Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for extended tip image #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions scripts/alter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,60 @@ function SpaceScript(loc, script)
return d
end

local tipImageCallbackMapping = {
Shield = function(loc)
if memedit then
-- Create a shield without animation
Board:SetShield(loc, true, true)
else
Board:AddShield(loc)
end
end,
Sand = function(loc)
Board:SetTerrain(loc, TERRAIN_SAND)
end,
Ice = function(loc)
Board:SetTerrain(loc, TERRAIN_ICE)
end,
Frozen = function(loc)
if memedit then
-- Create frozen without animation
Board:SetFrozen(loc, true, true)
else
Board:SetFrozen(loc, true)
end
end,
Snow = function(loc)
Board:SetCustomTile(loc, "snow.png")
end,
}

local function applyExtendedTipImage(self)
for feature, loc in pairs(self.TipImage) do
-- Remove trailing digits to allow for multiple features of the same type
local feature = feature:match("(.-)%d*$")
local callback = tipImageCallbackMapping[feature]

if callback == nil and self.TipImageCallbacks ~= nil then
callback = self.TipImageCallbacks[feature]
end

if callback ~= nil then
callback(loc)
end
end
end

local function modApiExtGetSkillEffect(self, p1, p2, ...)
-- Dereference to weapon object
if type(self) == "string" then
self = _G[self]
end

if Board:IsTipImage() then
applyExtendedTipImage(self)
end

p1 = p1 or Point(-1,-1)
p2 = p2 or Point(-1,-1)

Expand Down