ElmutiKelmuti Posted August 30, 2014 Share Posted August 30, 2014 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 Quote Link to comment Share on other sites More sharing options...
shadmar Posted August 30, 2014 Share Posted August 30, 2014 If you in your script add this : Script.player=""--entity Then in your scene tab, you can drag and drop your player entity. You will need to reference they player as self.player in the script. 1 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
ElmutiKelmuti Posted August 30, 2014 Author Share Posted August 30, 2014 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 Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 30, 2014 Share Posted August 30, 2014 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 1 Quote 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 More sharing options...
beo6 Posted August 30, 2014 Share Posted August 30, 2014 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 Quote Link to comment Share on other sites More sharing options...
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.