GMS 2.3+ [SOLVED] Program fails to run after adding code to transition between rooms

NTiger7

Member
IDE version 2.3.0.529 and runtime version 2.3.0.401. I am currently using the trial version but will be upgrading to the desktop version soon.

So I was following Shaun Spalding's tutorial on adding transitions between rooms (Part 7) when after I added the part where black bars come from the top and bottom and then you add a trigger to enter the next room, the game won't run. This is what is provided to me in the output:

GML:
"cmd"  /c subst Z: "C:\Users\strip\AppData\Roaming\GameMakerStudio2\Cache\GMS2CACHE"

elapsed time 00:00:00.1042324s for command "cmd" /c subst Z: "C:\Users\strip\AppData\Roaming\GameMakerStudio2\Cache\GMS2CACHE" started at 10/10/2020 17:52:25
"cmd"  /c subst Y: "C:\Users\strip\AppData\Local\GameMakerStudio2\GMS2TEMP"

elapsed time 00:00:00.0979827s for command "cmd" /c subst Y: "C:\Users\strip\AppData\Local\GameMakerStudio2\GMS2TEMP" started at 10/10/2020 17:52:25
"cmd"  /c subst X: "C:\ProgramData\GameMakerStudio2\Cache\runtimes\runtime-2.3.0.401"

elapsed time 00:00:00.1760401s for command "cmd" /c subst X: "C:\ProgramData\GameMakerStudio2\Cache\runtimes\runtime-2.3.0.401" started at 10/10/2020 17:52:25
"C:\ProgramData/GameMakerStudio2/Cache/runtimes\runtime-2.3.0.401/bin/Igor.exe"  -j=8 -options="C:\Users\strip\AppData\Local\GameMakerStudio2\GMS2TEMP\build.bff" -v -- Windows Run

