-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheat_menu.lua
243 lines (212 loc) · 7.31 KB
/
cheat_menu.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
--
--Copyright (C) 2022 Matthias Gatto
--
--This program is free software: you can redistribute it and/or modify
--it under the terms of the GNU Lesser General Public License as published by
--the Free Software Foundation, either version 3 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--GNU General Public License for more details.
--
--You should have received a copy of the GNU Lesser General Public License
--along with this program. If not, see <http://www.gnu.org/licenses/>.
--
local phq = Entity.wrapp(ygGet("phq"))
local function mk_main_mn()
local menu = Menu.new_entity()
menu.ent.size = 30
menu.ent["pre-text"] = "Cheat Menu\nhere for debuging purpose:"
menu.ent.onEsc = Entity.new_func("popGlobMnOtherMenu")
menu:push("back", Entity.new_func("popGlobMnOtherMenu"))
local slider = Entity.new_array()
slider[0] = {}
slider[0].text = "night"
slider[0].action = {"recreateString", "phq.env.time", "night"}
slider[1] = {}
slider[1].text = "day"
slider[1].action = {"recreateString", "phq.env.time", "day"}
slider[2] = {}
slider[2].text = "morning"
slider[2].action = {"recreateString", "phq.env.time", "morning"}
ywMenuPushSlider(menu.ent, "Time Select: ", slider)
slider = Entity.new_array()
slider[0] = {}
slider[0].text = "prolgue"
slider[0].action = {"recreateInt", "phq.env.chapter", 0}
slider[1] = {}
slider[1].text = "1"
slider[1].actions = {}
slider[1].actions[0] = {"recreateInt", "phq.env.day", 1}
slider[1].actions[1] = {"recreateString", "phq.env.time", "night"}
slider[1].actions[2] = {"phq:quest_script", "end_chapter_0"}
slider[1].actions[3] = Entity.new_func(popGlobMnOtherMenu)
ywMenuPushSlider(menu.ent, "Chapter Select: ", slider)
menu:push("Quests", Entity.new_func(cheat_quest_select_mn))
menu:push("next chapter", Entity.new_func(gotoEndChapter))
local money_action = Entity.new_array()
money_action[0] = "phq.recive"
money_action[1] = "money"
money_action[2] = 50
menu:push("give 50$", money_action)
local xp_action = Entity.new_array()
xp_action[0] = "phq.increase"
xp_action[1] = "xp"
xp_action[2] = 50
menu:push("give 50 xp", xp_action)
local m_actions = Entity.new_array()
m_actions[0] = {"phq.openGlobMenu", 3}
local e = menu:push("Metro")
e.actions = m_actions
menu:push("NPCs", Entity.new_func(cheat_npcs_mn))
menu:push("Students", Entity.new_func(cheat_students_mn))
menu.ent.in_subcontained = 1
return menu.ent
end
function cheat_main_mn(mn)
local cnt = ywCntWidgetFather(mn)
ywReplaceEntry(cnt, 0, mk_main_mn())
Entity.wrapp(cnt).in_subcontained = 1
return YEVE_ACTION
end
function cheat_quest_action(mn)
local cur_txt = Entity.wrapp(ywMenuGetCurrentEntry(mn)).text:to_string()
print(cur_txt, phq.quests[cur_txt], "phq.quests." .. cur_txt)
ygIncreaseInt("phq.quests." .. cur_txt, 1);
print(cur_txt, phq.quests[cur_txt], "phq.quests." .. cur_txt)
local f = ywCntWidgetFather(mn)
popGlobMnOtherMenu(mn)
return backToGame(f)
end
function cheat_quest_select_mn(main_mn)
local cnt = ywCntWidgetFather(main_mn)
local qmn = Menu.new_entity()
qmn.ent["pre-text"] = "Quest Cheat Menu"
qmn.ent.onEsc = Entity.new_func(cheat_main_mn)
qmn:push("Back", Entity.new_func(cheat_main_mn))
for i = 0, yeLen(phq.quests) - 1 do
qmn:push(yeGetKeyAt(phq.quests, i), Entity.new_func(cheat_quest_action))
end
qmn.ent.size = 30
ywReplaceEntry(cnt, 0, qmn.ent)
return YEVE_ACTION
end
function cheat_students_mn(main_mn)
local cnt = Entity.wrapp(ywCntWidgetFather(main_mn))
local nmn = Menu.new_entity()
nmn.ent["pre-text"] = "Quest Cheat Menu"
nmn.ent.onEsc = Entity.new_func(cheat_main_mn)
nmn.ent.moveOn = Entity.new_func(cheat_show_npc)
nmn:push("Back", Entity.new_func(cheat_main_mn))
for i = 0, yeLen(npcs) - 1 do
local npc = yeGet(npcs, i)
local npc_key = yeGetKeyAt(npcs, i)
if yIsNNil(yeGet(npc, "student_year")) then
nmn:push(npc_key)
end
end
nmn.ent.size = 30
ywReplaceEntry(cnt, 0, nmn.ent)
ywPushNewWidget(cnt, Canvas.new_entity().ent);
cnt.current = 0
return YEVE_ACTION
end
function cheat_show_npc(mn, _current)
local cur = Entity.wrapp(ywMenuGetCurrentEntry(mn))
local cnt = ywCntWidgetFather(mn)
local canvas = Entity.wrapp(ywCntGetEntry(cnt, 1))
local npc = npcs[cur.text]
local handler
canvas.h = nil
ywCanvasClear(canvas)
if yIsNil(npc) then
return YEVE_ACTION;
end
if yeGetString(npc.type) == "sprite" then
canvas.h = sprite_man.createHandler(npc, canvas)
else
dressup.dressUp(npc)
canvas.h = lpcs.createCaracterHandler(npc, canvas)
canvas.h.y = LPCS_DOWN
end
handler = canvas.h
yGenericHandlerRefresh(handler)
yShowDialogueImage(canvas, npc)
if npc.stats then
ywCanvasNewTextExt(canvas, 200, 20,
Entity.new_string(npc.stats:to_string()),
"rgba: 0 0 0 255")
end
if yIsNNil(npc._place) or yIsNNil(npc._cur_pos) then
local localtion = "localtion: "
if yIsNNil(npc._cur_pos) then
localtion = localtion .. yeGetString(npc._cur_pos)
elseif yIsNNil(npc._place) then
localtion = localtion .. yeGetString(npc._place)
end
ywCanvasNewTextExt(canvas, 460, 20,
Entity.new_string(localtion),
"rgba: 0 0 0 255")
end
ywCanvasNewTextExt(canvas, 460, 35,
Entity.new_string("year " .. yeGetIntAt(npc, "student_year")),
"rgba: 0 0 0 255")
ywCanvasNewTextExt(canvas, 460, 50,
Entity.new_string("class " .. yeGetIntAt(npc, "class")),
"rgba: 0 0 0 255")
if npc.relation then
ywCanvasNewTextExt(canvas, 460, 120,
Entity.new_string(npc.relation:to_string()),
"rgba: 0 0 0 255")
end
if npc.reputation then
ywCanvasNewTextExt(canvas, 460, 340,
Entity.new_string(npc.reputation:to_string()),
"rgba: 0 0 0 255")
end
if npc.trait then
ywCanvasNewTextExt(canvas, 200, 120,
Entity.new_string(npc.trait:to_string()),
"rgba: 0 0 0 255")
end
if npc.organisations then
ywCanvasNewTextExt(canvas, 200, 300,
Entity.new_string(npc.organisations:to_string()),
"rgba: 0 0 0 255")
end
if npc.knowledge then
ywCanvasNewTextExt(canvas, 200, 360,
Entity.new_string(npc.knowledge:to_string()),
"rgba: 0 0 0 255")
end
return YEVE_ACTION;
end
function cheat_npcs_mn(main_mn)
local cnt = Entity.wrapp(ywCntWidgetFather(main_mn))
local nmn = Menu.new_entity()
nmn.ent["pre-text"] = "Quest Cheat Menu"
nmn.ent.moveOn = Entity.new_func(cheat_show_npc)
nmn:push("Back", Entity.new_func(cheat_main_mn))
nmn.ent.onEsc = Entity.new_func(cheat_main_mn)
for i = 0, yeLen(npcs) - 1 do
local npc_key = yeGetKeyAt(npcs, i)
if (yIsNNil(npc_key)) then
nmn:push(npc_key)
end
end
nmn.ent.size = 30
ywReplaceEntry(cnt, 0, nmn.ent)
ywPushNewWidget(cnt, Canvas.new_entity().ent);
cnt.current = 0
return YEVE_ACTION
end
function god_window(_mn)
local m = main_widget
local ccw = Container.new_entity("vertical")
ccw.ent.background = "rgba: 255 255 255 255"
ccw.ent.entries[0] = mk_main_mn()
ywPushNewWidget(m, ccw.ent)
return YEVE_ACTION
end