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
14
anselme.lua
14
anselme.lua
|
|
@ -203,8 +203,9 @@ local vm_mt = {
|
||||||
-- will load in path, in order:
|
-- will load in path, in order:
|
||||||
-- * config.ans, which will be executed in the "config" namespace and may contains various optional configuration options:
|
-- * 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
|
-- * 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
|
||||||
-- Always included in saved variables.
|
-- * 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: 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
|
-- * main file, if defined in config.ans
|
||||||
-- * every other file in the path and subdirectories, using their path as namespace (i.e., contents of path/world1/john.ans will be defined in a function world1.john)
|
-- * every other file in the path and subdirectories, using their path as namespace (i.e., contents of path/world1/john.ans will be defined in a function world1.john)
|
||||||
|
|
@ -222,12 +223,17 @@ local vm_mt = {
|
||||||
-- get config
|
-- get config
|
||||||
self.game = {
|
self.game = {
|
||||||
language = self:eval("config.language"),
|
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_file = self:eval("config.main file"),
|
||||||
main_block = nil
|
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
|
-- 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
|
if not interpreter then return interpreter, err end
|
||||||
interpreter:step()
|
interpreter:step()
|
||||||
-- load language
|
-- load language
|
||||||
|
|
|
||||||
|
|
@ -57,5 +57,3 @@ Disadvantages:
|
||||||
* could do something like `$ ()(l::list(?), i::number)::?`, but then can't return nil on not found...
|
* 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: 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