Loaded Macros from C:\Users\strip\AppData\Roaming\GameMakerStudio2\Cache\GMS2CACHE\Nuclear_Al_16E6CEFD_F61589CD\macros.json
Options: X:/bin\platform_setting_defaults.json
Options: C:\Users\strip\AppData\Roaming/GameMakerStudio2\stripesrocks_2579517\local_settings.json
Failed to load Options from C:\Users\strip\AppData\Roaming/GameMakerStudio2\stripesrocks_2579517\local_settings.json
Options: C:\Users\strip\AppData\Roaming\GameMakerStudio2\Cache\GMS2CACHE\Nuclear_Al_16E6CEFD_F61589CD\targetoptions.json
Setting up the Asset compiler
X://bin/GMAssetCompiler.exe  /c /mv=1 /zpex /iv=0 /rv=0 /bv=0 /j=8  /gn="Nuclear Alteration" /td="Y:/" /cd="Z:/Nuclear_Al_16E6CEFD_F61589CD" /zpuf="C:\Users\strip\AppData\Roaming/GameMakerStudio2\stripesrocks_2579517" /m=windows /tgt=64 /nodnd /cfg="Default" /o="Y:/Nuclear_Alteration_430DBC34_VM" /sh=True /optionsini="Y:/Nuclear_Alteration_430DBC34_VM\options.ini"  /cvm /baseproject="X:/BaseProject\BaseProject.yyp" "C:\Users\strip\Documents\GameMakerStudio2\Nuclear Alteration\Nuclear Alteration.yyp" /preprocess="Z:/Nuclear_Al_16E6CEFD_F61589CD"
Found Project Format 2
Core Resources : Debug Info - Subresource not found 86093bef-58eb-4f99-bf45-794751993a02 on sPlayer
ProjectFileWatcher:StartWatching:C:\Users\strip\Documents\GameMakerStudio2\Nuclear Alteration
Started: 2020-10-10 5:52:27 PM
Finished: 2020-10-10 5:52:28 PM
Diff: 00:00:00.9096063
Loaded Project: Nuclear Alteration
finished.
Release build
Options: Z:/Nuclear_Al_16E6CEFD_F61589CD\ExtensionOptions.json
OptionsIni
Options: Z:/Nuclear_Al_16E6CEFD_F61589CD\PlatformOptions.json
[Compile] Run asset compiler
X://bin/GMAssetCompiler.exe  /c /mv=1 /zpex /iv=0 /rv=0 /bv=0 /j=8  /gn="Nuclear Alteration" /td="Y:/" /cd="Z:/Nuclear_Al_16E6CEFD_F61589CD" /zpuf="C:\Users\strip\AppData\Roaming/GameMakerStudio2\stripesrocks_2579517" /m=windows /tgt=64 /nodnd /cfg="Default" /o="Y:/Nuclear_Alteration_430DBC34_VM" /sh=True /optionsini="Y:/Nuclear_Alteration_430DBC34_VM\options.ini"  /cvm /baseproject="X:/BaseProject\BaseProject.yyp" "C:\Users\strip\Documents\GameMakerStudio2\Nuclear Alteration\Nuclear Alteration.yyp" /bt=run /rt=vm
Compile Constants...finished.
Remove DnD...finished.
Compile Scripts...finished.
Compile Rooms...finished.
Compile Objects...finished.
Compile Timelines...finished.
Compile Triggers...finished.
Compile Extensions...finished.
Global scripts...finished.
finished.
collapsing enums.
Final Compile...finished.
Saving IFF file... Y:/Nuclear_Alteration_430DBC34_VM\Nuclear Alteration.win
Writing Chunk... GEN8
option_game_speed=60
Writing Chunk... OPTN
Writing Chunk... LANG
Writing Chunk... EXTN
Writing Chunk... SOND
Writing Chunk... AGRP
Writing Chunk... SPRT
Writing Chunk... BGND
Writing Chunk... PATH
Writing Chunk... SCPT
Writing Chunk... GLOB
Writing Chunk... SHDR
Writing Chunk... FONT
Writing Chunk... TMLN
Writing Chunk... OBJT
Writing Chunk... ACRV
Writing Chunk... SEQN
Writing Chunk... TAGS
Writing Chunk... ROOM
Writing Chunk... DAFL
Writing Chunk... EMBI
Writing Chunk... TPAGE
Texture Group - Default
Writing Chunk... TGIN
Writing Chunk... CODE
Writing Chunk... VARI
Writing Chunk... FUNC
Writing Chunk... STRG
Writing Chunk... TXTR
0 Compressing texture... writing texture texture_0.png...
Writing Chunk... AUDO
Writing Chunk... SCPT
Writing Chunk... DBGI
Writing Chunk... INST
Writing Chunk... LOCL
Writing Chunk... DFNC
Writing Chunk... STRG
Stats : GMA : Elapsed=1413.7848
Stats : GMA : sp=25,au=0,bk=0,pt=0,sc=1,sh=2,fo=0,tl=0,ob=20,ro=3,da=0,ex=0,ma=255,fm=0x4000200C69E80020
DoSteam
Igor complete.
[Run] Run game
Options: Z:/Nuclear_Al_16E6CEFD_F61589CD\MainOptions.json
X://windows/Runner.exe  -game "Y:/Nuclear_Alteration_430DBC34_VM\Nuclear Alteration.win"
Attempting to set gamepadcount to 12
DirectX11: Using hardware device
Collision Event time(microsecs)=5
Total memory used = 7878235(0x0078365b) bytes
**********************************.
Entering main loop.
**********************************.


X://windows/Runner.exe exited with non-zero status (-1)
elapsed time 00:00:20.6392119s for command "C:\ProgramData/GameMakerStudio2/Cache/runtimes\runtime-2.3.0.401/bin/Igor.exe" -j=8 -options="C:\Users\strip\AppData\Local\GameMakerStudio2\GMS2TEMP\build.bff" -v -- Windows Run started at 10/10/2020 17:52:26
"cmd"  /c subst Z: /d

elapsed time 00:00:00.1047205s for command "cmd" /c subst Z: /d started at 10/10/2020 17:52:46
"cmd"  /c subst Y: /d

elapsed time 00:00:00.1067173s for command "cmd" /c subst Y: /d started at 10/10/2020 17:52:46
"cmd"  /c subst X: /d

elapsed time 00:00:00.1166766s for command "cmd" /c subst X: /d started at 10/10/2020 17:52:46
---------- STOPPING ----------
FAILED: Run Program Complete
For the details of why this build failed, please review the whole log above and also see your Compile Errors window.
I think the above is useless, but maybe I'm wrong. The game had no problems before. There are no complier or syntax errors. I have tried removing the code that I added in and it still doesn't load. I have closed and reopened the game and the problem still persists. Here is the last code I added after the last time the game ran successfully:

This is found in the oLevelSwitch object, in the event collision with oPlayer. TRANS_MODE.GOTO is an enum type.:
GML:
/// @description Move to next area

