CangoJoe Posted July 3, 2016 Share Posted July 3, 2016 Excellent, that's what I needed - thanks! So with Lua and Leadwerks in general, in order to keep a script 'alive' does it always need to be attached to an element (like a pivot) in the scene? For instance if I wanted to create a script that tabulates what Journal entries the player has selected over the course of the game I would need to attach this 'tabulation.lua' to a something like a pivot - yes? Quote Link to comment Share on other sites More sharing options...
thehankinator Posted July 3, 2016 Author Share Posted July 3, 2016 Excellent, that's what I needed - thanks! So with Lua and Leadwerks in general, in order to keep a script 'alive' does it always need to be attached to an element (like a pivot) in the scene? For instance if I wanted to create a script that tabulates what Journal entries the player has selected over the course of the game I would need to attach this 'tabulation.lua' to a something like a pivot - yes? A script that is attached to an element will only stay alive until you call world:Clear() (this is done when you load a new level for instance). For something to persist through loading levels you would probably want to use a global variable to store that information. You can also load scripts in Main.lua, the items in those scripts would be global and would persist through a world:Clear(). This tutorial talks more about global variables. Bare in mind that the Journal script will likely need to be modified to use global variables to track progress through a world:Clear() http://www.leadwerks.com/werkspace/page/tutorials/_/variables-r14 Quote Link to comment Share on other sites More sharing options...
CangoJoe Posted July 3, 2016 Share Posted July 3, 2016 Interesting... so all variables, unless declared Local, are Global even between scripts. A little scary IMO but it explains some of my other scripting snafus. Guess I'll have to be more careful on variable naming and scope. Regardless, thanks for all the info - It sheds a lot of light on how Leadwerks and Lua work together! Quote 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.