Jump to content

Getting vars from other objects?


Andy Gilbert
 Share

Recommended Posts

Ive got myself a little stuck using lua in editor.

 

I have objects with scripts attatched and one of them uses the:

 

Script.entityName = nil --entity "Pivot"

 

so i can reference to that entity within the script, this entity also has a script attatched with some variables set. As i can now access the entity's properties such as GetPosition, GetRotation ETC, How would I access the entities scripts variables?

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

uh...I want to make sure you've done it correctly, so that uh, you don't have any issues with it in the future, mind if I check your methods for you? free of charge of course

Core I5 2.67 / 16GB RAM / GTX 670

Zbrush/ Blender / Photoshop CS6 / Renoise / Genetica / Leadwerks 3

Link to comment
Share on other sites

Of course. smile.png Sorry i should have put this for others. When you have a entity referenced that has a script attached with variables initialised within. Its a simple case of:

 

myVar = self.entity.script.VarName

 

As a side note, i got this from looking through darkness awaits scripts.

 

Andy

  • Upvote 1

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

myVar = self.entity.script.VarName

 

In your example there, "self" and "script" are the same object, so this is more straightforward:

myVar = self.VarName

 

To access values on another entity, using a pick result as an example:

if world:Pick(0,0,0, 0,0,1, pickinfo) then
if pickinfo.entity.script~=nil then
a = pickinfo.entity.script.Varname
end
end

  • Upvote 1

 

 

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...