-
Notifications
You must be signed in to change notification settings - Fork 0
Game Status & Containers
Everything about game status accesed with cr.stat table.
You can change or read values.
Some variables accesed with getters and setters.
You know level IDs from Variable Types. The level ID at cr.stat contains the level ID of the current level.
Warning
Wrong usage of cr.stat.set_levelid() may fuck up game!
Actualy, the level ID just used to generate cr.stat.card_set. But if one plugin needs level ID, your plugin will fuck this plugin.
Examples:
local current_id = cr.stat.get_levelid()
cr.stat.set_levelid(5) -- fuck the game!!This is the game seed. Its a string contains numbers. Why its a string? -> Because Lua doesnt support unsigned 64 bit integers. You need a helper function to use seed in randomizing.
Warning
Like level ID, you should use cr.stat.set_seed() carefully
Examples:
-- This function may help to get seed as integer
function get_usable_seed()
local hash = 0
local s = cr.stat.get_seed()
for i = 1, #s do
hash = (hash * 37 + string.byte(s, i)) % 9007199254740992
end
return hash
end
math.randomseed(get_usable_seed())
-- getting a random number
local randomnumber = math.random(1, 100)
cr.log("randomnumber: " .. tostring(randomnumber), cr.log_type.NORMAL)[!INFO] Container methods
To see full list of methods of containers go to Container Operations on sol2 documentation
Warning
Do not try to erase something with nil
This code block below will not work:
cr.stat.deck[1] = nil -- crash!!Use :erase method instead of that:
cr.stat.deck:erase(1)A table contains shared cards. Used to generate cr.stat.card_set content. When cr.create_card() is used, new cards will be added to this container.
A table contains shared cards. Contains duplicate cards. When a card in slot used, new card will came from this container.
Slots on the UI in cr.obj.card_slot type.
A table contains shared biomes. Biome registry of the game. Used once to generate cr.stat.levels. When cr.create_biome() is used new biomes will be added to this container.
A table contains shared levels. Ordered levels of the game. After ordering biomes by their difficulty, their levels will go to this container.
Current index of the level stored in cr.player.level. You can access current level with this value:
local current_level = cr.stat.levels[cr.player.level]
cr.log("Current level name: " .. current_level.name, cr.log_type.NORMAL)A table contains shared levels. When cr.create_buff() is used new buffs will go to this container.
Every turn game checks this container. If one of the buffs level is not 0, its event will be called.
A complex table contains the latest 9 logs. When you use cr.log() function new log will be put here.
Structure of the table:
cr.stat.logs
├── <index number>
│ ├── first // log type (cr.log_type)
│ └── second // log msg (string)
...Warning
Never try :add() logs At the C++ side log pairs not binded perfectly. You can edit existing pairs but can't use :add() method on it.
Example reads last log's name:
local logname = cr.stat.logs[1].second-
Getting Started
-
Metadata
-
Variable Types and Variables
-
Game Status
-
TUI