mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 12:58:00 +03:00
Lua: Standardize record stores
This commit is contained in:
parent
38eb741bfd
commit
6d529835ae
12 changed files with 329 additions and 182 deletions
|
@ -2,6 +2,7 @@ local testing = require('testing_util')
|
|||
local core = require('openmw.core')
|
||||
local async = require('openmw.async')
|
||||
local util = require('openmw.util')
|
||||
local types = require('openmw.types')
|
||||
local world = require('openmw.world')
|
||||
|
||||
local function testTimers()
|
||||
|
@ -87,6 +88,45 @@ local function testMWScript()
|
|||
testing.expectEqual(variableStoreCount, indexCheck)
|
||||
end
|
||||
|
||||
local function testRecordStore(store,storeName,skipPairs)
|
||||
testing.expect(store.records)
|
||||
local firstRecord = store.records[1]
|
||||
if not firstRecord then return end
|
||||
testing.expectEqual(firstRecord.id,store.records[firstRecord.id].id)
|
||||
local status, _ = pcall(function()
|
||||
for index, value in ipairs(store.records) do
|
||||
if value.id == firstRecord.id then
|
||||
testing.expectEqual(index,1,storeName)
|
||||
break
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
testing.expectEqual(status,true,storeName)
|
||||
|
||||
end
|
||||
|
||||
local function testRecordStores()
|
||||
for key, type in pairs(types) do
|
||||
if type.records then
|
||||
testRecordStore(type,key)
|
||||
end
|
||||
end
|
||||
testRecordStore(core.magic.enchantments,"enchantments")
|
||||
testRecordStore(core.magic.effects,"effects",true)
|
||||
testRecordStore(core.magic.spells,"spells")
|
||||
|
||||
testRecordStore(core.stats.Attribute,"Attribute")
|
||||
testRecordStore(core.stats.Skill,"Skill")
|
||||
|
||||
testRecordStore(core.sound,"sound")
|
||||
testRecordStore(core.factions,"factions")
|
||||
|
||||
testRecordStore(types.NPC.classes,"classes")
|
||||
testRecordStore(types.NPC.races,"races")
|
||||
testRecordStore(types.Player.birthSigns,"birthSigns")
|
||||
end
|
||||
|
||||
local function initPlayer()
|
||||
player:teleport('', util.vector3(4096, 4096, 867.237), util.transform.identity)
|
||||
coroutine.yield()
|
||||
|
@ -124,6 +164,7 @@ tests = {
|
|||
end},
|
||||
{'teleport', testTeleport},
|
||||
{'getGMST', testGetGMST},
|
||||
{'recordStores', testRecordStores},
|
||||
{'mwscript', testMWScript},
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue