Move to event loop, prettify warps, add delay to warp with damage counter
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Tyler
2021-06-12 01:28:34 -04:00
parent c037c66fc6
commit f9512b2485
12 changed files with 528 additions and 86 deletions

View File

@ -4,6 +4,7 @@ import (
lua "github.com/yuin/gopher-lua"
luar "layeh.com/gopher-luar"
"meow.tf/residentsleeper/events"
"meow.tf/residentsleeper/scripting/eventloop"
)
func Loader(L *lua.LState) int {
@ -23,14 +24,18 @@ func onFunc(L *lua.LState) int {
name := L.CheckString(1)
handler := L.CheckFunction(2)
loop := eventloop.FromState(L)
events.On(name, func(args ...interface{}) {
L.Push(handler)
loop.RunOnLoop(func(L *lua.LState) {
L.Push(handler)
for _, arg := range args {
L.Push(luar.New(L, arg))
}
for _, arg := range args {
L.Push(luar.New(L, arg))
}
L.PCall(len(args), 0, handler)
L.PCall(len(args), 0, handler)
})
})
return 0