Mordred Posted February 1, 2014 Posted February 1, 2014 Hello fellow leadwerkers, it's me again and even though i am ashamed a bit, i have another question to ask. Refering a previous posting about how to access variables between different scripts i managed to get this set up quite well. But now i have another, mhm well, luxuary issue. It's a bit hard to always write something like: self.target.script.hud.script.strength = self.target.script.hud.script.strength + 1 thus i know that if i use: str = self.starget.script.hud.script.strength the engine only stores the actual value of "[...].strength" into "str". Now i know from C++ that you can use references (&<name>) and pointers (*name) to point to the memoryadress where those values are stored. So basically i do not want to have the actual value of "strength" to be stored in "str" but the memory adress, so i can use a shortcut to pass variables onto that adress. Is that possible in LUA too? Quote
Josh Posted February 1, 2014 Posted February 1, 2014 self.target.script.hud.script.strength = self.target.script.hud.script.strength + 1 In the case of things like this, I recommend using functions. That way you can change the way scripts work internally, and other scripts won't have to be updated. For example, I would do something like this: self.target.script:AddStrength(1) This is a common idea in object-oriented programming, and it will prevent your game from becoming a mess of spaghetti code. Quote My job is to make tools you love, with the features you want, and performance you can't live without.
Mordred Posted February 1, 2014 Author Posted February 1, 2014 Hello Josh and thanks for your reply, just a minute before i read your answer i came to the same conclusion and it does work pretty well Quote
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.