Legacy GM Need help with remaining Obsolete Commands

S

Stratos

Guest
Hello all, Its been years since I have posted on the GMC forums. Anyways, I have been slowly making a game on and off in game maker 8.1. Earlier today, I kept getting errors when trying to do things which actually happens once every few days so i saved it and closed it. When reopening it, it said that it and the backup were corrupt and could not be opened. The files open fine on Game Maker Studio, so I thought now is as good as any other time to transfer it over, as GM: Studio is just better.

So the issue is three lines of code in my game that are all pretty important, that I have no idea what to do about. Any help would be appreciated. Ive tried google searching but its all very vague answers that just says "use arrays" or something like that. Im not looking for someone to give me something to copy paste, just something solid to point me in the right direction.

Code Segment One: execute_string()
The code for room switching, which is when you intersect borders the variables mapX and mapY change accordingly. The room order doesnt matter this way making it dynamic and open world, and the old code used to look very simple. a room name would be something like rm_5_5; and now this code does not work. I have no idea how to keep my room naming system the way it is, as theres 30+ rooms all coded in and mentioned in different parts of code so i would really rather not redo this whole system.

execute_string("room = rm_"+string( mapX )+"_"+string( mapY )+";");

Code Segment Two: screen_redraw()
The game I am making is a large 2D zelda fan project, and this is only used in the text boxes being generated. Im not sure why its in the code(someone else wrote the text box example) and it is not something i fully understand. I feel as if there should be a similar command to this one, I just cannot find anything like it in the manual or google.

Code Segment Three: sound_add()
This is sort of a weird one. My game is getting large. Very large. And i want to minimise things so i dont have 6000 sprites sounds objects etc. One way I had that in GM8.1 was having a folder of all of the sounds and then loading them in and saving them as variables to save on loading time. There is a large script loading in all of my sounds similar to the code below.

global.FireSound = sound_add(working_directory + "\Sounds\FireNoise.wav",0,0)


Any help on these issues would be appreciated, as I do not really understand Game Maker Studio, why the commands were called obsolete or if there is an easy fix for these. Thank you for your time,
-Richard
 
A

Aura

Guest
Welcome to the GMC!

The execute_string() function can be replicated using a string parser. Here's one:

https://forum.yoyogames.com/index.php?threads/551/

As for screen_redraw(), GM:S draws everything to the application surface by default. You can copy its contents to another surface by using surface_copy() if that is what you require it for. Or you can manually draw it the way you draw any other surface.

As for sound_add(), you can use audio_create_stream() but that would limit you to OGG file format only. There are multiple ways of loading sounds dynamically though:

https://forum.yoyogames.com/index.php?threads/1549/#post-12926

You can alternatively use an audio extension, such as FMOD but that would require a lot more effort and changes in the code, so stick to a feasible way for now.
 
A couple of things to expand upon from what @Aura said.

For what you need for room switching, a replacement parser for 'script_execute is overkill. Instead, look into the function 'asset_get_index'.

As for storing data outside the program, the developers no longer recommend doing that, especially for images, as Studio builds all the texture pages when the project is compiled, whereas anything added at run time will be placed on its own texture page and can lead to slowdowns from too many texture swaps. That being said, im pretty sure its still okay, and possibly still beneficial, to load external sounds.

Unfortunately, theres no easy work around for 'screen_redraw'. you may want to research a modern textbox engine written for Studio to learn the correct way to do textboxes now.
 
Top