Writing a Plugin
Let's get started with writing our first plugin. The gimmick method we currently have in Ichigo is nice, but we can only change one gimmick per line. Let's write a plugin that will allow us to define multiple gimmicks with one ease, and multiple gimmicks with one set.
Create a new file called multimod.lua in the /src/plugins folder. We can create two functions to accomplish the goals of this plugin. We can name them anything that isn't taken already. Let's go with ease and set. They should take in a table, just like gimmick does.
function ease(t)
end
function set(t)
endLet's work with ease first. We want to make this as little confusing as possible, so let's get an idea of how to use this function.
ease {0, 2, Tweens.linear, 0, 100, "flip", 0, -100, "invert"}We have three arguments that are constant, the first three, and we have a boundless number of arguments that are variable. However, it follows a pattern. Do you notice it? Each group of three contains the following:
A start value
An end value
A gimmick name
After some calculation, we can boil our table of arguments down to the following:
-- [1]: start beat
-- [2]: length (or end)
-- [3]: the ease
-- [4 + 3*n]: the source mod value
-- [5 + 3*n]: the destination mod value
-- [6 + 3*n]: the mod nameIf you don't understand, it's okay. The point is that what we want to accomplish is possible. Let's fill in our ease function.
function ease(t)
for i = 4, #t, 3 do
gimmick {t[1], t[2], t[3], t[i], t[i + 1], t[i + 2], plr = t.plr}
end
return ease
endNow with set. This one is easier.
-- [1]: start beat
-- [2 + 2*n]: the mod value
-- [3 + 2*n]: the mod nameLet's go ahead and fill in our set function with this in mind.
function set(t)
for i = 2, #t, 2 do
gimmick {t[1], t[i], t[i + 1], plr = t.plr}
end
return set
endGreat! We now have a plugin that allows us to set or ease multiple mods at once. Here's the entire code we've written so far:
-- multimod.lua
-- written by Sudospective
function ease(t)
for i = 4, #t, 3 do
gimmick {t[1], t[2], t[3], t[i], t[i + 1], t[i + 2], plr = t.plr}
end
return ease
end
function set(t)
for i = 2, #t, 2 do
gimmick {t[1], t[i], t[i + 1], plr = t.plr}
end
return set
endPlugins can be a great way to provide easy, lightweight tools that can speed up the gimmick creation process.
Last updated
Was this helpful?