Here’s a summary of what I have already implemented. To define a class, all we need is this:
*create class_dragon "name,hp,color,alignment"
The “class_” prefix is required. The default maximum length of each field is 20. If another value is needed, we can declare it this way:
*create class_dragon "name:35,hp:3,color,alignment"
The class base string will be used to control the class parameters as well as to store all instances. My perception is that this way is the easiest to use for the end user.
However, we need to create some variables to store the instances we fetch, like this:
*create currentdragon_name ""
*create currentdragon_hp 0
*create currentdragon_color ""
*create currentdragon_alignment ""
To create a new instance, this is the syntax:
*gosub_scene objects new "dragon" "John,50,blue,lawful evil"
*gosub_scene objects new "dragon" "Trevor,70,green,chaotic good"
Now we have two dragons, ready to be summoned.
If we want the “currentdragon” variable set to be filled at the same time, we can use:
*gosub_scene objects new "dragon" "John,50,blue,lawful evil" "currentdragon"
currentdragon_name == “John”
currentdragon_hp == 50
currentdragon_color == “blue”
currentdragon_alignment == “lawful evil”
We can, of course, have more than one instance active at a given time, we just need more variables…
*create myotherdragon_name ""
*create myotherdragon_hp 0
*create myotherdragon_color ""
*create myotherdragon_alignment ""
To fetch an instance, we use:
*gosub_scene objects get "dragon" "name" "Trevor" "myotherdragon"
This will fetch the first dragon named Trevor that has been stored and puts it into the “myotherdragon” variable set:
myotherdragon_name == “Trevor”
myotherdragon_hp == 70
myotherdragon_color == “green”
myotherdragon_alignment == “chaotic good”
Now they can fight each other.
Right now I am working on other methods, one to change the value of an instance’s field, another to destroy an instance, and a third to randomly return an instance.
Much of what I wrote above is compatible with the behavior you intended for cslib_class, but since I am working with a different approach for storing the instances I had to write the code from scratch.
I’ll share the code later today or tomorrow, once I have the remaining methods completed. But I wanted, for now, to know what you think about the direction this is taking. My idea is to make it as simple as possible for anyone who wants to use it.