Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

dynamic state changes

Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
02-02-2005 09:00
It'd be useful if there was some way to change state dynamically at run-time. What I mean by this is that I'd like to store the name of a state to a variable, and then change state to whatever state is stored in the variable. This would make it possible to call a state sort of as a sub-routine: set a global variable to the name of the state I'm in, jump to some state that quickly does something (say, prompt the user with an llDialog), and then that state jumps to whatever state called it, by jumping to whatever state is stored in the global variable.

There could b eother uses to this, as well. It can be done by a series of if statements, but that's ugly.
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
02-02-2005 09:07
I actualy wrote a stand alone script for generating Dialog Box's that works by using Linked Messages; to generate the box and return the results to the requesting prim; i'll post it somewhere when i get home (runs out door).
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Tread Whiplash
Crazy Crafter
Join date: 25 Dec 2004
Posts: 291
PHP anyone?
02-02-2005 12:51
From: Lex Neva
What I mean by this is that I'd like to store the name of a state to a variable, and then change state to whatever state is stored in the variable.


PHP allows this sort of thing - called "variable variables". It allows you to store the name of a function or variable inside another variable - then call or access the original via the "special" variable. Quite handy, I must admit! And the latest versions of PHP also allow assigning references to variables (a la C++).

Either implementation in LSL would be most welcome! Pass-by-reference implementations could also cut down on memory usage, too!

Take care,

--Noel "HB" Wade
(Tread Whiplash)
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
02-02-2005 21:55
Function pointers would be cool ^_^
They take a bit to wrap your mind around if you never used them before.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
02-03-2005 05:58
From: Tread Whiplash
PHP allows this sort of thing - called "variable variables".


From: Strife Onizuka
Function pointers would be cool ^_^
They take a bit to wrap your mind around if you never used them before.


Yeah, I was thinking along both of these lines. Perl and PHP both do what I think would work well: simply store the name of the thing you're talking about, and use that like a function or variable. Simple, clean. Should make fairly good intuitive sense to people who haven't seen anything like that before. At the very least, a line like this:

CODE

state "foo";


makes fairly good intuitive sense.