I'm writing a simple script for my server that spawns two ammo crate entities automatically on server start. This is what i wrote, and saved as a lua file in my server's lua/autorun/server directory.
[LUA]local function crateSpawn()
local ammod = ents.Create("AmmoCrate")
ammod:SetPos(-1928.458862 357.966750 -95.968750)
ammod:Spawn()
ammod:SetPos(-1869.265503 357.966750 -95.968750)
ammod:Spawn()
end[/LUA]
I'm very new to LUA scripting and was wondering if anyone could shed some light on why this would not work?
You need to create a new one again instead of reusing the first one.
[lua]
local function crateSpawn()
local ammod = ents.Create("AmmoCrate")
ammod:SetPos(-1928.458862 357.966750 -95.968750)
ammod:Spawn()
ammod = ents.Create("AmmoCrate")
ammod:SetPos(-1869.265503 357.966750 -95.968750)
ammod:Spawn()
end[/lua]
Could someone post a simple example for how to make a cube with meshes.
Also, what's the difference between IMesh and mesh?
Hey. I'm having an issue with vehicles in GMod 13.
When trying to spawn the vehicle in my gamemode, it puts out this error:
[code]
Vehicle () unable to properly initialize due to script error in (scripts/vehicles/ambo.txt)!
[/code]
Is there anything new with vehicle scripts in GMod 13 that I'm not aware of?
When I spawn an entity and read its angles, I get a value.
When I don't move this entity, and then freeze it, I get that same value.
Yet when I set an entity's angles to anything involving a change in pitch in its initialize, this is not the case.
I have an entity that I change the pitch of upon initialization. I spawn it, and then I read its angles. Then I don't move it, only freeze it at what [b]appears[/b] to be that same angle. I read the angles again, and I get a different value: Same pitch, previous yaw - 180, previous roll + 180.
Why?
I'm coding something really simple for Computercraft in Minecraft, which uses Lua, I got this as code:
[img]http://puu.sh/Xs2o[/img]
and this is the output:
[img]http://puu.sh/Xs2v[/img]
Does anyone know what's wrong? It should be only outputting "It's not night."
Use and instead of or on the second if-statement.
Okay, now it says it's night in daytime!
Code:
[img]http://puu.sh/XtUb[/img]
Output:
[img]http://puu.sh/XtTW[/img]
Just change what it prints then:downs:
Thing is, it says nighttime when it's nighttime.
Are you sure os.time() resets when a new day begins?
[QUOTE=Staneh;37345148]Thing is, it says nighttime when it's nighttime.[/QUOTE]
Do you have the numbers right?
Also, I think an "else" would be better than a second if
[QUOTE=ralle105;37345214]Are you sure os.time() resets when a new day begins?[/QUOTE]
Yes I am.
[editline]21st August 2012[/editline]
[QUOTE=my_hat_stinks;37345279]Do you have the numbers right?
Also, I think an "else" would be better than a second if[/QUOTE]
I just lost the Minecraft world where the computer was in, so I'll be trying it again later. :|
Should I be using ply:Respawn() at the end of a round or is ply:Spawn() fine? I currently use ply:Spawn() for dead and alive players to reset positions at the end of a round. It seems to work okay but sometimes players don't choose a spawn place correctly (they spawn where the spectate camera was at the time the player is spawned, assuming they are dead). it doesn't happen all the time, it seems random
Here's a weird problem (or maybe it isn't, I can't explain it);
Sometimes the arrow-texture I'm using in Holopad becomes corrupt. The texture fixes itself if I change to another texture and then switch back;
[img]https://dl.dropbox.com/u/902553/Pictures/Screens/Holopad/whatthe.png[/img]
Those fuzzy blobs at the end of each line should be coloured arrows.
Here's the draw code I'm using;
[lua]
surface.SetTexture(surface.GetTextureID("holopad/arrowup_solid"))
surface.SetDrawColor(colour)
surface.DrawLine(centrepos.x, centrepos.y, pos.x, pos.y)
surface.DrawTexturedRectRotated(pos.x, pos.y, 16, 16, ang)
[/lua]
And here's the texture in question (all the textures I use for the arrow suffer from this problem, and are similar)
[url=https://dl.dropbox.com/u/902553/Misc%20Files/arrowup_solid.zip]arrowup_solid.zip[/url]
I know this isn't much to go on but I really don't have any other info to give, I'm at a loss here.
Code:
[code]
local PANEL = {};
local cinematicAlpha = 255;
local topSlider = 100;
local bottomSlider = 100;
local defaultColor = 0;
function PANEL:Init ( )
self:SetMouseInputEnabled( false );
end;
function PANEL:PerformLayout ( )
self:SetPos(0, 0);
self:SetSize(ScrW(), ScrH());
end;
function PANEL:Paint ( )
surface.SetDrawColor( 0, 0, 0, 255);
// Sliders
surface.DrawRect(0 , 0, ScrW(), topSlider );
surface.DrawRect(0 , (ScrH())-bottomSlider, ScrW(), 100 );
// Center Cinematic Text
draw.SimpleText("[UGR] DarkRP, 2012", "darkrp_IntroTextBig", ScrW()/2, ScrH()/2, Color(255, 255, 255, cinematicAlpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
draw.SimpleText("July, 27 Another Boring Day.", "darkrp_IntroTextSmall", ScrW()/2, (ScrH()/2)+35, Color(255, 255, 255, cinematicAlpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
end;
function PANEL:Think()
timer.Simple(5, function() cinematicAlpha = math.Approach(cinematicAlpha, 0, 2) end );
if cinematicAlpha < 10 then
value = true;
end;
if (value) then
topSlider = math.Approach(topSlider, 0, 1);
bottomSlider = math.Approach(bottomSlider, 0, 1);
defaultColor = math.Approach(defaultColor, 100, 1);
end;
if defaultColor > 99 then
hook.Remove("RenderScreenspaceEffects", "BlackWhite");
self:Remove();
end;
end;
function BlackWhiteEffect ( )
local bwe = {}
bwe[ "$pp_colour_addr" ] = 0
bwe[ "$pp_colour_addg" ] = 0
bwe[ "$pp_colour_addb" ] = 0
bwe[ "$pp_colour_brightness" ] = 0
bwe[ "$pp_colour_contrast" ] = 1
bwe[ "$pp_colour_colour" ] = defaultColor/100;
bwe[ "$pp_colour_mulr" ] = 0
bwe[ "$pp_colour_mulg" ] = 0
bwe[ "$pp_colour_mulb" ] = 0
DrawColorModify( bwe )
end;
hook.Add( "RenderScreenspaceEffects", "BlackWhite", BlackWhiteEffect )
vgui.Register("darkrp_cinematic_intro", PANEL);[/code]
Result:
[img]http://ugr-gmod.com/dapic.jpg[/img]
I got no idea how to solve.
[B]Edit[/B]
Console:
[url]http://pastebin.com/VSAnPVFB[/url]
You haven't actually asked a question there. You've posted some code and a picture, but not what your problem is.
Also, don't combine timers and think hooks. Use one or the other but not both.
Sorry Lexic, I'm very tired at the time. I'll try to be as detailed as possible. So what the problem is, It's the Middle text that's supposed to appear.
And Fade away, there should be two bars like on a 16:9 movie. And gray background until it fades away with that timer. Oh and this is on Gmod13.
Anyone know how to suppress console death messages in GM12?
Like "Player1 killed Player2 using somegunclass"
I tried looking through the TTT source, no joy
Thanks for any help
[QUOTE=Trumple;37348495]Anyone know how to suppress console death messages in GM12?
Like "Player1 killed Player2 using somegunclass"
I tried looking through the TTT source, no joy
Thanks for any help[/QUOTE]
Call PlayerSilentDeath after PlayerDeath hook. Like:
[lua]
function GM:PlayerDeath(victim, infl, attacker)
self:PlayerSilentDeath(victim)
end
[/lua]
I'm having some trouble getting a fretta-based gamemode to start rounds. I've got roundbased set to true, but rounds never start. The HUD always reads Round 0, timer 00:00. No LUA errors are printing to console either. Am I missing something right in front of me?
Thanks in advance
EDIT: I had overwritten frettas GM:Initialize with my own in the gamemode's init.lua. After taking that out, Frettas Base Initialize takes over. Problem solved.
[QUOTE=me-name-bob;37348594]I'm having some trouble getting a fretta-based gamemode to start rounds. I've got roundbased set to true, but rounds never start. The HUD always reads Round 0, timer 00:00. Am I missing something right in front of me?
Thanks in advance[/QUOTE]
Did you set a value to GM.RoundLength ?
[QUOTE=ralle105;37342370]IMesh uses a vertex buffer, mesh is immediate mode.
Here's the code for the old MeshCube function
-lua-[/QUOTE]
I guess I worded that in the wrong way.
How do I make anything with a mesh; the actual mesh code.
[QUOTE=Undefined;37348622]Did you set a value to GM.RoundLength ?[/QUOTE]
yep, set to 60 * 5. Also, I just edited the last post. I'm not getting any errors in console
I've had no luck with Mesh:BuildFromTriangles ( never renders ), but the mesh library is fine.
[code]local function Vert( pos, normal, u, v, c )
mesh.Position( pos )
mesh.Normal( normal )
mesh.TexCoord( 0, u, v )
mesh.Color( c.r, c.g, c.b, c.a )
mesh.AdvanceVertex( )
end
t:Translate( position )
t:Rotate( angle )
cam.PushModelMatrix( t )
mesh.Begin( MATERIAL_QUADS, 1 )
Vert( a, normal, 0, 0, color_white )
Vert( b, normal, 1, 0, color_white )
Vert( c, normal, 1, 1, color_white )
Vert( d, normal, 0, 1, color_white )
mesh.End( )
cam.PopModelMatrix( )[/code]
It's fairly straight forward. You have several different modes In the beta we have render.OverrideDepthEnable( bEnable, bDepth ) which lets your meshes be depth sorted.
Your primitive types are
[code]MATERIAL_LINE_STRIP
MATERIAL_LINES
MATERIAL_TRIANGLES
MATERIAL_POINTS
MATERIAL_QUADS
MATERIAL_POLYGON
MATERIAL_TRIANGLE_STRIP
MATERIAL_LINE_LOOP
[/code]
[QUOTE=me-name-bob;37348634]yep, set to 60 * 5. Also, I just edited the last post. I'm not getting any errors in console[/QUOTE]
GAMEMODE tables set serverside need to be networked. Just use the net library or umsg library and send the time to the player everytime it changes.
OR do clientside prediction, like calling the message on the client then having the time decrease clientside instead of sending a new message everytime it changes.
[QUOTE=jrj996;37349429]GAMEMODE tables set serverside need to be networked. Just use the net library or umsg library and send the time to the player everytime it changes.
OR do clientside prediction, like calling the message on the client then having the time decrease clientside instead of sending a new message everytime it changes.[/QUOTE]
Thanks anyway, but it was something else. I had overwritten GM:Initialize, so when I took it out, frettas base initialize, which contains all the good stuff i need to start, is used. Problem Solved. My bad, but thank you.
Sorry, you need to Log In to post a reply to this thread.