Jump to content

The Hankinator's UI library


thehankinator
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...