[quote=“Chezzo, post:46, topic:13488”]Hey Zhilkin, could this work for the mod I wanted to do where:
The apocalypse continues to evolve as you explore with fighting pits, cannibal towns, and apocalypse churches.
Basically, I wouldn’t want them to generate in the first overmap, but I would want them to start generating when you reveal more overmaps. Possibly also only during later seasons.[/quote]
There are four LUA callbacks, two of which are calendar-related:
[ul][li]on_new_player_created
- called when starting the game (used in StatsThroughSkills mod)[/li]
[li]on_skill_increased
- called when player skill is increased (used in StatsThroughSkills mod)[/li]
[li]on_day_passed
- called once a day (at midnight)[/li]
[li]on_minute_passed
- called once a minute[/li][/ul]
It is possible to store player string variables which can be saved/loaded with the game.
player = {
parent = "Character",
functions = {
{ name = "get_value", rval = "string", args = { "string" } },
{ name = "set_value", rval = nil, args = { "string", "string" } }
}
}
Calendar class fields are exported to LUA:
calendar = {
new = {
{ "calendar" },
{ "int" },
{ "int", "int", "int", "season_type", "int" },
},
by_value_and_reference = true,
attributes = {
},
functions = {
{ name = "day_of_week", rval = "string", args = { } },
{ name = "day_of_year", rval = "int", args = { } },
{ name = "get_season", rval = "season_type", args = { } },
{ name = "get_turn", rval = "int", args = { } },
{ name = "increment", rval = nil, args = { } },
{ name = "minutes_past_midnight", rval = "int", args = { } },
{ name = "print_time", rval = "string", args = { "bool" } },
{ name = "print_time", rval = "string", args = { } },
{ name = "seconds_past_midnight", rval = "int", args = { } },
{ name = "is_night", rval = "bool", args = { } },
{ name = "seconds", rval = "int", args = { } },
{ name = "minutes", rval = "int", args = { } },
{ name = "hours", rval = "int", args = { } },
{ name = "days", rval = "int", args = { } },
{ name = "sunlight", rval = "float", args = { } },
{ name = "textify_period", rval = "string", args = { } },
{ name = "turn_of_year", rval = "int", args = { } },
{ name = "years", rval = "int", args = { } },
{ name = "sunset", rval = "calendar", args = { } },
{ name = "sunrise", rval = "calendar", args = { } },
}
}
All lua mapgen-related (like, map:ter_set
) and other functions are usable during the game, not only on mapgen stage.
So it should be possible to store initial calendar values, calculate time difference once a minute or once a day and make some changes to the map once enough time is passed.
Still there are many limitations in LUA (or at least I didn’t find the way to find a solution):
[ul][li]lua generated buldings aren’t rotated automatically;[/li]
[li]overmaps (displayed in the map) cannot be changed;[/li]
[li]it is not possible to calculate the number of tiles the player have traversed;[/li]
[li]bigger overmap coordinates are unknown.[/li][/ul]