RynthSuite as of 2026-10-04 (internal c94715f): RynthOracle (based on Oracle of Dereth by Advis Eveldan) and RynthInventory, RynthAi patrol doorways and rooms, healing priority, strict monster priority, finish the wounded target, slayer weapons, arcs when clear, blasts like rings, learn unknown spells, looting fixes, release 2026.10.4.6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c33e24a610
commit
12ca25f911
426 changed files with 108239 additions and 7521 deletions
60
Tools/RynthLua.CompatTests/Scripts/storage.lua
Normal file
60
Tools/RynthLua.CompatTests/Scripts/storage.lua
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
-- storage: RynthLua's saved values (UB has no storage module; UB scripts write their own
|
||||
-- JSON through filesystem, which this also checks against).
|
||||
local storage = require("storage")
|
||||
local json = require("json")
|
||||
local fs = require("filesystem").GetData()
|
||||
|
||||
storage.Clear()
|
||||
eq(#storage.Keys(), 0, "starts empty")
|
||||
eq(storage.Get("missing"), nil, "missing is nil")
|
||||
eq(storage.Get("missing", 42), 42, "missing with a default")
|
||||
|
||||
storage.Set("count", 3)
|
||||
storage.Set("name", "Tester")
|
||||
storage.Set("flags", { a = true, list = { 1, 2, 3 } })
|
||||
storage.Set("skill", SkillId.WarMagic)
|
||||
storage.Set("typed", StringId.Name)
|
||||
eq(storage.Get("count"), 3, "number")
|
||||
eq(storage.Get("name"), "Tester", "string")
|
||||
eq(storage.Get("flags").list[3], 3, "table")
|
||||
eq(storage.Get("skill"), 34, "numeric enum stored as its number")
|
||||
eq(storage.Get("typed"), 1, "typed enum stored as its number")
|
||||
check(storage.Has("name"), "Has")
|
||||
local keys = storage.Keys()
|
||||
eq(#keys, 5, "Keys")
|
||||
eq(keys[1], "count", "Keys are sorted")
|
||||
|
||||
-- values are copies
|
||||
local t = storage.Get("flags")
|
||||
t.a = false
|
||||
eq(storage.Get("flags").a, true, "Get returns a copy")
|
||||
|
||||
check(storage.Remove("count"), "Remove says it was there")
|
||||
check(not storage.Has("count"), "removed")
|
||||
storage.Set("name", nil)
|
||||
check(not storage.Has("name"), "Set(nil) removes")
|
||||
|
||||
-- written to the script's data folder as JSON
|
||||
storage.Save()
|
||||
local text, err = fs.ReadText("storage.json")
|
||||
check(text ~= nil, "storage.json written: " .. tostring(err))
|
||||
if text then
|
||||
local onDisk = json.decode(text)
|
||||
eq(onDisk.skill, 34, "on disk")
|
||||
end
|
||||
|
||||
-- per character
|
||||
storage.Character.Set("seen", true)
|
||||
eq(storage.Character.Get("seen"), true, "storage.Character")
|
||||
check(not storage.Has("seen"), "character values are separate")
|
||||
|
||||
-- the UB way: a script's own JSON file through filesystem
|
||||
local ok, werr = fs.WriteText("settings.json", json.encode({ enabled = true, range = 30 }))
|
||||
check(ok, "WriteText: " .. tostring(werr))
|
||||
local saved = json.decode((fs.ReadText("settings.json")))
|
||||
eq(saved.range, 30, "read back")
|
||||
check(fs.FileExists("settings.json"), "FileExists")
|
||||
|
||||
storage.Clear()
|
||||
eq(#storage.Keys(), 0, "Clear")
|
||||
done()
|
||||
Loading…
Reference in a new issue