I'm having trouble getting this variable assignment to work:
[code]local sm = ents.FindByName("startmark"):GetPos()[/code]
Thanks.
That means no entity by the name of startmark could be found. Note that if you set the name serverside it won't be accessible clientside.
ents.FindByName returns a table, not an entity.
[QUOTE=Lexic;18207922]ents.FindByName returns a table, not an entity.[/QUOTE]
How would I remedy that?
table.tostring?
If true, how would I go about using it?
edit: I set the name as a keyvalue in Hammer, that's the name, right?
[QUOTE=snuwoods;18208210]How would I remedy that?
table.tostring?
If true, how would I go about using it?
edit: I set the name as a keyvalue in Hammer, that's the name, right?[/QUOTE]
[lua]
local ent = ents.FindByName("myentname")[1]
if ValidEntity(ent) == false then
-- No entity found
else
-- Do something with the ent
end
[/lua]
And to understand tables in lua :
[url]http://wiki.garrysmod.com/?title=Tables[/url]
edit : Hmm actually that page is a bit lacking in advanced stuff, go to the lua section of the wiki and read Programming in Lua instead. :smile:
[lua]local sm = ents.FindByName("startmark")[1]:GetPos()[/lua]
Assuming that the first value in the table returned is valid, not nil, and the value your trying to find the position of :)
Sorry, you need to Log In to post a reply to this thread.