Author Topic: I Object! (Your honor...)  (Read 927 times)

Castleberg

  • Newbie
  • *
  • Posts: 37
I Object! (Your honor...)
« on: December 03, 2021, 04:51:17 AM »
Is it just me, or is voice attack missing Objects? It seems that it would be made much more organized (and thereby efficient) if we had access to objects.

Perhaps, like the way we can back ourselves into array like behavior there is a way to back ourselves into array buect like behavior that I'm missing. Can someone enlighten me?

Can I create something that emulates :

Car{
Color = blue
MaxSpeed = 150
Wheels = 4
}

Such that :
Car.color = blue
Car.maxspeed = 150
Car.wheels = 4

And such that I can say something like

Lamborghini = new instance of car
Lamborghini.maxspeed = 200

And lamborghini.color = blue
Lamborghini.maxspeed = 200
Lamborghini.wheels = 4

And printing lamborghini.doors to the log would reveal "not set"

But if I added

Lamborghini.doors = 2

Then the above would print "2".

Sorry for the above code being imprecise, but you get the idea.

I recognize I could create a myriad of variables:

Car1Color = blue
Car1maxSpeed = 150
Car1wheels = 4

Lamborghini Color = blue
Lamborghini MaxSpeed = 200
....etc

And thus might functionally be similar, but I fear by the time I am done I will have literally thousands, if not hundreds of thousands of variables floating around, mist if which having "save value to profile" checked in my case, and this will be impractical.

Any thoughts or advice on either emulating what I need, or in actually bringing this kind of functionality to the software?




Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4781
  • RTFM
Re: I Object! (Your honor...)
« Reply #1 on: December 03, 2021, 11:43:50 AM »
Plugins have access to the "SessionState" dictionary, which can store arbitrary objects.

You will need to do your own (de)serialization and storage (E.G. through a JSON library).