Skip to content

Commit c0486f3

Browse files
[Community][CheatCode] A condition to check if a specific cheat code was entered (#868)
Thanks to @ayushbhardwas
1 parent 20fe7af commit c0486f3

File tree

1 file changed

+332
-0
lines changed

1 file changed

+332
-0
lines changed
Lines changed: 332 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,332 @@
1+
{
2+
"author": "",
3+
"category": "Input",
4+
"extensionNamespace": "",
5+
"fullName": "CheatCode",
6+
"helpPath": "",
7+
"iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLWZvcm0tdGV4dGJveC1wYXNzd29yZCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiB2aWV3Qm94PSIwIDAgMjQgMjQiPjxwYXRoIGQ9Ik0xNyw3SDIyVjE3SDE3VjE5QTEsMSAwIDAsMCAxOCwyMEgyMFYyMkgxNy41QzE2Ljk1LDIyIDE2LDIxLjU1IDE2LDIxQzE2LDIxLjU1IDE1LjA1LDIyIDE0LjUsMjJIMTJWMjBIMTRBMSwxIDAgMCwwIDE1LDE5VjVBMSwxIDAgMCwwIDE0LDRIMTJWMkgxNC41QzE1LjA1LDIgMTYsMi40NSAxNiwzQzE2LDIuNDUgMTYuOTUsMiAxNy41LDJIMjBWNEgxOEExLDEgMCAwLDAgMTcsNVY3TTIsN0gxM1Y5SDRWMTVIMTNWMTdIMlY3TTIwLDE1VjlIMTdWMTVIMjBNOC41LDEyQTEuNSwxLjUgMCAwLDAgNywxMC41QTEuNSwxLjUgMCAwLDAgNS41LDEyQTEuNSwxLjUgMCAwLDAgNywxMy41QTEuNSwxLjUgMCAwLDAgOC41LDEyTTEzLDEwLjg5QzEyLjM5LDEwLjMzIDExLjQ0LDEwLjM4IDEwLjg4LDExQzEwLjMyLDExLjYgMTAuMzcsMTIuNTUgMTEsMTMuMTFDMTEuNTUsMTMuNjMgMTIuNDMsMTMuNjMgMTMsMTMuMTFWMTAuODlaIiAvPjwvc3ZnPg==",
8+
"name": "CheatCode",
9+
"previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/5ab10adef033825feddc9138b59d79d9a7aa94c58dd58fba0d21cd7b99be4aff_form-textbox-password.svg",
10+
"shortDescription": "Add cheat codes to your game.",
11+
"version": "1.1.1",
12+
"description": [
13+
"- Use \"Cheat Code Entered\" (A Condition to check if a cheat code was entered).",
14+
"",
15+
"Note: Only lowercase alphabets and no special characters can be used as a cheat code."
16+
],
17+
"tags": [
18+
"cheatcode",
19+
"code",
20+
"debug",
21+
"tool"
22+
],
23+
"authorIds": [
24+
"TJLmS4MUFJSWNNietFUWDxVSKnB3"
25+
],
26+
"dependencies": [],
27+
"eventsFunctions": [
28+
{
29+
"description": "Check if a cheat code was entered.",
30+
"fullName": "Cheat code entered",
31+
"functionType": "Condition",
32+
"name": "CheatCodeEntered",
33+
"sentence": "_PARAM1_ code entered",
34+
"events": [
35+
{
36+
"type": "BuiltinCommonInstructions::Comment",
37+
"color": {
38+
"b": 109,
39+
"g": 230,
40+
"r": 255,
41+
"textB": 0,
42+
"textG": 0,
43+
"textR": 0
44+
},
45+
"comment": "How it works:\n\n1) The program checks if a key is pressed.\n2) In a structure (__CheatCode.IndexStructure) each code has a variable that stores the index of the current letter in the code that is to be checked.\n3) If the key that was pressed matches the required letter, the variable's value is incremented by 1 (one).\n4) If not, the variable is set back to 0 (zero).\n5) Once each letter is checked, the variable reaches the final index, confirming that the correct code was entered and the condition returns true.\n\nNote: the time TimeLimit parameter is not nil then a scene timer is created by the name \"__CheatCode_<code>\" for that specific code. This timer is checked in step 3 to ensure there is time left to enter the code."
46+
},
47+
{
48+
"folded": true,
49+
"type": "BuiltinCommonInstructions::Standard",
50+
"conditions": [
51+
{
52+
"type": {
53+
"value": "DepartScene"
54+
},
55+
"parameters": [
56+
""
57+
]
58+
}
59+
],
60+
"actions": [
61+
{
62+
"type": {
63+
"value": "ModVarSceneTxt"
64+
},
65+
"parameters": [
66+
"__CheatCode.LastCodeChecked",
67+
"=",
68+
"\"\""
69+
]
70+
}
71+
],
72+
"events": [
73+
{
74+
"type": "BuiltinCommonInstructions::Standard",
75+
"conditions": [
76+
{
77+
"type": {
78+
"value": "GetArgumentAsBoolean"
79+
},
80+
"parameters": [
81+
"\"TimeLimit\""
82+
]
83+
}
84+
],
85+
"actions": [
86+
{
87+
"type": {
88+
"value": "ResetTimer"
89+
},
90+
"parameters": [
91+
"",
92+
"\"__CheatCode_\"+GetArgumentAsString(\"Code\")"
93+
]
94+
}
95+
]
96+
}
97+
]
98+
},
99+
{
100+
"type": "BuiltinCommonInstructions::Standard",
101+
"conditions": [
102+
{
103+
"type": {
104+
"value": "AnyKeyPressed"
105+
},
106+
"parameters": [
107+
""
108+
]
109+
}
110+
],
111+
"actions": [],
112+
"events": [
113+
{
114+
"folded": true,
115+
"type": "BuiltinCommonInstructions::Standard",
116+
"conditions": [
117+
{
118+
"type": {
119+
"value": "BuiltinCommonInstructions::CompareStrings"
120+
},
121+
"parameters": [
122+
"LastPressedKey()",
123+
"!=",
124+
"StrAt(GetArgumentAsString(\"Code\"), Variable(__CheatCode.IndexStructure[GetArgumentAsString(\"Code\")]))"
125+
]
126+
},
127+
{
128+
"type": {
129+
"value": "BuiltinCommonInstructions::Once"
130+
},
131+
"parameters": []
132+
}
133+
],
134+
"actions": [
135+
{
136+
"type": {
137+
"value": "ModVarScene"
138+
},
139+
"parameters": [
140+
"__CheatCode.IndexStructure[GetArgumentAsString(\"Code\")]",
141+
"=",
142+
"0"
143+
]
144+
}
145+
],
146+
"events": [
147+
{
148+
"type": "BuiltinCommonInstructions::Standard",
149+
"conditions": [
150+
{
151+
"type": {
152+
"value": "GetArgumentAsBoolean"
153+
},
154+
"parameters": [
155+
"\"TimeLimit\""
156+
]
157+
}
158+
],
159+
"actions": [
160+
{
161+
"type": {
162+
"value": "ResetTimer"
163+
},
164+
"parameters": [
165+
"",
166+
"\"__CheatCode_\"+GetArgumentAsString(\"Code\")"
167+
]
168+
}
169+
]
170+
}
171+
]
172+
},
173+
{
174+
"type": "BuiltinCommonInstructions::Standard",
175+
"conditions": [
176+
{
177+
"type": {
178+
"value": "BuiltinCommonInstructions::CompareStrings"
179+
},
180+
"parameters": [
181+
"LastPressedKey()",
182+
"=",
183+
"StrAt(GetArgumentAsString(\"Code\"), Variable(__CheatCode.IndexStructure[GetArgumentAsString(\"Code\")]))"
184+
]
185+
},
186+
{
187+
"type": {
188+
"value": "BuiltinCommonInstructions::Or"
189+
},
190+
"parameters": [],
191+
"subInstructions": [
192+
{
193+
"type": {
194+
"inverted": true,
195+
"value": "GetArgumentAsBoolean"
196+
},
197+
"parameters": [
198+
"\"TimeLimit\""
199+
]
200+
},
201+
{
202+
"type": {
203+
"value": "BuiltinCommonInstructions::And"
204+
},
205+
"parameters": [],
206+
"subInstructions": [
207+
{
208+
"type": {
209+
"value": "GetArgumentAsBoolean"
210+
},
211+
"parameters": [
212+
"\"TimeLimit\""
213+
]
214+
},
215+
{
216+
"type": {
217+
"value": "CompareTimer"
218+
},
219+
"parameters": [
220+
"",
221+
"\"__CheatCode_\"+GetArgumentAsString(\"Code\")",
222+
"<",
223+
"GetArgumentAsNumber(\"TimeLimit\")"
224+
]
225+
}
226+
]
227+
}
228+
]
229+
},
230+
{
231+
"type": {
232+
"value": "BuiltinCommonInstructions::Once"
233+
},
234+
"parameters": []
235+
}
236+
],
237+
"actions": [
238+
{
239+
"type": {
240+
"value": "ModVarScene"
241+
},
242+
"parameters": [
243+
"__CheatCode.IndexStructure[GetArgumentAsString(\"Code\")]",
244+
"+",
245+
"1"
246+
]
247+
}
248+
]
249+
}
250+
]
251+
},
252+
{
253+
"folded": true,
254+
"type": "BuiltinCommonInstructions::Standard",
255+
"conditions": [
256+
{
257+
"type": {
258+
"value": "VarScene"
259+
},
260+
"parameters": [
261+
"__CheatCode.IndexStructure[GetArgumentAsString(\"Code\")]",
262+
"=",
263+
"StrLength(GetArgumentAsString(\"Code\"))"
264+
]
265+
}
266+
],
267+
"actions": [
268+
{
269+
"type": {
270+
"value": "ModVarScene"
271+
},
272+
"parameters": [
273+
"__CheatCode.IndexStructure[GetArgumentAsString(\"Code\")]",
274+
"=",
275+
"0"
276+
]
277+
},
278+
{
279+
"type": {
280+
"value": "SetReturnBoolean"
281+
},
282+
"parameters": [
283+
"True"
284+
]
285+
}
286+
],
287+
"events": [
288+
{
289+
"type": "BuiltinCommonInstructions::Standard",
290+
"conditions": [
291+
{
292+
"type": {
293+
"value": "GetArgumentAsBoolean"
294+
},
295+
"parameters": [
296+
"\"TimeLimit\""
297+
]
298+
}
299+
],
300+
"actions": [
301+
{
302+
"type": {
303+
"value": "ResetTimer"
304+
},
305+
"parameters": [
306+
"",
307+
"\"__CheatCode_\"+GetArgumentAsString(\"Code\")"
308+
]
309+
}
310+
]
311+
}
312+
]
313+
}
314+
],
315+
"parameters": [
316+
{
317+
"description": "Code",
318+
"name": "Code",
319+
"type": "string"
320+
},
321+
{
322+
"description": "Time in seconds under which the code must be entered (leave empty for no time limit)",
323+
"name": "TimeLimit",
324+
"type": "expression"
325+
}
326+
],
327+
"objectGroups": []
328+
}
329+
],
330+
"eventsBasedBehaviors": [],
331+
"eventsBasedObjects": []
332+
}

0 commit comments

Comments
 (0)