Getting Started

Kitsu Template for Project OutFox

Getting Started


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.

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.)

Using Konko Node

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.

Using Konko Mods

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.

Writing Libraries

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.

  1. If you need a certain library to function, include it! remember to use import for anything you’ll need.
  2. Try to keep your library local to avoid interfering with other libraries. Even the included standard library is local!
  3. If you write your own standard library, a good practice is to set an ActorFrame for the foreground. You should do this with FG = FG or Def.ActorFrame {}. This is the same FG that is returned in mods.lua.
  4. Another thing to consider if you write your own standard library is that you may need to write your own mod loader as well. This is why one is included. It may not make writing a mod loader clear, but it will give you an idea of what it may expect from your standard library.

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
Return to Home