What Do you think of some cheap reflection?

For example:

number x
= x 100
string s
= s (varname x)
print "%\n" s ; prints "x"
= `(tovar s) 777 ; x is now 777

Comments

4 responses to “What Do you think of some cheap reflection?”

  1. tremblin Avatar
    tremblin

    Some internal things like vector locations will return “-booboo-” and will be an error trying to set them, though.

  2. tremblin Avatar
    tremblin

    By the way everything like labels, functions, and variables are all “variables” which would work with this.

  3. tremblin Avatar
    tremblin

    There is also the case of the variables being out of scope, like if you call a function and pass it a variable name in a string and that var doesn’t exist in the function, tovar should set the pointer to nullptr and I’ll probably leave it to crash…

  4. tremblin Avatar
    tremblin

    I think it makes sense to leave varname out, but tovar could be useful. You could have a json/text/ini file that scripts your game.

Leave a Reply to tremblin Cancel reply

Your email address will not be published. Required fields are marked *