[EDIT : correction of go.propery
/go.set
confusion]
Thank you for your answer.
I had understood the go.property
call parameters. The go.set
above is to show what i wanted to do.
Sorry it was not clear.
I should have written « i’m stuck because i cannot use expressions in go.property
» (would be very complicated for defold team to allow this, i guess). But if every resources must be hardcoded, that add a step of generation in the flow (could be added in a Makefile, before bob
call).
I think i will just generate all the go.property
with content of /data/resources
.
After the generation, It will look like this:
if my_new_tilesource == "foo" then
go.property("new_tilesource", resource.tile_source("/data/resources/foo.tilesource") )
else if my_new_tilesource == "bar" then
go.property("new_tilesource", resource.tile_source("/data/resources/bar.tilesource") )
else if …
end
and then after all of this, i just use the variable self.tile_source
with the go.set
.
Only possibility i see.
I’ve tried also:
local switch_prop = {["foo"]= go.property("new_tilesource", resource.tile_source("/data/resources/foo.tilesource"))}
switch_prop["test"]()
But i get severe errors at generation:
ERROR:GAMEOBJECT: Error running script: scripts/game.script:106: unexpected symbol near '}'
WARNING:RESOURCE: Unable to create resource: /scripts/game.scriptc: FORMAT_ERROR
WARNING:RESOURCE: Unable to create resource: /_generated_33d003ce.goc: FORMAT_ERROR
ERROR:GAMEOBJECT: Could not instantiate game object from prototype /_generated_33d003ce.goc.
(the first error is while evaluating the table generation)
So probably not possible. Only a bunch of if - elseif
will work, i guess