Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
Scripting question

areibma
Registered User
Quote
2016-10-20 07:18:17

Hi,
If I have behavior script attached on my player character with its health, armor, gold etc, is it possible to access those properties from another behavior or action?
Another question, I am a bit confused about the custom mouse cursor script. Where do I attach that script?

Thank you


tim12345
Guest
Quote
2016-10-20 23:29:44

not sure what you're asking but i think yes, you should be able to access them from anywhere. custom mouse cursor script... the one thats a function? should be able to attach that anywhere with 'execute javascript' action


just_in_case
Moderator
Quote
2016-10-21 05:40:19

If You are asking to use the variable health,gold,armor ...
Then yes u can use it anywhere anytime in ur scenes...

not sure about other behaviours....if u can use them anywhere or not... maybe not..

And about custom mouse script i will advice u to use it with your root scenenode.. click on the root scene node...

Add a behaviour "before first drawing do something" ,assign an action "execute JavaScript " from special...and put that custom mouse script there... and click ok...

You are done....


areibma
Registered User
Quote
2016-10-22 05:49:40

wrote:
If You are asking to use the variable health,gold,armor ...
Then yes u can use it anywhere anytime in ur scenes...

Actually I am asking how do I access those properties from another script (behavior or action). e.g. If I shoot an enemy, how do I access the health property of enemy (which is attached to the enemy as behavior) from player script (which is attached to player)?

Thank you


just_in_case
Moderator
Quote
2016-10-22 11:46:16

They are special variable and yes u can change them by assigning a behaviour and then using the action set or change variable....

And type

player.health

here player is the name of scene node to which u have assigned game behaviour " player with health and ai"

And set the value to whatever you want for example on proximity with something set or change a variable...

Variable name = player.health
Subtract value..

Value =50

Now whenever the player get near to that object it health will decreases to half...

Hope that help you..


areibma
Registered User
Quote
2016-10-23 09:59:44

Can I access my custom variables same way?

Thank you for your reply.


just_in_case
Moderator
Quote
2016-10-23 10:55:01

Yes you can access your own created variables same way...


areibma
Registered User
Quote
2016-10-23 12:07:29

Thank you for your reply and help.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internationa?" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact