jakubg1 / OpenSMCE

Game engine which allows creating a broad range of marble popper games.
MIT License
14 stars 11 forks source link

Scripting in games #36

Closed jakubg1 closed 2 years ago

jakubg1 commented 3 years ago

Any game could have a set of Lua scripts that would be assigned per game instead of per engine. This could enable extra flexibility for value configuration.

Example: Take this from <game>/config.json:

"sphereBehaviour":{
   "collisionSpeed":-200
}

Instead, this could be an equivalent function in, let's say, <game>/scripts/sphereBehaviour.lua:

function collisionSpeed(comboLv, chainLv)
    return comboLv * -200
end

UI could be scripted in a similar way. However, this would need to have the game event system reevaluated and most of UI system functions should be provided in order to make game UI script files as simple as possible.

This would also allow to configure some tough formulas that are hard to be represented in JSON, such as functions whether a given match should spawn a coin or a powerup.

This feature will be implemented late, probably during the process of writing an engine documentation or even later.

jakubg1 commented 3 years ago

Stub implemented in https://github.com/jakubg1/OpenSMCE/commit/a21e5ad06e6606a9d5718b61a9900b7e99641c02

jakubg1 commented 3 years ago

Note that UI script support, which was already implemented in the engine, does a lot in terms of custom scripting.

jakubg1 commented 2 years ago

More robust variable definitions will come at some point, with the addition of Expressions. Game scripting as it is right now will soon be deprecated and removed (excluding UI script).

Closing as partially implemented.