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.