mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Use world.players to initialize player in global tests
This commit is contained in:
parent
c298210844
commit
8b62f02523
1 changed files with 17 additions and 17 deletions
|
@ -42,6 +42,7 @@ local function testTimers()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function testTeleport()
|
local function testTeleport()
|
||||||
|
local player = world.players[1]
|
||||||
player:teleport('', util.vector3(100, 50, 500), util.transform.rotateZ(math.rad(90)))
|
player:teleport('', util.vector3(100, 50, 500), util.transform.rotateZ(math.rad(90)))
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
testing.expect(player.cell.isExterior, 'teleport to exterior failed')
|
testing.expect(player.cell.isExterior, 'teleport to exterior failed')
|
||||||
|
@ -221,8 +222,10 @@ local function testMemoryLimit()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function initPlayer()
|
local function initPlayer()
|
||||||
|
local player = world.players[1]
|
||||||
player:teleport('', util.vector3(4096, 4096, 1745), util.transform.identity)
|
player:teleport('', util.vector3(4096, 4096, 1745), util.transform.identity)
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
|
return player
|
||||||
end
|
end
|
||||||
|
|
||||||
local function testVFS()
|
local function testVFS()
|
||||||
|
@ -272,8 +275,7 @@ local function testVFS()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function testCommitCrime()
|
local function testCommitCrime()
|
||||||
initPlayer()
|
local player = initPlayer()
|
||||||
local player = world.players[1]
|
|
||||||
testing.expectEqual(player == nil, false, 'A viable player reference should exist to run `testCommitCrime`')
|
testing.expectEqual(player == nil, false, 'A viable player reference should exist to run `testCommitCrime`')
|
||||||
testing.expectEqual(I.Crimes == nil, false, 'Crimes interface should be available in global contexts')
|
testing.expectEqual(I.Crimes == nil, false, 'Crimes interface should be available in global contexts')
|
||||||
|
|
||||||
|
@ -295,51 +297,50 @@ local function testCommitCrime()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function testRecordModelProperty()
|
local function testRecordModelProperty()
|
||||||
initPlayer()
|
local player = initPlayer()
|
||||||
local player = world.players[1]
|
|
||||||
testing.expectEqual(types.NPC.record(player).model, 'meshes/basicplayer.dae')
|
testing.expectEqual(types.NPC.record(player).model, 'meshes/basicplayer.dae')
|
||||||
end
|
end
|
||||||
|
|
||||||
tests = {
|
tests = {
|
||||||
{'timers', testTimers},
|
{'timers', testTimers},
|
||||||
{'rotating player with controls.yawChange should change rotation', function()
|
{'rotating player with controls.yawChange should change rotation', function()
|
||||||
initPlayer()
|
local player = initPlayer()
|
||||||
testing.runLocalTest(player, 'playerYawRotation')
|
testing.runLocalTest(player, 'playerYawRotation')
|
||||||
end},
|
end},
|
||||||
{'rotating player with controls.pitchChange should change rotation', function()
|
{'rotating player with controls.pitchChange should change rotation', function()
|
||||||
initPlayer()
|
local player = initPlayer()
|
||||||
testing.runLocalTest(player, 'playerPitchRotation')
|
testing.runLocalTest(player, 'playerPitchRotation')
|
||||||
end},
|
end},
|
||||||
{'rotating player with controls.pitchChange and controls.yawChange should change rotation', function()
|
{'rotating player with controls.pitchChange and controls.yawChange should change rotation', function()
|
||||||
initPlayer()
|
local player = initPlayer()
|
||||||
testing.runLocalTest(player, 'playerPitchAndYawRotation')
|
testing.runLocalTest(player, 'playerPitchAndYawRotation')
|
||||||
end},
|
end},
|
||||||
{'rotating player should not lead to nan rotation', function()
|
{'rotating player should not lead to nan rotation', function()
|
||||||
initPlayer()
|
local player = initPlayer()
|
||||||
testing.runLocalTest(player, 'playerRotation')
|
testing.runLocalTest(player, 'playerRotation')
|
||||||
end},
|
end},
|
||||||
{'playerForwardRunning', function()
|
{'playerForwardRunning', function()
|
||||||
initPlayer()
|
local player = initPlayer()
|
||||||
testing.runLocalTest(player, 'playerForwardRunning')
|
testing.runLocalTest(player, 'playerForwardRunning')
|
||||||
end},
|
end},
|
||||||
{'playerDiagonalWalking', function()
|
{'playerDiagonalWalking', function()
|
||||||
initPlayer()
|
local player = initPlayer()
|
||||||
testing.runLocalTest(player, 'playerDiagonalWalking')
|
testing.runLocalTest(player, 'playerDiagonalWalking')
|
||||||
end},
|
end},
|
||||||
{'findPath', function()
|
{'findPath', function()
|
||||||
initPlayer()
|
local player = initPlayer()
|
||||||
testing.runLocalTest(player, 'findPath')
|
testing.runLocalTest(player, 'findPath')
|
||||||
end},
|
end},
|
||||||
{'findRandomPointAroundCircle', function()
|
{'findRandomPointAroundCircle', function()
|
||||||
initPlayer()
|
local player = initPlayer()
|
||||||
testing.runLocalTest(player, 'findRandomPointAroundCircle')
|
testing.runLocalTest(player, 'findRandomPointAroundCircle')
|
||||||
end},
|
end},
|
||||||
{'castNavigationRay', function()
|
{'castNavigationRay', function()
|
||||||
initPlayer()
|
local player = initPlayer()
|
||||||
testing.runLocalTest(player, 'castNavigationRay')
|
testing.runLocalTest(player, 'castNavigationRay')
|
||||||
end},
|
end},
|
||||||
{'findNearestNavMeshPosition', function()
|
{'findNearestNavMeshPosition', function()
|
||||||
initPlayer()
|
local player = initPlayer()
|
||||||
testing.runLocalTest(player, 'findNearestNavMeshPosition')
|
testing.runLocalTest(player, 'findNearestNavMeshPosition')
|
||||||
end},
|
end},
|
||||||
{'teleport', testTeleport},
|
{'teleport', testTeleport},
|
||||||
|
@ -351,11 +352,11 @@ tests = {
|
||||||
{'mwscript', testMWScript},
|
{'mwscript', testMWScript},
|
||||||
{'testMemoryLimit', testMemoryLimit},
|
{'testMemoryLimit', testMemoryLimit},
|
||||||
{'playerMemoryLimit', function()
|
{'playerMemoryLimit', function()
|
||||||
initPlayer()
|
local player = initPlayer()
|
||||||
testing.runLocalTest(player, 'playerMemoryLimit')
|
testing.runLocalTest(player, 'playerMemoryLimit')
|
||||||
end},
|
end},
|
||||||
{'player with equipped weapon on attack should damage health of other actors', function()
|
{'player with equipped weapon on attack should damage health of other actors', function()
|
||||||
initPlayer()
|
local player = initPlayer()
|
||||||
world.createObject('basic_dagger1h', 1):moveInto(player)
|
world.createObject('basic_dagger1h', 1):moveInto(player)
|
||||||
testing.runLocalTest(player, 'playerWeaponAttack')
|
testing.runLocalTest(player, 'playerWeaponAttack')
|
||||||
end},
|
end},
|
||||||
|
@ -367,7 +368,6 @@ tests = {
|
||||||
return {
|
return {
|
||||||
engineHandlers = {
|
engineHandlers = {
|
||||||
onUpdate = testing.testRunner(tests),
|
onUpdate = testing.testRunner(tests),
|
||||||
onPlayerAdded = function(p) player = p end,
|
|
||||||
},
|
},
|
||||||
eventHandlers = testing.eventHandlers,
|
eventHandlers = testing.eventHandlers,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue