1
0
Fork 0
mirror of https://github.com/notwa/mm synced 2024-06-01 18:53:06 -07:00
mm/Lua/cheat menu.lua

102 lines
2.1 KiB
Lua
Raw Normal View History

require "boilerplate"
2015-05-03 16:46:09 -07:00
require "addrs.init"
require "classes"
require "menu classes"
2015-05-03 16:46:09 -07:00
function T(x, y, color, pos, s, ...)
if #{...} > 0 then
s = s:format(...)
end
gui.text(10*x + 2, 16*y + 4, s, nil, color or "white", pos or "bottomright")
end
2015-05-03 16:46:09 -07:00
function T_BR(x, y, color, ...) T(x, y, color, "bottomright", ...) end
function T_BL(x, y, color, ...) T(x, y, color, "bottomleft", ...) end
function T_TL(x, y, color, ...) T(x, y, color, "topleft", ...) end
function T_TR(x, y, color, ...) T(x, y, color, "topright", ...) end
2015-05-03 16:46:09 -07:00
local passives = {}
2015-05-03 16:46:09 -07:00
Passive = Class(Callbacks)
function Passive:init(...)
Callbacks.init(self, ...)
table.insert(passives, self)
end
2015-05-03 16:46:09 -07:00
function Passive:tick()
end
2015-05-03 16:46:09 -07:00
local levitate = Passive()
function levitate:tick()
if self.state then
if bit.band(addrs.buttons(), 0x20) > 0 then
self:hold()
end
end
end
2015-05-03 16:46:09 -07:00
function levitate:hold()
addrs.link_actor.y_vel(10)
end
2015-05-03 16:46:09 -07:00
local everything = Callbacks()
function everything:on()
dofile("oneshot.lua")
end
2015-05-03 16:46:09 -07:00
local self_destruct = Callbacks()
function self_destruct:on()
addrs.hearts(0)
end
2015-05-03 16:46:09 -07:00
local main_menu = Menu{
Screen{
Text("hey"),
Toggle("L to Levitate", levitate),
Hold("Levitate", levitate),
Oneshot("100%", everything),
Back(),
},
Screen{
Oneshot("Kill Link", self_destruct),
Flags("some flags"),
Text("k"),
Back(),
},
}
2015-05-03 16:46:09 -07:00
local input = InputHandler{
enter = "P1 L",
up = "P1 DPad U",
down = "P1 DPad D",
left = "P1 DPad L",
right = "P1 DPad R",
}
2015-05-03 16:46:09 -07:00
local menu = nil
2015-05-03 16:46:09 -07:00
while mm or oot do
local ctrl, pressed = input:update()
2015-05-03 16:46:09 -07:00
local delay = false
if not menu and pressed.enter then
delay = true
menu = main_menu
menu:focus()
end
2015-05-03 16:46:09 -07:00
if menu and not delay then
local old = menu
menu = menu:navigate(ctrl, pressed)
if menu ~= old then
old:unfocus()
if menu then menu:focus() end
end
end
2015-05-03 16:46:09 -07:00
if menu then menu:draw(T_TL, 0) end
2015-05-03 16:46:09 -07:00
for i, passive in ipairs(passives) do
passive:tick()
end
2015-05-03 16:46:09 -07:00
emu.frameadvance()
end