mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-27 16:49:31 +00:00
Add anselme version check in game config, rename version to "game version"
This commit is contained in:
parent
d42c35facd
commit
0e755ea841
2 changed files with 10 additions and 6 deletions
12
anselme.lua
12
anselme.lua
|
|
@ -203,7 +203,8 @@ local vm_mt = {
|
|||
-- will load in path, in order:
|
||||
-- * config.ans, which will be executed in the "config" namespace and may contains various optional configuration options:
|
||||
-- * language: string, built-in language file to load
|
||||
-- * version: any, version information of the game. Can be used to perform eventual migration of save with an old version in the main file.
|
||||
-- * anselme version: number, version of the anselme language this game was made for
|
||||
-- * game version: any, version information of the game. Can be used to perform eventual migration of save with an old version in the main file.
|
||||
-- Always included in saved variables.
|
||||
-- * main file: string, name (without .ans extension) of a file that will be loaded into the root namespace and ran when starting the game
|
||||
-- * main file, if defined in config.ans
|
||||
|
|
@ -222,12 +223,17 @@ local vm_mt = {
|
|||
-- get config
|
||||
self.game = {
|
||||
language = self:eval("config.language"),
|
||||
version = self:eval("config.version"),
|
||||
anselme_version = self:eval("config.anselme version"),
|
||||
game_version = self:eval("config.game version"),
|
||||
main_file = self:eval("config.main file"),
|
||||
main_block = nil
|
||||
}
|
||||
-- check language version
|
||||
if self.game.anselme_version and self.game.anselme_version ~= anselme.versions.language then
|
||||
return nil, ("trying to load game made for Anselme language %s, but currently using version %s"):format(self.game.anselme_version, anselme.versions.language)
|
||||
end
|
||||
-- force merging version into state
|
||||
local interpreter, err = self:run("config.version")
|
||||
local interpreter, err = self:run("config.game version")
|
||||
if not interpreter then return interpreter, err end
|
||||
interpreter:step()
|
||||
-- load language
|
||||
|
|
|
|||
|
|
@ -57,5 +57,3 @@ Disadvantages:
|
|||
* could do something like `$ ()(l::list(?), i::number)::?`, but then can't return nil on not found...
|
||||
|
||||
TODO: ensure that most stuff in the state stays consistent after an error was thrown
|
||||
|
||||
TODO: way to migrate save files
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue