Skip to content

Commit

Permalink
Mirin Template 5.0.0
Browse files Browse the repository at this point in the history
Mirin Template Version 5.0.0

New Features:

* Everything is in real lua files.
  * No need to download specialized plugins to get syntax highlighting.

* Use `require` to load more .lua files.

* There are `outIn` eases now.

* Clearer function names:
  * `func` is now three functions: `func`, `perframe`, and `func_ease`

* New `blendease` function!
  * It's kind of like `flip`, but takes two eases and combines them
    smoothly! (the precise definition is `blendease(a, b)(t) = smoothstep(t, a(t), b(t))`)

* Ease params are coded better internally, but it means you have to call
  them with a `:` now.
  (`outBack:param(1.1)` instead of `outBack.param(1.1)`)

* Testing!
  * Versions in the future should be much less likely to break stuff,
    because I have code to test the mirin template using `busted`.

Bug Fixes:

* No more `ScreenReadyCommand`
  * Files will work in Marathon Mode, and with `ctrl+r`
* Probably more. I wasn't keeping track.
  • Loading branch information
xerool committed Feb 14, 2022
2 parents db47620 + eb9ae51 commit d1e9a8e
Show file tree
Hide file tree
Showing 37 changed files with 3,608 additions and 1,932 deletions.
5 changes: 5 additions & 0 deletions .luacov
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
modules = {
["template.template"] = "./template/template.lua",
["template.ease"] = "./template/ease.lua",
["template.std"] = "./template/std.lua",
}
9 changes: 9 additions & 0 deletions .luarc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
"Lua.diagnostics.disable": [
"ambiguity-1"
],
"Lua.diagnostics.globals": [
"xero"
]
}
3 changes: 1 addition & 2 deletions Song.sm
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
#TIMESIGNATURES:0.000=4=4;
#BGCHANGES:;

//The majority of simfile scripts and visual effects are stored here.
#FGCHANGES:0.000=template/main.xml=1.000=0=0=1=====,
#FGCHANGES:-10000.000=template/main.xml=1.000=0=0=1=====,
;

#KEYSOUNDS:;
Expand Down
17 changes: 17 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh
VER=$1
if [[ -z "$VER" ]]
then
VER="unknown"
fi
FILENAME=mirin-template-"$VER"

mkdir "$FILENAME"
cp -r Song.ogg Song.sm lua template "$FILENAME"
cd "$FILENAME"

sed 's/$VERSION/'"$VER"'/' template/main.xml -i

cd ..
zip "$FILENAME".zip "$FILENAME" -r
rm "$FILENAME" -rf
7 changes: 7 additions & 0 deletions check_coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if busted --coverage --suppress-pending;
then
luacov
awk 't&&(--l<0){print}/Summary/{t=1;l=1}' luacov.report.out
rm luacov.report.out
fi
rm luacov.stats.out
8 changes: 8 additions & 0 deletions lua/layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Layer Type = "ActorFrame"><children>
<Layer Type = "ActorProxy" Name = "PC[1]" />
<Layer Type = "ActorProxy" Name = "PC[2]" />
<Layer Type = "ActorProxy" Name = "PJ[1]" />
<Layer Type = "ActorProxy" Name = "PJ[2]" />
<Layer Type = "ActorProxy" Name = "PP[1]" />
<Layer Type = "ActorProxy" Name = "PP[2]" />
</children></Layer>
17 changes: 17 additions & 0 deletions lua/mods.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
if not P1 or not P2 then
backToSongWheel('Two Player Mode Required')
return
end

-- judgment / combo proxies
for pn = 1, 2 do
setupJudgeProxy(PJ[pn], P[pn]:GetChild('Judgment'), pn)
setupJudgeProxy(PC[pn], P[pn]:GetChild('Combo'), pn)
end
-- player proxies
for pn = 1, #PP do
PP[pn]:SetTarget(P[pn])
P[pn]:hidden(1)
end
-- your code goes here here:

29 changes: 0 additions & 29 deletions lua/mods.xml

This file was deleted.

36 changes: 36 additions & 0 deletions spec/acc_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---@diagnostic disable: undefined-global
local helper = require('spec.helper')
local update = helper.update

describe('acc', function()

before_each(function()
helper.reset()
helper.init()
end)

after_each(function()
xero = nil
end)

it('sets values at the right time', function()
xero.acc{1, 100, 'bumpy'}
update(0.5)
assert.equal(nil, helper.get_mod('bumpy'))
update(1)
assert.equal('100', helper.get_mod('bumpy'))
end)

it('adds when called multiple times', function()
xero.acc{1, 100, 'bumpy'}
xero.acc{1, 100, 'bumpy'}
xero.acc{1, 100, 'bumpy'}
xero.acc{1, 100, 'bumpy'}
xero.acc{1, 100, 'bumpy'}
update(0.5)
assert.equal(nil, helper.get_mod('bumpy'))
update(1)
assert.equal('500', helper.get_mod('bumpy'))
end)

end)
47 changes: 47 additions & 0 deletions spec/add_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---@diagnostic disable: undefined-global
local helper = require 'spec.helper'
local update = helper.update

describe('add', function()

before_each(function() helper.reset(); helper.init() end)
after_each(function() xero = nil end)

it('should add to the amount', function()
xero.add {0, 4, xero.inOutExpo, 100, 'bumpyx'}
xero.add {0, 4, xero.inOutExpo, 100, 'bumpyx'}
xero.add {0, 4, xero.inOutExpo, 100, 'bumpyx'}
update(4)
assert.equal('300', helper.get_mod('bumpyx'))
end)
it('should be player specific', function()
xero.add {0, 1, xero.outExpo, 100, 'dizzy'}
xero.add {0, 1, xero.outExpo, 100, 'dizzy', plr = 1}
xero.add {0, 1, xero.outExpo, 100, 'dizzy', plr = {1, 2}}
xero.add {0, 1, xero.outExpo, -100, 'dizzy', plr = 2}
update(1)
assert.equal('300', helper.get_mod('dizzy', 1))
assert.equal('100', helper.get_mod('dizzy', 2))
end)
it('should detect missing beats', function()
assert.errors(function() xero.add {nil, 4, xero.inOutExpo, 100, 'bumpyx'} end)
end)
it('should detect missing lengths', function()
assert.errors(function() xero.add {0, nil, xero.inOutExpo, 100, 'bumpyx'} end)
end)
it('should detect missing eases', function()
assert.errors(function() xero.add {0, 4, nil, 100, 'bumpyx'} end)
end)
it('should detect missing mod percents', function()
assert.errors(function() xero.add {0, 4, xero.inOutExpo, nil, 'bumpyx'} end)
end)
it('should detect missing mod names', function()
assert.errors(function() xero.add {0, 4, xero.inOutExpo, 0, nil} end)
end)
it('should detect malformed mod names', function()
assert.errors(function()
xero.add {0, 4, xero.inOutExpo, 0, 'bumpyx,'}
update()
end)
end)
end)
56 changes: 56 additions & 0 deletions spec/alias_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---@diagnostic disable: undefined-global
local helper = require('spec.helper')
local update = helper.update

describe('alias', function()

before_each(function()
helper.reset()
helper.init()
end)

after_each(function()
xero = nil
end)

it('should work with ease', function()
xero.alias{'a', 'b'}
xero.ease {0, 100, xero.outExpo, 100, 'a'}
update(100)
assert.equal(helper.get_mod('b'), '100')
end)

it('should work with perframes', function()
local success = false

xero.alias{'a', 'b'}
xero.setdefault {100, 'a'}
xero.perframe {1, 5, function(beat, mods)
success = mods[1].a == 100 and mods[1].b == 100
end}
update(3)
assert(success, 'mod aliases worked properly')
end)

it('should work with definemod (simple case)', function()
xero.definemod{'a', function()
return 100
end, 'b'}
xero.definemod{'c', function(input)
return input + 50
end, 'd'}
xero.definemod{'e', function(input)
return input + 25
end, 'f'}

xero.alias {'b', 'c'}
xero.alias {'e', 'd'}
xero.alias {'f', 'g'}

xero.set {0, 0, 'a'}

update(1)
assert.equal(helper.get_mod('g'), '175')
end)

end)
49 changes: 49 additions & 0 deletions spec/aux_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---@diagnostic disable: undefined-global
local helper = require('spec.helper')
local update = helper.update

describe('aux', function()

before_each(function()
helper.reset()
helper.init()
end)

after_each(function()
xero = nil
end)

it('prevents mods from being applied to the game', function()
xero.aux {'funny'}
xero.set {0, 100, 'funny', 100, 'funny2'}

local funny_observed
local funny2_observed

xero.perframe {0, 2, function(_, poptions)
funny_observed = poptions[1].funny
funny2_observed = poptions[1].funny2
end}

update(1)

-- funny should show up in a func, but not in the helper's mods model
assert.equals(nil, helper.get_mod('funny'))
assert.equals(100, funny_observed)

-- funny2, having not been auxed, should appear in both
assert.equals('100', helper.get_mod('funny2'))
assert.equals(100, funny2_observed)
end)

it('works with setdefault', function()
xero.aux {'funny'}
xero.setdefault {100, 'funny', 100, 'funny2'}

update(1)

assert.equals(nil, helper.get_mod('funny'))
assert.equals('100', helper.get_mod('funny2'))
end)

end)
18 changes: 18 additions & 0 deletions spec/definemod_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---@diagnostic disable: undefined-global
local helper = require('spec.helper')
local update = helper.update

describe('definemod', function()

before_each(function()
helper.reset()
helper.init()
end)

after_each(function()
xero = nil
end)

-- TODO

end)
Loading

0 comments on commit d1e9a8e

Please sign in to comment.