• LuaProblem
    10 replies, posted
I get a problem with this specific line of code [LUA]self:CapabilitiesAdd( CAP_MOVE_GROUND | CAP_MOVE_JUMP | CAP_OPEN_DOORS )[/LUA] Ive tried adding NPC instead of self that didnt work this is the error I get with the code [ERROR] addons/psb-snpcs5/lua/entities/npc_ceratosaurus/init.lua:112: ')' expected near '|' 1. unknown - addons/psb-snpcs5/lua/entities/npc_ceratosaurus/init.lua:0 ` EDIT: The above problem was fixed thanks but now I have these errors with this code [LUA]if self:HasCondition(COND_FLOATING_OFF_GROUND) == true then[/LUA] [ERROR] addons/coelophysis_alpha6/lua/entities/npc_raptor/init.lua:214: bad argument #1 to 'HasCondition' (number expected, got nil) 1. HasCondition - [C]:-1 2. unknow
I don't know if this would work, but try this: [lua] self:CapabilitiesAdd( CAP_MOVE_GROUND ) self:CapabilitiesAdd( CAP_MOVE_JUMP ) self:CapabilitiesAdd( CAP_OPEN_DOORS ) [/lua]
I have a new problem under the edit marker
It's obvious that the enumeration has been modified. Try self:HasCondition( 61 ) for now. According to [url=http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4389.html#COND]the old wiki[/url] that's what the enumeration is meant to be. [editline]5th March 2014[/editline] Oh and by the way you don't need the "== true" part, just the function returning the boolean works fine.
I put this in and I still get the errors [LUA]if self:Health() < self.health/3 || self:HasCondition( 31 )(COND_ENEMY_UNREACHABLE) then[/LUA]
You can't do it like that. You need to use the function multiple times: [lua]if self:Health() < self.health/3 || self:HasCondition( 31 ) || self:HasCondition( COND_ENEMY_UNREACHABLE ) then[/lua] Not to mention you're checking the same thing twice. Not sure if that's intentional.
Ok I see my error thanks
[QUOTE=Handsome Matt;44136818]Bitwise operators were removed in GMOD13. Not sure why but here's the [i]new[/i] way to do it: [lua]self:CapabilitiesAdd( bit.bor( CAP_MOVE_GROUND, CAP_MOVE_JUMP, CAP_OPEN_DOORS ) )[/lua][/QUOTE] I tried to do the same thing as the original poster without luck, and this method doesn't fix the problem for me. Is it because I'm using a NextBot?
[QUOTE=Handsome Matt;44538482]Yes; they work very differently than the other SNPCs. [URL="http://wiki.garrysmod.com/page/NextBot_NPC_Creation"]Read this![/URL][/QUOTE] Thank you, I'm very new to this. I'll look into it :)
Sorry, you need to Log In to post a reply to this thread.