Lavishscript container usage question

mistahmikey

Active Member
I would like to create a list of specific Actors. I tried to do this as follows:

variable index:actor Members

Members.Insert[Me.ToActor]

The above returns "1" and Members.Used returns "1".

But ${Members[1].Name} returns NULL.

I have scoured the Lavishscript wiki, and it appears that the Insert member and method both create a new subtype in the container initialized by the provided parameters. I figured since Lavishscript didn't complain about the use of Me.ToActor as the initialization parameter, it would have least created a copy of it in the index. But apparently not.

I really want to add a reference to an existing actor into my index if possible, but I have been unsuccessful discovering how to do this. I realize I could create an int index and instead store the Actor IDs, but I was hoping to avoid having to indirectly access my actors through the Actor TLO.

So this really all boils down to the following. Is it possible store a reference to an existing object in a variable? Or are objects only accessible via the variable used to create them?
 

Kannkor

Ogre
I would like to create a list of specific Actors. I tried to do this as follows:

variable index:actor Members

Members.Insert[Me.ToActor]

The above returns "1" and Members.Used returns "1".

But ${Members[1].Name} returns NULL.

I have scoured the Lavishscript wiki, and it appears that the Insert member and method both create a new subtype in the container initialized by the provided parameters. I figured since Lavishscript didn't complain about the use of Me.ToActor as the initialization parameter, it would have least created a copy of it in the index. But apparently not.

I really want to add a reference to an existing actor into my index if possible, but I have been unsuccessful discovering how to do this. I realize I could create an int index and instead store the Actor IDs, but I was hoping to avoid having to indirectly access my actors through the Actor TLO.

So this really all boils down to the following. Is it possible store a reference to an existing object in a variable? Or are objects only accessible via the variable used to create them?
Oh boy..

declaring an actor datatype, is the same as using the actor TLO, since it is an actor datatype also. You're just skipping the searching part of it.

Generally speaking, computers take numbers over strings. It's much faster. So this: Members.Insert[Me.ToActor] doesn't make sense. It's been a while, but I'm confident to say, when setting an actor datatype, you use the ID. (and in this case, you weren't even setting it to your name, you set it to the string "Me.ToActor").

Until you get it 'working', drop the index, it will only add extra complexity you don't need. Work with a single actor variable, then when it's working, refactor it into an index.
 

mistahmikey

Active Member
Oh boy..

declaring an actor datatype, is the same as using the actor TLO, since it is an actor datatype also. You're just skipping the searching part of it.

Generally speaking, computers take numbers over strings. It's much faster. So this: Members.Insert[Me.ToActor] doesn't make sense. It's been a while, but I'm confident to say, when setting an actor datatype, you use the ID. (and in this case, you weren't even setting it to your name, you set it to the string "Me.ToActor").

Until you get it 'working', drop the index, it will only add extra complexity you don't need. Work with a single actor variable, then when it's working, refactor it into an index.
Heh. Well, if you are familiar with programming in languages like C++ or Java, the concept of inserting a reference to an object into a container makes perfect sense, which is what I had hoped Members.Insert[Me.ToActor] would do. After all, ts an list of actors, Me.ToActor is an actor, so what is senseless about trying to insert an actor into a list of actors? But obviously, Lavishscript is a different beast than those languages, and is unfortunately a bit arcane since the documentation is thin in important areas, so it is far from obvious what a statement like Members.Insert[Me.ToActor] is actually doing. My goal in using the index was to reduce the complexity of what I want to do, which is to monitor the effects on selected members of my group or raid. As with all programming solutions, there is always more than one way to skin the cat, and I will move on to different methods if necessary. But having tried to do what, in my considerable experience with C++ and Java, should have been straightforward, I am now curious as to why it is not so I can better understand how Lavishscript works.

So if anyone would be kind enough to explain to me the semantics of the Members.Insert[Me.ToActor] statement, I would be most appreciative.
 

macker0407

Active Member
Me.ToActor is an actor
Not really, the sequence Me.ToActor reduces to a string(your character name), and LavishScript is all about red wine reductions.

Code:
variable string InceptionOne   = "InceptionZero"
variable string InceptionTwo   = "InceptionOne"
variable string InceptionThree = "InceptionTwo"
variable string InceptionFour  = "InceptionThree"
function main()
{
    echo Let's peel back the layers
    echo 4 deep: ${${${${InceptionFour}}}}
    echo 3 deep: ${${${InceptionFour}}}
    echo 2 deep: ${${InceptionFour}}
    echo 1 deep: ${InceptionFour}
}
Anyway, 5 minutes of reading the LavishScript wiki would have given you the following:
References to objects exist only within explicitly defined data sequences, thus allowing external objects to be lost gracefully while a script is waiting for a timeslice (e.g. a character in a game may disappear before the next timeslice, and this will not cause synchronization problems)
Which should be a subtle hint as to why arbitrary reference creation doesn't exist.
 
Top Bottom