with (oPlayer)
{
    if (hasControl)
    {
        hasControl = false;
        SlideTransition(TRANS_MODE.GOTO, other.target);
    }
    
}
This is in the oPlayer step event.
GML:
if (hasControl)
{
    key_left = keyboard_check(ord("A")) || keyboard_check(vk_left);
    key_right = keyboard_check(ord("D")) || keyboard_check(vk_right);
    key_jump = keyboard_check_pressed(vk_space);
    key_run = keyboard_check(vk_lshift);
}
else
{
    key_left = 0;
    key_right = 0;
    key_jump = 0;
    key_run = 0;
}
For that code, I only added the if and else statement. All the key buttons worked beforehand. I also added hasControl into the oPlayer create event.

This is what the script SlideTransition looks like:
GML:
/// @desc SlideTransition(mode, targetroom)
/// @arg Mode        sets transition mode between next, restart and goto
/// @arg Target        sets target room when using the goto mode

// Script assets have changed for v2.3.0 see
// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information

with(oTransition)
{
    mode = argument[0];
    if (argument_count > 1)    target = argument[1];
    
}
To give some contexts to some variables, this is in the create event of oTransition:

GML:
/// @description Size variables and mode setup

w = display_get_gui_width();
h = display_get_gui_height();
h_half = h / 2;

enum TRANS_MODE
{
    OFF,
    NEXT,
    GOTO,
    RESTART,
    INTRO
}
mode = TRANS_MODE.INTRO;
percent = 1;
target = room;
I also made an object called oLevelSwitch so I can change rooms. I made a basic sprite for it (pink with text stating "trigger"), which is what the player will run into to change rooms. This object is invisible in the room.

If there is other code that you think might be causing the problem please let me know. I did add an oTransition object as well, but all the code in that was working previously (at least using RESTART and INTRO). I have been working on this in all my free time and would prefer to not have to restart. I also have tried to fix this problem for 2 hours with no avail.
 

FrostyCat

Member
Given that you are still writing the old script syntax, you should read the article that the notice told you to read.
GML:
/// @desc SlideTransition(mode, targetroom)
/// @arg Mode        sets transition mode between next, restart and goto
/// @arg Target        sets target room when using the goto mode
function SlideTransition(_mode, _targetroom)
{
    with (oTransition)
    {
        mode = _mode;
        if (argument_count > 1)
        {
            target = _targetroom;
        }
    }
}
 

NTiger7

Member
Given that you are still writing the old script syntax, you should read the article that the notice told you to read.
GML:
/// @desc SlideTransition(mode, targetroom)
/// @arg Mode        sets transition mode between next, restart and goto
/// @arg Target        sets target room when using the goto mode
function SlideTransition(_mode, _targetroom)
{
    with (oTransition)
    {
        mode = _mode;
        if (argument_count > 1)
        {
            target = _targetroom;
        }
    }
}
I did look at the changes, but they make more sense now so thank you. I did change it to the updated format but the build still fails.

EDIT: I now notice that I get a syntax error stating that calling this function requires two arguments but it only got one. This is because I used SlideTransition(TRANS_MODE.RESTART) in oPlayer's event key press 'R'. I do not need the second variable since I only want the second input function to work with TRANS_MODE.GOTO and no other mode. Could this cause the program to not run?
 
Last edited:

Nidoking

Member
EDIT: I now notice that I get a syntax error stating that calling this function requires two arguments but it only got one. This is because I used SlideTransition(TRANS_MODE.RESTART) in oPlayer's event key press 'R'. I do not need the second variable since I only want the second input function to work with TRANS_MODE.GOTO and no other mode. Could this cause the program to not run?
Yes, you need to send the correct variables for the function definition every time. This is a sophisticated computer program, not Twitter. You can't just leave things out because you don't have room and assume that the program will figure them out from context. If you want to verify that your arguments fit a particular pattern, you'll need to put more logic in the function or write two functions. There's also a syntax that allows you to use a single function with any number of variables, but I don't suggest that you use it until you've got the basics figured out. In fact, you've clearly already started down that road - FrostyCat added arguments for you but left argument_count in place. If you change that check to mode == TRANS_MODE.GOTO, it should do exactly what you want, but you'll still need to put something in the room argument.
 

NTiger7

