Objects in ChoiceScript

I’ve mentioned it to Dan, but he is quite busy, so I’m not surprised not to have heard back yet. I am continuing to make use of this code in my current CS project, and when the time comes that I have a finished game and he can see it in action, I hope he’ll be inclined to accept it as official. In the meantime, I’ll continue to test it, as I am making extensive use of it myself. My first scene file is nothing but setting up the objects I’ll be using throughout the game, over 700 lines long.

I’ve noticed that I sometimes use an instruction that sets the current value of an element variable to the corresponding object element. It looks like this:

*set_elem obj elem elem

It feels a bit senseless to have to type the element name and then the element variable name in the case where they are exactly the same. So I was considering modifying the *set_elem instruction to accept only two arguments instead of three, and to default the third argument to the second one, so that the above could also be written as

*set_elem obj elem

It makes sense to retain the three argument version too, so as not to break any existing code that might use it, and because sometimes one might want to use a string, number, boolean, or non-element variable as the third argument, as in

*set_elem obj elem "string value to be assigned to the element"

Have you been using the *set_elem instruction much, @CJW, or otherwise have an opinion about this? It wouldn’t be much of a change to the JS, simply allowing the instruction to have 2 or 3 arguments, and defaulting the third one to the second one if the third one is missing. It’s not any more efficient, but I prefer to minimize typing. Just wondered if you had an opinion on the matter.

I see no reason why not, I’ll actually get back to you in more detail soon.

The link doesn’t seem to work. Is it still available to download?

I’ve got the original version (before the boolean fix):
https://dl.dropbox.com/u/7840892/CJW/choicescript/mods/eposic/CSObjects.zip

If you use it be sure to credit @eposic though.

Very cool. I’m not sure I’ll use it here, but object oriented programming is the bee’s knees.

Of course, he deserves a lot of credit and I’ll definitely remember that if I use it.

I really want to try this but the links not working :frowning:

I’ve not been doing any ChoiceScript programming for a long time now. Am
not maintaining anything that had to do with ChoiceScript, and have
changed computers since I was working on CS, and don’t have any CS code
on my new computer. If someone else has a copy of the CSObject code I
wrote, you’re free to use it.

1 Like

Does anybody have a copy of this code that I could try out?

Thanks

1 Like

I don’t have the code listed here but if you want to try objects on CS I made it possible on a little project of mine.

I never tried what @eposic did here so I don’t know how different our approaches are.

1 Like

Awesome, thanks!

I will try it out!