Some of the changes were sparked by thoughts about how I’m going to create save states. I came up with the idea of something like this:
"entities": [
{ "chest", [ x, y, opened... ] },
{ "person", [ x, y, ... ] },...
]
You would read the name and use toptr something like:
= name (json_get_string json "entities>[0]")
= name (string_format "create_%" name)
var ptr
= ptr (toptr name)
; create a vector from the array after "chest" /etc, which can be fully automated
var entity
call_result entity *ptr vec
vector_add entities entity
Now the load code doesn’t need to know about the types. Typically you see:
if (type == chest) {
}
if (type == person) {
}
; a million others
By the way, if you use this trick, it won’t work if you obfuscate your code. I can allow it though through a command line switch to list your create_ functions/etc.

Leave a Reply