1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-07-16 12:54:49 +00:00

More work on the mod v1.1 compatibility layer

This commit is contained in:
fgenesis 2021-01-12 23:51:18 +01:00
parent 5897d369b0
commit 1e9c415624
11 changed files with 953 additions and 33 deletions

View file

@ -3,20 +3,36 @@
-- Most that had no function are dummied out, some existed but threw errors,
-- and others were registered under different names.
local NULLREF = 0
-- these did something but are now gone
local WARN_FUNCTIONS =
{
getAngleBetween = true,
getAngleBetweenEntities = true,
getNearestNode = true,
getNodeFromEntity = true,
healEntity = true,
killEntity = true,
entity_warpToPathStart = true,
sendEntityMessage = true,
entity_fireShot = true,
entity_resetTimer = true,
moveEntity = true,
playVfx = true,
registerSporeChildData = true,
setMiniMapHint = true,
setupConversationEntity = true,
}
-- These returned something important, so here we just return a failure/dummy value
local WARN_FUNCTIONS_VAL =
{
getAngleBetween = 0.0,
getAngleBetweenEntities = 0.0,
getEntityInGroup = NULLREF,
getNearestNode = NULLREF,
getNodeFromEntity = NULLREF,
isInDialog = false,
}
-- These had no function and we can just ignore the call
local DUMMY_FUNCTIONS =
{
entity_setCollideWithAvatar = true,
@ -48,11 +64,31 @@ local DUMMY_FUNCTIONS =
stopCursorGlow = true,
toggleTransitFishRide = true,
entity_stopTimer = true,
setEntityScript = true,
streamSfx = true,
}
-- Deprecated stuff from v1.1's scripts/entities/entityinclude.lua
local function entity_watchSwimToEntitySide(ent1, ent2)
local xoff=entity_getCollideRadius(ent2)+64
if entity_x(ent1) < entity_x(ent2) then
xoff = -xoff
end
entity_swimToPosition(ent1, entity_x(ent2)+xoff, entity_y(ent2))
entity_watchForPath(ent1)
entity_idle(ent1)
entity_clearVel(ent1)
entity_flipToEntity(ent1, ent2)
entity_flipToEntity(ent2, ent1)
end
-- Duplicated and renamed functions
local REPLACED_FUNCTIONS =
{
-- alternate names
-- alternate names, old name on the left, new name on the right
-- (Might want tp use the name on the right, they existed in 1.1.1 already)
entity_getPositionX = entity_x,
entity_getPositionY = entity_y,
entity_applyRandomForce = entity_addRandomVel,
@ -60,22 +96,50 @@ local REPLACED_FUNCTIONS =
getEntityByName = getEntity,
entity_flipTo = entity_fhTo,
bone_getidx = bone_getIndex,
getAvatar = getNaija,
getRandVector = randVector,
inp = toggleInput,
isPlayingVoice = isStreamingVoice,
playVoice = voice,
-- These are unfortunately broken and can't be fixed.
-- They are interface function names and the first loaded script would grab them,
-- thinking an interface function with that name was provided by whichever script was just loaded.
-- So we ignore these and hope nobody misses them.
--msg = screenMessage,
--castSong = singSong,
-- entityinclude functions
entity_watchSwimToEntitySide = entity_watchSwimToEntitySide,
}
----------------------------------------------------
---- Functors to generate replacement function -----
----------------------------------------------------
local function mkwarn(name, param)
local err = "Dummy function: " .. name .. "() - no longer present in the current API, fix the script!"
return function() errorLog(err) end
local warnLog = (isDeveloperKeys() and errorLog) or debugLog
-- generate function that warns when called and returns nil
local function warndummy(name)
warnLog("Dummy function: " .. name .. "() - no longer present in the current API, fix the script!")
end
local function mkwarn(name)
return function() warndummy(name) end
end
local function dummy(name, param)
-- generate function that warns when called and returns a non-nil fixed value
local function mkwarnret(name, param)
return function() warndummy(name) return param end
end
-- generate silent dummy that does nothing when called and returns nil
local function dummy() end
local function mkdummy(name, param)
return dummy
end
-- register existing function under a different name
local function mkalias(name, param)
return assert(param, name)
end
@ -95,5 +159,6 @@ end
---- Do it! ----
----------------
makestubs(WARN_FUNCTIONS, mkwarn)
makestubs(WARN_FUNCTIONS_VAL, mkwarnret)
makestubs(DUMMY_FUNCTIONS, mkdummy)
makestubs(REPLACED_FUNCTIONS, mkalias)