1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
--[[ Dispatches events ]]
mod = ...
char = require "char"
import KeyInput from char
main = require "main"
set_input = (inputs, key, value) ->
for input in *inputs
if input.key == key
--print("Setting", key, " to", value)
input.value = value
return
controls = {
right: "right",
left: "left",
up: "up"
jump: "z",
down: "down"
dash: "c"
swing: "x"
}
mod.control = (character) ->
character.node\action(coroutine.create(() ->
while true
for k,v in pairs controls
set_input(character.inputs,k,main.win\key_down(v))
coroutine.yield()
))
mod.slime_ai = (character) ->
character.node\action(coroutine.create(() ->
time_offset = math.random()
last_action = am.current_time() + time_offset
while true
time_diff = am.current_time() - last_action
if time_diff > 1.3
last_action = am.current_time() + math.random()
elseif time_diff > 1.1
set_input(character.inputs,"jump_left",false)
elseif time_diff > 1
set_input(character.inputs,"jump_left",true)
coroutine.yield()
))
mod
|