Skip to content

Commit 0cea983

Browse files
Dobby233Liucolinator27
authored andcommitted
Address suggestions, improve comments
1 parent fb82caf commit 0cea983

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

UndertaleModTool/Scripts/Builtin Scripts/RunSwitchAndXboxOnPC.csx

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ bool isXbox = Data.Rooms.ByName("room_xbox_engagement") is not null;
1717

1818
if (isXbox)
1919
{
20-
// Fix initialization code not running
20+
// Fix cruical initialization code not running.
2121
ReplaceTextInGML("gml_Object_obj_time_Create_0", """
2222
if (os_type == os_xboxone)
2323
{
@@ -35,20 +35,24 @@ if (isXbox)
3535
otherEvents.Remove(gameStartEvent);
3636
}
3737

38-
// Disables interpolation. Only necessary for NX version.
38+
// Disables interpolation. Only necessary for the NX version.
3939
Data.GeneralInfo.Info &= ~UndertaleGeneralInfo.InfoFlags.Interpolate;
4040

41-
// Use new gamepad functions, because the compatibility ones are completely broken
41+
// Use console gamepad code paths to use the new gamepad functions,
42+
// because the compatibility ones are completely broken.
4243

43-
// use NX routine for joypad detection
44+
// Use the NX code path for gamepad detection.
4445
ReplaceTextInGML("gml_Object_obj_time_Create_0", "if (global.osflavor >= 4)", "if (true)");
46+
// Make the game not pretend a controller is there initially on PC?
47+
// Why did they do this?
4548
ReplaceTextInGML("gml_Object_obj_time_Create_0", """
4649
else
4750
j_ch = 1
4851
""", """
4952
else if (global.osflavor >= 4)
5053
j_ch = 1
5154
""");
55+
// The os_switch constant changed after the NX version.
5256
string os_switch = "os_switch" + (!isXbox ? "_beta" : "");
5357
ReplaceTextInGML("gml_Object_obj_time_Step_1", "global.osflavor <= 2", "false");
5458
ReplaceTextInGML("gml_Object_obj_time_Step_1", $"os_type == {os_switch}", "true");
@@ -61,7 +65,9 @@ ReplaceTextInGML("gml_Object_obj_time_Step_1", """
6165
missing_controller_timeout = 0
6266
""");
6367

64-
// Use Xbox default buttons
68+
// Use the Xbox default buttons on PC.
69+
// We have to map the joystick_* button constants to the gamepad_*
70+
// button constants anyway.
6571
ReplaceTextInGML("gml_Object_obj_time_Create_0", """
6672
global.button0 = 2
6773
global.button1 = 1
@@ -81,7 +87,7 @@ ReplaceTextInGML("gml_Object_obj_joypadmenu_Draw_0", """
8187
global.button2 = gp_face4
8288
""");
8389

84-
// axis check
90+
// Use the console path for the axis check.
8591
ReplaceTextInGML("gml_Object_obj_time_Step_1", """
8692
if (global.osflavor >= 4)
8793
{
@@ -92,14 +98,14 @@ ReplaceTextInGML("gml_Object_obj_time_Step_1", """
9298
if (gamepad_button_check
9399
""");
94100

95-
// button check
101+
// Use the console path for the button checks.
96102
ReplaceTextInGML("gml_Script_control_update", "else if (obj_time.j_ch > 0)", "else if (false)");
97103
ReplaceTextInGML("gml_Script_control_update", "global.osflavor >= 4", "obj_time.j_ch > 0");
98104

99-
// Fix Joystick Menu
105+
// Make the Joystick Menu use the new gamepad functions.
100106
ReplaceTextInGML("gml_Object_obj_joypadmenu_Create_0", "joystick_has_pov(obj_time.j_ch)", "true");
101107
ReplaceTextInGML("gml_Object_obj_joypadmenu_Draw_0", "joystick_has_pov(obj_time.j_ch)", "true");
102-
// gamepad_button_count(obj_time.j_ch - 1) might work better but I'm not sure
108+
// TODO: gamepad_button_count(obj_time.j_ch - 1) might work better?
103109
ReplaceTextInGML("gml_Object_obj_joypadmenu_Draw_0", "joystick_buttons(obj_time.j_ch)", "11 + 1");
104110
ReplaceTextInGML("gml_Object_obj_joypadmenu_Draw_0", "joystick_check_button(obj_time.j_ch, i)", "gamepad_button_check(obj_time.j_ch - 1, gp_face1 + i)");
105111
for (var i = 0; i < 3; i++)
@@ -108,13 +114,7 @@ for (var i = 0; i < 3; i++)
108114
ReplaceTextInGML("gml_Object_obj_joypadmenu_Draw_0", $"string_hash_to_newline(global.button{i})", $"string(global.button{i} - gp_face1)");
109115
}
110116

111-
// Use Xbox or PS4 button sprites
112-
if (isXbox)
113-
ReplaceTextInGML("gml_Script_scr_getbuttonsprite", "os_type == os_xboxone", "true");
114-
else
115-
ReplaceTextInGML("gml_Script_scr_getbuttonsprite", "os_type == os_ps4", "true");
116-
117-
// Allow gamepad input for left/right heart halfs
117+
// Make the Mad Mew Mew heart halves accept both kinds of input.
118118
foreach (char half in new[] {'l', 'r'})
119119
{
120120
foreach (char side in new[] {'u', 'd', 'l', 'r'})
@@ -128,45 +128,45 @@ if (ScriptQuestion("Enable the Dog Shrine?"))
128128
{
129129
if (isXbox)
130130
{
131-
// This enables the Dog Shrine's entrance.
131+
// This enables the entrance to the Dog Shrine.
132132
ReplaceTextInGML("gml_Object_obj_kitchenchecker_Create_0", "global.osflavor == 4 || global.osflavor == 5 || global.osflavor == 6", "true");
133133
ReplaceTextInGML("gml_Object_obj_kitchenchecker_Alarm_2", "(global.osflavor == 4 || global.osflavor == 5 || global.osflavor == 6) && ", "");
134-
// if in NX version, the door will get you into the ruined dog shrine
134+
// This patch is unnecessary in the NX version, as the door will get you into the ruined Dog Shrine.
135135
ReplaceTextInGML("gml_Object_obj_doorXmusicfade_Alarm_2", "if (global.osflavor == 6)", "else");
136136

137-
// Enable donation box trash
137+
// Enable the donation box trash in Waterfall.
138138
ReplaceTextInGML("gml_Object_obj_npc_room_Create_0", "global.osflavor != 4 && global.osflavor != 6", "false");
139139
}
140140
else
141141
{
142-
// This enables the Dog Shrine's entrance.
142+
// This enables the entrance to the Dog Shrine.
143143
ReplaceTextInGML("gml_Object_obj_kitchenchecker_Create_0", "global.osflavor == 4 || global.osflavor == 5", "true");
144144
ReplaceTextInGML("gml_Object_obj_kitchenchecker_Alarm_2", "(global.osflavor == 4 || global.osflavor == 5) && ", "");
145145

146-
// Enable donation box trash
146+
// Enable the donation box trash in Waterfall.
147147
ReplaceTextInGML("gml_Object_obj_npc_room_Create_0", "(global.osflavor != 4 && global.osflavor != 5) || ", "");
148148
}
149149
}
150150

151-
// Done.
152-
ScriptMessage("""
151+
string requiredFiles = !isXbox ? """
152+
Copy "mus_mewmew.ogg", "mus_sfx_dogseal.ogg",
153+
and "DELTARUNE.exe" (from the 2018 Ch1 demo)
154+
to the folder you will save this data file to.
155+
Then use the Deltarune runner to run the game.
156+
""" : """
157+
Copy "mus_mewmew.ogg", "mus_sfx_dogseal.ogg",
158+
"mus_dogshrine_xbox.ogg", and a GMS2 2.2.2-2.2.5
159+
runner to the folder you will save this data file to.
160+
Then use the new runner to run the game.
161+
""";
162+
ScriptMessage($"""
153163
NXTALE Enabler by Kneesnap
154164
Xbox and gamepad fixes by Dobby233Liu
155165
156166
NOTE: You're not done yet!
157167
158-
For Switch version:
159-
Copy "mus_mewmew.ogg", "mus_sfx_dogseal.ogg",
160-
and "DELTARUNE.exe" (from SURVEY_PROGRAM/the 2018 version)
161-
to the folder you will save this data file to.
162-
Then use the Deltarune runner to run Undertale.
163-
164-
For Xbox version:
165-
Copy "mus_mewmew.ogg", "mus_sfx_dogseal.ogg"
166-
and "mus_dogshrine_xbox.ogg"
167-
to the folder you will save this data file to.
168-
Then use a GMS2 2.2.2-2.2.5 runner to run Undertale.
168+
{requiredFiles}
169169
170-
Due to button constant changes, you might want to reset
171-
the joystick settings.
170+
Due to gamepad code changes, you might want to reset the
171+
gamepad settings.
172172
""");

0 commit comments

Comments
 (0)