Skip to content

Commit 7ad4d1f

Browse files
committed
Fix documentation, several various bugs
1 parent 005fb10 commit 7ad4d1f

9 files changed

Lines changed: 238 additions & 150 deletions

File tree

README.md

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ Kitsu template is special in the sense that you don't have to use a built-in mod
1010

1111
You can include libraries in `mods.lua` by using the `import` function.
1212
```lua
13-
local std = import 'stdlib' -- Kitsu Standard Library
14-
local Node = import 'konko-node' -- Konko Node
15-
local Mods = import 'konko-mods' -- Konko Mods
13+
import 'stdlib' -- Kitsu Standard Library
14+
import 'konko-node' -- Konko Node
15+
import 'konko-mods' -- Konko Mods
16+
local TweensEXT = import 'extended-tweens' -- Extended Tweens Library
1617
```
1718

1819
There are more libraries you can find [here](https://github.com/Tiny-Foxes/kitsu-template-libraries/).
1920

2021
## Using Konko Node
21-
Konko Node allows a new, streamlined syntax that reduces the need for actor tables.To create a node, simply call the `Node.new` function.
22+
Konko Node allows a new, streamlined syntax that reduces the need for actor tables. To create a node, simply call the `Node.new` function.
2223
```lua
2324
local MyNode = Node.new('Sprite') -- You can pass in a string naming the type of Actor, or an entire Actor itself.
2425
```
@@ -35,7 +36,7 @@ MyNode:SetUpdate(function(self, dt)
3536
self:addrotationz(360 * dt) -- dt stands for "delta time" - the amount of seconds since last frame.
3637
end)
3738
MyNode:SetInput(function(self, event)
38-
if event.type == "InputEventType_FirstPress" then
39+
if event.type:find('Press') then
3940
SCREENMAN:SystemMessage(event.button)
4041
end
4142
end)
@@ -48,7 +49,7 @@ MyNode:SetAttribute('Texture', 'path/to/texture.png')
4849

4950
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.
5051
```lua
51-
MyNode:AddToTree('MyNode', 1)
52+
MyNode:AddToTree(1, 'MyNode')
5253
```
5354
More documentation avaiable in `konko-nodes.lua`.
5455

@@ -62,16 +63,17 @@ This will ease `invert` at its current percent to `100` starting at beat `0` for
6263

6364
You can insert mods using three different functions. These examples all do the same thing, but each with their own syntax and advantages.
6465
```lua
65-
-- In-house method - Recommended for inserting tables of percent-mod pairs
66+
-- In-house method
6667
Mods:Insert(0, 4, Tweens.outelastic, {
6768
{100, 'invert'},
68-
{100, 'tipsy'}
69+
-- You can also specify a starting percent.
70+
{100, 'tipsy', -100}
6971
})
7072

71-
-- Mirin Method - Recommended for fast mod prototyping
73+
-- Mirin Method
7274
Mods:Mirin {0, 4, Tweens.outelastic, 100, 'invert', 100, 'tipsy'}
7375

74-
-- Exschwasion Method - Recommended for easy troubleshooting
76+
-- Exschwasion Method
7577
Mods:Exsch(0, 4, 0, 100, 'invert', 'len', Tweens.outelastic)
7678
Mods:Exsch(0, 4, 0, 100, 'tipsy', 'len', Tweens.outelastic)
7779
```
@@ -94,30 +96,41 @@ There's really no limit to what you can write for a library. Since the only requ
9496

9597
1. If you need a certain library to function, include it! remember to use `import` for anything you'll need.
9698
1. Try to keep your library local to avoid interfering with other libraries. Even the included standard library is local!
97-
2. If you write a library and you need to add an actor, you should do this with `FG[#FG + 1] = Def.ActorFrame {}`. This is the same `FG` that is created in `env.lua` and added to the ActorFrame in `init.lua`. This `FG` ActorFrame has an update loop already provided that will call `UpdateCommand` every frame.
98-
3. 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.
99-
4. You're more than welcome to submit your library to the [Template Library Repository](https://github.com/Tiny-Foxes/kitsu-template-libraries/)! Once approved, it will be listed with others in an easy-to-find location.
99+
1. If you write a library and you need to add an actor, you should do this with `FG[#FG + 1] = Def.ActorFrame {}`. This is the same `FG` that is created in `env.lua` and added to the ActorFrame in `init.lua`. This `FG` ActorFrame has an update loop already provided that will call `UpdateCommand` every frame.
100+
1. 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.
101+
1. You're more than welcome to submit your library to the [Template Library Repository](https://github.com/Tiny-Foxes/kitsu-template-libraries/)! Once approved, it will be listed with others in an easy-to-find location.
100102

101103
Generally, a library is written as follows:
102104
```lua
105+
-- mylib.lua --
106+
103107
-- You can import libraries in your library, too! That's what we call a dependency.
104-
local std = import 'stdlib'
108+
depend ('mylib', std, 'stdlib')
109+
-- If the library does not have a global namespace, you can simply import it directly.
110+
local OtherLib = import 'otherlib'
105111

106112
-- We will fill this and return it in the end.
107113
local MyLib = {}
108114
setmetatable(MyLib, {})
109115

110116
-- We write our library definitions here.
111117
local MyVar = std.SCX
118+
local function GetVar()
119+
return MyVar
120+
end
112121
local function MyFunc(n)
113122
return MyVar + n
114123
end
124+
local function AddVars()
125+
return OtherLib.GetVar() + MyVar
126+
end
115127

116128
-- List only what you want to export. Internal variables should stay hidden to prevent other things from messing with them.
117129
MyLib = {
118130
VERSION = '1.0',
119-
var = MyVar,
120-
func = MyFunc
131+
var = GetVar,
132+
func = MyFunc,
133+
otherfunc = AddVars
121134
}
122135
MyLib.__index = MyLib
123136

@@ -128,9 +141,9 @@ return MyLib
128141

129142
You should name be able to import your library into `mods.lua` or other libraries by using `import`.
130143
```lua
131-
local lib = import 'MyLib'
144+
local lib = import 'mylib'
132145

133-
print(lib.var) -- Will print the value of SCREEN_CENTER_X
146+
print(lib.var()) -- Will print the value of SCREEN_CENTER_X
134147
local newvar = lib.func(7)
135148
print(newvar) -- Will print the value of SCREEN_CENTER_X + 7
136149
```

docs/outfox/staging-notes.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
# Staging Notes
2+
3+
### August 29, 2022 7:07pm
4+
Jesus Christ the docs are so out of date.
5+
6+
I did my best to fix up what I could with the README, but it's gonna take a while before I get to the API reference documentation. There's just a lot on my plate and it'll take a while for me to get through all of it.
7+
8+
I almost accidentally deleted the entire docs, by the way. What the hell is my goddamn problem.
9+
210
---
311
### October 15, 2021 1:19am
412
I've finally gotten back into the swing of working on the template again. During the time I haven't been around this I've made [an entire theme](https://github.com/Tiny-Foxes/superuser-outfox "god it took forever to actually push myself to do this").

lib/konko-mods.lua

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ local AUTHOR = 'Sudospective'
3030
local POptions = {}
3131
local plrcount = 0
3232
for i, v in ipairs( GAMESTATE:GetEnabledPlayers() ) do
33-
POptions[i] = GAMESTATE:GetPlayerState(v):GetPlayerOptions('ModsLevel_Song')
33+
POptions[i] = GAMESTATE:GetPlayerState(v):GetPlayerOptions('ModsLevel_Current')
3434
end
3535

36+
local instant_tween = function(t) return 1 end
3637
local modlist = {}
3738
local mod_percents = {}
3839
local note_percents = {}
@@ -141,8 +142,8 @@ local function UpdateMods()
141142
if m.Player and not POptions[m.Player] then break end
142143
local BEAT = std.BEAT
143144
local pn = m.Player
144-
if (BEAT >= m.Start and BEAT < (m.Start + m.Length)) then
145-
if m.Type == 'Player' then
145+
if (BEAT >= m.Start and BEAT <= (m.Start + m.Length)) then
146+
if m.Type == 'Blend' then
146147
-- Ease blending is a work in progress. Try to make sure two eases don't use the same mod.
147148
v[3] = v[3] or mod_percents[pn][v[2]] or 0
148149
active[pn][v[2]] = active[pn][v[2]] or {}
@@ -162,7 +163,7 @@ local function UpdateMods()
162163
end
163164
end
164165
mod_percents[pn][v[2]] = perc
165-
elseif m.Type == 'bup' then
166+
elseif m.Type == 'Player' then
166167
v[3] = v[3] or mod_percents[pn][v[2]] or default_mods[pn][v[2]] or 0
167168
local ease = m.Ease((BEAT - m.Start) / m.Length)
168169
if m.Length == 0 then ease = m.Ease(1) end
@@ -189,48 +190,36 @@ local function UpdateMods()
189190
end
190191
note_percents[pn][notemod] = perc
191192
end
192-
elseif BEAT >= (m.Start + m.Length) then
193+
elseif BEAT > (m.Start + m.Length) then
193194
if m.Type == 'Player' then
194195
v[3] = v[3] or mod_percents[pn][v[2]] or 0
195196
mod_percents[pn][v[2]] = m.Ease(1) * (v[1] - v[3]) + v[3]
196197
if v[4] and active[pn][v[2]] then
197-
active[pn][v[2]][v[4]] = nil
198+
--active[pn][v[2]][v[4]] = nil
198199
end
199200
elseif m.Type == 'Note' then
200201
v[5] = v[5] or note_percents[pn][notemod] or 0
201202
local notemod = v[4]..'|'..v[1]..'|'..v[2]
202203
note_percents[pn][notemod] = m.Ease(1) * (v[3] - v[5]) + v[5]
203204
if v[6] and active[pn][notemod] then
204-
active[pn][notemod][v[6]] = nil
205+
--active[pn][notemod][v[6]] = nil
205206
end
206207
end
207208
if j == #m.Modifiers then
208-
m.Modifiers = {}
209+
--m.Modifiers = {}
209210
end
210211
end
211212
end
212213
end
213214
end
214215

215-
FG[#FG + 1] = Def.Actor {
216-
ReadyCommand = function(self)
217-
for pn = 1, plrcount do
218-
POptions[pn]:FromString('*-1 clearall')
219-
end
220-
end,
221-
UpdateCommand = function(self)
222-
UpdateMods()
223-
ApplyMods()
224-
end
225-
}
226-
227216
local function RegisterField(notefield, pn)
228217
POptions[pn] = notefield:GetPlayerOptions('ModsLevel_Current')
229218
end
230219

231220
-- Load a mod file.
232221
local function FromFile(self, scriptpath)
233-
--printerr('Mods:LoadFromFile')
222+
--printerr('Mods:FromFile')
234223
run('lua/'..scriptpath)
235224
return self
236225
end
@@ -242,7 +231,7 @@ local function Default(self, modtable)
242231
table.insert(default_mods[pn], modtable[i])
243232
end
244233
end
245-
local res = self:Insert(std.START, 0, function(x) return 1 end, modtable)
234+
local res = self:Insert(std.START, 0, instant_tween, modtable)
246235
return res
247236
end
248237
-- Define a new mod.
@@ -397,6 +386,20 @@ local function Mirin(self, t, offset, pn)
397386
return res
398387
end
399388

389+
FG[#FG + 1] = Def.Actor {
390+
ReadyCommand = function(self)
391+
for pn = 1, plrcount do
392+
if POptions[pn] then POptions[pn]:FromString('*-1 clearall') end
393+
end
394+
-- Before we include the Note function, make sure we can actually call the required command.
395+
if std.PL[1].Player.AddNoteMod then Mods.Note = Note end
396+
end,
397+
UpdateCommand = function(self)
398+
UpdateMods()
399+
ApplyMods()
400+
end
401+
}
402+
400403
Mods = {
401404
VERSION = VERSION,
402405
AUTHOR = AUTHOR,
@@ -405,7 +408,6 @@ Mods = {
405408
FromFile = FromFile,
406409
Define = Define,
407410
Insert = Insert,
408-
--Note = Note,
409411
Mirin = Mirin,
410412
Exsch = Exsch,
411413
Default = Default,

0 commit comments

Comments
 (0)