YouGroove Posted April 20, 2014 Share Posted April 20, 2014 I had some simple GetPosition inside a function called walk() called from UpdateWorld() : local positionPlayer = self.entity:GetPosition(true) if positionPlayer.x < self.xminPos then -- self:walkMinPos() else -- --self:walkMaxPos() end It didn't worked as i had nil for that code : self.entity:GetPosition(true) Is that normal ? I put above code directly in UpdateWorld() instead of calling a function and it worked ? Is something i do in bad way ? would not self.entity accessible from any function we create ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted April 20, 2014 Share Posted April 20, 2014 Make sure you defined your walk function like: function Script:Walk() end My guess is you defined it just like: function Walk() end If you don't know why you need to do that then you don't have a fundamental idea of how Lua is working. Let me know and I can help explain. I'f I'm wrong then we need to see the entire script. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted April 20, 2014 Author Share Posted April 20, 2014 If you don't know why you need to do that then you don't have a fundamental idea of how Lua is working. Let me know and I can help explain. I use Lua for all ennemies, my own functions, even ennemies or player calling each other scripts, i'm not so newbbie with Lua in LE3 i guess ? That's simple : same code in UpdateWordl : ok same code in function : error nil That's not first time strange things happens with LE3. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted April 20, 2014 Share Posted April 20, 2014 Where is self.xmin defined or given a value? After seeing what you have there I now think that this function is being called before you define or give xmin a value. LE doesn't do anything strange to Lua, which is why the reason is 99.9% always your usage of it and not understanding how it works. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted April 20, 2014 Author Share Posted April 20, 2014 I just changed function name to walkToMin and calling it from updateWorld() it worked, the function is called and runned with any problem. What to say ? strange Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted April 20, 2014 Share Posted April 20, 2014 You keep not showing us the whole script so we have to guess... There is no mystery to programming. The computer does what you tell it to do, but we need to see the script to tell what's up. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted April 20, 2014 Author Share Posted April 20, 2014 Perhaps something i didn't seen, but just changing the name worked ? When i will upload the Shoothemup kit, you will be able to download it, it will have some comment for that function and we will take a look if you want Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.