Member
Yes, you need to send the correct variables for the function definition every time. This is a sophisticated computer program, not Twitter. You can't just leave things out because you don't have room and assume that the program will figure them out from context. If you want to verify that your arguments fit a particular pattern, you'll need to put more logic in the function or write two functions. There's also a syntax that allows you to use a single function with any number of variables, but I don't suggest that you use it until you've got the basics figured out. In fact, you've clearly already started down that road - FrostyCat added arguments for you but left argument_count in place. If you change that check to mode == TRANS_MODE.GOTO, it should do exactly what you want, but you'll still need to put something in the room argument.
I understand that this is a sophisticated computer program. This is not my first experience with coding, just with GML and Game Maker in general. As I mentioned before, I was following a tutorial and this was how the tutorial set things up, but I know that with 2.3, scripts have changed so at least that part is outdated.

Regardless, I have updated my code and have added two scripts, one that will only work with TRANS_MODE.GOTO and the other where it will work when mode either works TRANS_MODE.RESTART or TRANS_MODE.NEXT.

This is script SlideTransition:

GML:
/// @desc SlideTransition(mode, targetroom)
/// @arg Mode        sets transition mode to goto
/// @arg Target        sets target room to target

function SlideTransition(_mode, _targetroom)
{
    with(oTransition)
    {
        if (mode == TRANS_MODE.GOTO)
        {
            mode = _mode;
            target = _targetroom;  
        }
    }
}
This is script RestartAndRoomChange:
GML:
/// @desc RestartAndRoomChange(mode)
/// @arg mode        sets transition mode between next and restart


function RestartAndRoomChange(_mode){
    with(oTransition)
    {
        if (mode == TRANS_MODE.RESTART) || (mode == TRANS_MODE.NEXT)    mode = _mode;
    }
}
I have change the script where I called TRANS_MODE.RESTART originally and replaced it with RestartAndRoomChange. I have no syntax or complier errors. My program still will not build.

If this is not a good solution, I can alternatively use one function and made it so that if the mode is restart or next then it sets the room using room function (as in target = room) so it will still work and not transition anywhere.
 

Nidoking

Member
Are you saying that your build fails, but without errors? Or does the game not run? Or does it run, but this part doesn't work, likely because you've got the boolean logic backwards?
 

NTiger7

Member
Are you saying that your build fails, but without errors? Or does the game not run? Or does it run, but this part doesn't work, likely because you've got the boolean logic backwards?
I'm saying that if I try to run the program, it basically crashes. Like, the screen freezes and eventually will turn to white. In the output, it says the build failed. I only have two rooms and I just duplicated the second room since I haven't worked on the sprites for new buildings (it's just the player walks on a street and there are different buildings on the street). So the whole game won't run. I can't test if any of my new code works or not since when I run the game, the game freezes.
 

Nidoking

Member
Might be time to run it in the debugger, then. Hit pause and see where the execution thinks it is, and step through to see what it's doing. Chances are good you've got an infinite loop somewhere.
 

NTiger7

Member
Might be time to run it in the debugger, then. Hit pause and see where the execution thinks it is, and step through to see what it's doing. Chances are good you've got an infinite loop somewhere.
Thank you! I didn't understand how to use the debugger. I didn't realize that you had to hit pause to see where the code stops (it makes more sense now that I know). That was indeed my problem. I forgot I added a feature while adding in the room transition. I added a second ground type called oAsphalt (compared to oSidewalk) and here is the code:
GML:
if (place_meeting(x,y+vsp,oSidewalk)) || (place_meeting(x,y+vsp, oAsphalt))
{
    while(!place_meeting(x,y+sign(vsp),oSidewalk) && (!place_meeting(x,y+sign(vsp),oAsphalt)))
    {
        y = y + sign(vsp);
    }
    vsp = 0;
}
I originally used 'or' in the while loop and not 'and' and that was causing an infinite loop. I fixed all the objects that had this code in it with the updated code, and I can now build the game. So thank you. I wasn't paying attention.

Also, a side note: the transition didn't work when I tried it so if someone has the same problem, do not use the scripts I used above, but these ones:

Script RestartAndRoomChange:
GML:
/// @desc RestartAndRoomChange(mode)
/// @arg mode        sets transition mode between next and restart


function RestartAndRoomChange(_mode){
    with(oTransition)
    { 
        mode = _mode;
    }
}
Script SlideTransition:
GML:
/// @desc SlideTransition(mode, targetroom)
/// @arg Mode        sets transition mode to goto
/// @arg Target        sets target room if mode is goto

function SlideTransition(_mode, _targetroom)
{
    with(oTransition)
    {
        mode = _mode;
        target = _targetroom; 
    }
}
Using the if statements I mentioned before will not work. It might be possible to combine these two scripts into one by setting target to room if it is goto or next but using two functions is working no problem. Thank you everyone for the help!
 
Top