Jump to content

Referencing Entities in the Scene


ElmutiKelmuti
 Share

Recommended Posts

How would I reference entities in the scene?

 

I have this health giving box that I'm setting up for the default player that comes with the demo, but I have no Idea how to index the player entity

 

Script.HealthPerUse = 15
Script.Uses = 2
Script.Sound = ""
function Script:Use()
if Script.Uses > 0 then
 print("Health giver used!")
 local player = I_DONT_KNOW
 player:ReceiveHealth(Script.HealthPerUse)
 Script.Uses = Script.Uses - 1
end
end

Link to comment
Share on other sites

I have this set up as the Script of the box

 

Script.HealthPerUse = 15
Script.Uses = 2
Script.Sound = ""
Script.player = ""
function Script:Use()
if self.Uses > 0 then
 print("Health giver used!")
 local player = I_DONT_KNOW
 player:ReceiveHealth(self.HealthPerUse)
 self.Uses = self.Uses - 1
end
end

 

However I checked through all the properties in the box, and it doesn't have any of the properties I set to it in the script

Link to comment
Share on other sites

This:

Script.player=""--entity

is not the same as this:

Script.player = ""

 

the commented text after the script variables will allow you to set options/parameters in the editor as explained here at the bottom of the article: http://www.leadwerks.com/werkspace/page/tutorials/_/script/creating-your-first-object-script-r110

  • Upvote 1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

How do you call the Use function?

I would guess you use it from the player script, so you should be able to just give the player entity with it.

 

as a side node. But definetly my own opinion:

I would not let another entity play around with the player functions. That way the box don't even need to know the player

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