Kitsu Template for Project OutFox
Kitsu template is special in the sense that you don’t have to use a built-in mod loader. You can use a different mod loader or even make your own. You don’t even have to use the standard library; you can make an entirely custom one and use that instead!
You can include libraries in mods.lua
by using the import
function.
local std = import 'stdlib' -- Kitsu Standard Library
local Node = import 'konko-node' -- Konko Node
local Mods = import 'konko-mods' -- Konko Mods
There are two other libraries included that you can use if you wish, mirin-syntax
and ease-names
.
mirin-syntax
will stylize the Konko Mods syntax to be like Mirin, and allow you to call mirin.ease
instead of Mods:Mirin
.ease-names
will allow you to use different names for ease functions like inOutExpo
instead of Tweens.inoutexpo
.You can include them like this:
local mirin = import 'mirin-syntax'
import 'ease-names'
(If you import mirin-syntax
, you do not have to import konko-mods
, unless you want to still be able to use the Mods
object directly.)
Konko Node allows a new, streamlined syntax that reduces the need for actor tables.To create a node, simply call the Node.new
function.
local MyNode = Node.new('Sprite') -- You can pass in a string naming the type of Actor, or an entire Actor itself.
Once you’ve created your node, you can set its init
, ready
, update
, and input
functions.
MyNode:SetInit(function(self)
self:Center()
end)
MyNode:SetReady(function(self)
self:SetWidth(64)
self:SetHeight(64)
end)
MyNode:SetUpdate(function(self, dt)
self:addrotationz(360 * dt) -- dt stands for "delta time" - the amount of seconds since last frame.
end)
MyNode:SetInput(function(self, event)
if event.type == "InputEventType_FirstPress" then
SCREENMAN:SystemMessage(event.button)
end
end)
-- You can also set custom commands and messages.
MyNode:SetCommand('Custom1', function(self) end)
MyNode:SetMessage('Custom2', function(self) end)
-- You can even set attributes!
MyNode:SetAttribute('Texture', 'path/to/texture.png')
Finally, you can add your node to the node tree. You can give it a name, and index, both, or neither. Giving it a name will allow you to use this node in its Actor form after its construction.
MyNode:AddToNodeTree('MyNode', 1)
More documentation avaiable in konko-nodes.lua
.
Mods are straightforward if you’ve used other templates. You can insert a mod via the Mods
object.
Mods:Insert(0, 2, Tweens.outelastic, 100)
This will ease invert
at its current percent to 100
starting at beat 0
for two beats.
You can insert mods using three different functions. These examples all do the same thing, but each with their own syntax and advantages.
-- In-house method - Recommended for inserting tables of percent-mod pairs
Mods:Insert(0, 4, Tweens.outelastic, {
{100, 'invert'},
{100, 'tipsy'}
})
-- Mirin Method - Recommended for fast mod prototyping
Mods:Mirin {0, 4, Tweens.outelastic, 100, 'invert', 100, 'tipsy'}
-- Exschwasion Method - Recommended for easy troubleshooting
Mods:Exsch(0, 4, 0, 100, 'invert', 'len', Tweens.outelastic)
Mods:Exsch(0, 4, 0, 100, 'tipsy', 'len', Tweens.outelastic)
You can also set default mods using Mods:Default
.
Mods:Default({
{1.5, 'xmod'},
{100, 'stealthtype'},
{100, 'modtimersong'},
{100, 'tinyusesminicalc'}
})
More documentation available in konko-mods.lua
.
There’s really no limit to what you can write for a library. Since the only requirements you have are the requirements you give yourself, you can write any library you want. mirin-syntax
is a good starting example on how to write a library for the Kitsu template, but there are some important things to consider.
import
for anything you’ll need.FG = FG or Def.ActorFrame {}
. This is the same FG
that is returned in mods.lua
.Generally, a library is written as follows:
-- You can import libraries in your library, too! That's what we call a dependency.
local std = import 'stdlib'
-- We will fill this and return it in the end.
local MyLib = {}
setmetatable(MyLib, {})
-- We write our library definitions here.
local MyVar = std.SCX
local function MyFunc(n)
return MyVar + n
end
-- List only what you want to export. internal variables should stay hidden to prevent other things from messing with them.
MyLib = {
MyVar = var,
MyFunc = func
}
MyLib.__index = MyLib
-- It's a nice gesture to let the log know we've loaded in.
print('Loaded MyLib')
return MyLib
Full API references:
Outfox | NotITG |