--[[ 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