Jump to content

Recommended Posts

Posted

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?

Posted

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.

Let's build cool stuff and have fun. :)

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.

×
×
  • Create New...