Can JSON contain self-made Function some way?
Posted: Thu May 08, 2025 5:59 pm
I am trying to make an all purpose StoryEngine that would be scriptable in JSON-format.
What I am wondering is if there is a way to execute some Hollywood code, by adding it to JSON-format.
As in, lets take two different scenarios.
I might want to make a special mission where enemy ship needs to be destroyed, when that ship is destroyed, it should execute following code:
And then there could be another game where when winning it is supposed to unlock a card:
I can of course achieve this by having something like:
And then in the games code telling that when script says a HollywoodFunc and uses arg "GetReward" then it is supposed to call "GetReward()"-func.
But in ideal case I wouldn't need to tell the game anything about the JSON-script, but could simply add commands through JSON, without the game having any knowledge about them.
But is this possible? or do I just have to have it scripted in to the game code that HollywoodFunc "X" refers to FunctionX, and HollywoodFunc "Y" refers to HollywoodFuncY?
What I am wondering is if there is a way to execute some Hollywood code, by adding it to JSON-format.
As in, lets take two different scenarios.
I might want to make a special mission where enemy ship needs to be destroyed, when that ship is destroyed, it should execute following code:
Code: Select all
{
"onComplete": [
{"HollywoodCode": "Function() GetReward(100) EndFunction"},
]
}Code: Select all
{
"onWin": [
{"HollywoodCode": "Function() UnlockCard("Special1") EndFunction"},
]
}Code: Select all
{
"onComplete": [
{"HollywoodFunc": "GetReward", "100"},
]
}But in ideal case I wouldn't need to tell the game anything about the JSON-script, but could simply add commands through JSON, without the game having any knowledge about them.
But is this possible? or do I just have to have it scripted in to the game code that HollywoodFunc "X" refers to FunctionX, and HollywoodFunc "Y" refers to HollywoodFuncY?