|
Sofia Weir
Registered User
Join date: 5 Feb 2007
Posts: 26
|
04-25-2007 01:19
Hello
I am creating a HUD which includes several buttons. The buttons send chat messages in a near by object and change its position and rotation. Each of the buttons represent a position change (left right, rotate left, rotate right etc) when press the object rotates or moves just a little bit.
Well these commands are transmitted from HUD buttons to the object through a special "command" channel, represented by a cmd_channel constant in each script.
If I want to have multiple instances of the objects ( controled by different HUDs of course, many players), I have to go into each object and HUD button and change the constant of the channel i use so The commands dont mess up with each other.
Each HUD and respective object must have a special command channel different from the others or they will interfere...
Is there a method that I could controll the channels externaly or in a more global way? e.g In the parent object of each HUD to have the channel constant and reference it from inside each linked button, rather than have to copy it in each child script.
I figured these methods my self i dont know what other people do in this case... If you could point me out an example or method I whould really appreciate it...
ALso can somebody assign a value to a variable inside a script of an object on rez event, and then until the object dies to have it stored? Like a property or something!(So I could assign the channel value in each instanceof the controled objects on rez event..)
Thanx
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
04-25-2007 01:49
From: Sofia Weir Hello
I am creating a HUD which includes several buttons. The buttons send chat messages in a near by object and change its position and rotation. Each of the buttons represent a position change (left right, rotate left, rotate right etc) when press the object rotates or moves just a little bit.
Well these commands are transmitted from HUD buttons to the object through a special "command" channel, represented by a cmd_channel constant in each script.
If I want to have multiple instances of the objects ( controled by different HUDs of course, many players), I have to go into each object and HUD button and change the constant of the channel i use so The commands dont mess up with each other.
Each HUD and respective object must have a special command channel different from the others or they will interfere...
Is there a method that I could controll the channels externaly or in a more global way? e.g In the parent object of each HUD to have the channel constant and reference it from inside each linked button, rather than have to copy it in each child script.
I figured these methods my self i dont know what other people do in this case... If you could point me out an example or method I whould really appreciate it...
ALso can somebody assign a value to a variable inside a script of an object on rez event, and then until the object dies to have it stored? Like a property or something!(So I could assign the channel value in each instanceof the controled objects on rez event..)
Thanx You could use the description field of the HUD to contain the channel ID and then have the script read this when attached. From your description it sounds like each button contains its own script, it may be simpler and more efficient to have a single script in the root prim that handles all of button presses using the llDetectedLinkNumber Any variable declared out side of the scope of an event handler will be global to that script.
integer MyGlobal;
default { state_entry() { MyGlobal = 1; }
on_rez(integer num) { MyGlobal = num; } }
You can also get access to the rez parameter at any time using llGetStartParameter as long as you dont reset the script.
|
|
Adrian Zobel
Registered User
Join date: 4 Jan 2006
Posts: 49
|
04-25-2007 03:30
"I have to go into each object and HUD button and change the constant of the channel i use so The commands dont mess up with each other." Quick answer: the channel should be a variable, not a constant.
"Is there a method that I could controll the channels externaly or in a more global way?" Is there some sort of arena or play-area where these objects are rezzed? If so, there could be some sort of central-control object that assigns channels to HUDs on request and rezzes corresponding objects to control.
"ALso can somebody assign a value to a variable inside a script of an object on rez event, and then until the object dies to have it stored? Like a property or something!" Yes, prims do have properties. You could change the color of the prim, and then all the scripts could use llGetColor() when they start up. Or you could have one script set the description and all the other scripts could use llGetObjectDesc() to read it.
There are other ways, too. You could have the main script in the HUD do a random such as cmd_channel = 1000000+(integer)llFrand(5000000); and then tell all the other scripts the choice by linkmessage. Or you could base it on something less random, like the MLP scripts do: cmd_channel = (integer)("0x"+llGetSubString((string)llGetKey(),-4,-1))
However, it's not just a matter of telling all the scripts in the HUD, there's also these objects that are not linked to the HUD. Does the object choose a channel and then tell the HUD, or does the HUD choose a channel and tell the object? Or maybe a central control thingy decides the channel and tells both the HUD and the object? For that matter, does the HUD rez the object or does the object come from somewhere else? If the HUD rezzes the object you could tell it what channel to use with the rez parameter.
The best way to do it will depend on how your whole system works. Although your post is titled "in Linked Objects", the bigger problem is how to share the information with other objects (and maybe even other HUDs) that are NOT linked.
|