forked from gaithern/KH-1FM-AP-LUA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1fmAPBoardGummi.lua
54 lines (46 loc) · 1.6 KB
/
1fmAPBoardGummi.lua
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
50
51
52
53
54
LUAGUI_NAME = "1fmAPBoardGummi"
LUAGUI_AUTH = "denhonator with slight edits from Gicu"
LUAGUI_DESC = "Read readme for button combinations. Modified for AP by Gicu"
local extraSafety = false
local offset = 0x3A0606
local addgummi = 0
local deathCheck = 0x2978E0 - offset
local safetyMeasure = 0x297746 - offset
local canExecute = false
local lastsavemenuopen = 0
function _OnInit()
if GAME_ID == 0xAF71841E and ENGINE_TYPE == "BACKEND" then
if ReadShort(deathCheck) == 0x2E74 then
ConsolePrint("Global version detected")
elseif ReadShort(deathCheck-0x1C0) == 0x2E74 then
deathCheck = deathCheck-0x1C0
safetyMeasure = safetyMeasure-0x1C0
extraSafety = false
ConsolePrint("JP detected")
end
canExecute = true
else
ConsolePrint("KH1 not detected, not running script")
end
end
function _OnFrame()
if not canExecute then
goto done
end
local savemenuopen = ReadByte(0x232A604-offset)
if savemenuopen == 4 and lastsavemenuopen ~= 4 then
addgummi = 5
end
if savemenuopen == 4 and addgummi==1 then
WriteByte(0x2E1CC28-offset, 3) --Unlock gummi
WriteByte(0x2E1CB9C-offset, 5) --Set 5 buttons to save menu
WriteByte(0x2E8F450-offset, 5) --Set 5 buttons to save menu
WriteByte(0x2E8F452-offset, 5) --Set 5 buttons to save menu
for i=0,4 do
WriteByte(0x2E1CBA0+i*4-offset, i) --Set button types
end
end
addgummi = addgummi > 0 and addgummi-1 or addgummi
lastsavemenuopen = savemenuopen
::done::
end