[ 2 posts ]  Reply to topicPost new topic 
Author Message
 [zz]
 Post subject: Specific question regarding a work-around for execute_string
PostPosted: Mon Mar 30, 2015 3:09 pm 
User avatar
Lucario and/or Braixen = best avatar
Member
[*]
[*]
[*]
[*]
[*]

I posted this in the GMC, but I figured chances of finding a solution would come quicker if I shared this here as well. I've been looking around the internet for an answer, and while I've found some answers that have been useful, I have yet to find an answer to a specific question regarding a work around for execute_string in GMStudio, and I'm honestly stumped as to how I can find a work around.

I know you can use data structures to change variables, but what if you want a specific object or objects to perform a specific set of actions? For example, in a previous project I worked on, I had cutscene objects make characters or other objects perform specific actions, like make them move around or create an instance at a certain position and make the created object set a variable in itself, like a flag to stay with the player, to true, using the cutscene object's creation code.

Here's the above example explained with a little more detail:

In SMBOdyssey Ch.2, and in the cutscene object's creation code, I told it to call a script that went to execute_string and created a speech bubble at Mario's position, but Mario was walking and the speech bubbles are stationary by default, so I told it to set it's flag to stick with a specific cutscene character to true, and set a variable in the speech bubble that told it to stick to Mario's instance ID's position. The code was a little messy (particularly as I hadn't learned of some better methods of doing things), but it looked like this:

in obj_cutscene's creation code in the room:

Code:
cs_code("speechbubble = instance_create(0,0,obj_speech_exclamation); speechbubble.stickwithplayer = true; speechbubble.character = (151449)")


Here's a few more examples of how I used it if anyone needs a bit of a better idea:

Spoiler:


cs_code:

Code:
ds_list_add(list,"Code");
ds_list_add(list,argument0);


The code above added the string of code from cs_code to a list that the cutscene controller object went down to see what actions it should perform next. The string "Code" in the first line would be used by the cutscene controller in a switch statement to see what type of action it was performing. In the cutscene controller object, in the switch statement I mentioned above was this:

Code:
case "Code":
     execute_string(ds_list_find_value(list,0));
     ds_list_delete(list,0);
     break;


the string of code from the cutscene object's creation code in cs_code is executed here and is then removed from the list to prevent the list from becoming too large and eventually crashing the game.

This was able to save me a lot of time, especially as I never was able to find a work-around, but now that I'm using GMStudio and this feature is absent, I need a work around for this. I've searched and searched but I just can't figure it out.

Any advice?

_________________
Games I've made:

Spoiler:

Fangame(s) I support:
Spoiler:


You can find me on:
Image Image Image Image Image


These are my Smashers of choice:
Image
 
Top
Offline 
 
 
 [us]
 Post subject: Re: Specific question regarding a work-around for execute_st
PostPosted: Sat Apr 04, 2015 11:43 am 
User avatar
C# Programmer
Member
[*]
[*]
[*]
[*]
Could you do something with storing functions and parameters in a list or some collection and executing each one in order? You can even have a flag for each function determining whether the action has completed. I'll elaborate later with some examples.

_________________
MFGG TKO (scrapped) - Animations
Image
"It feels that time is better spent on original creations" - Konjak
Focus on the performance, the idea, not the technical bits or details - Milt Kahl
 
Top
Offline 
 
 
« Previous topic | Next topic »
Display posts from previous:  Sort by  
 [ 2 posts ]  Reply to topicPost new topic 


Who is online

Users browsing this topic: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group