• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [solved] access instance creation code?

R

Rukola

Guest
Is there any way to access instance creation code?

I'm using my own room loading system and this prevents the instance creation code from happening. I don't think I can event_perform() it either.

My best guess is to use scripts and save the creation code in a reference number..
Code:
///instance creation code for object buttons
switch(argument0){
case 0:
    object_track = objPlayer;
    break;

case 1:
    object_track = objStorm
    with(objDoor) open=1;
    break;
}
But this isn't fun to work with in a large project.
 
C

CaffeineJunky

Guest
make your create event do the bare minimum. create a script or multiple scripts that will create an object and set values on it.
 
R

Rukola

Guest
I'm not really getting what you're trying to say :(

This is an example of my instance creation code. How could I best access / save / use this if the instance_creation_code isn't available?

 

jo-thijs

Member
I tested it and event_perform won't offer the solution indeed.
It sounds like your best guess would be my best guess as well.
Altough, I am curious about how you're loading rooms so that instance creation codes are ignored.
 
R

RealsLife

Guest
///instance creation code for object buttons
switch(argument0){
case 0:
object_track = objPlayer;
break;

case 1:
object_track = objStorm <- use ;
with(objDoor) open=1; <- better use { and } to be sure
break;
}

//---DUTCH answer---//

Wat wil je nu eigenlijk doen ik snap er niets van :a... In ieder geval ik haat het om de creation code te gebruiken dan heb ik liever de object create event of room start event :eek:...
 
R

Rukola

Guest
I tested it and event_perform won't offer the solution indeed.
It sounds like your best guess would be my best guess as well.
Altough, I am curious about how you're loading rooms so that instance creation codes are ignored.
I'm loading my rooms next to each other 'real time'. I still use GameMakers room editor. Instead of
loading these, I save the room to an .ini file and load those in one room: rmPlay. I do this so my AI can
move between rooms accurately.

As your guess is similar, I'll just organise it neatly. One script for each object that has multiple creation codes :)

Ik denk dat je nederlands praat dus voorruit maar... :p waar zit die instance creation code voor buttons nu net?
Klopt! The instance creation code is located in the rooms.



You can use the room creation code for e.g. buttons! Check it out.
 
Last edited by a moderator:
R

RealsLife

Guest
I'm loading my rooms next to each other 'real time'. I still use GameMakers room editor. Instead of
loading these, I save the room to an .ini file and load those in one room: rmPlay. I do this so my AI can
move between rooms accurately.

As your guess is similar, I'll just organise it neatly. One script for each object that has multiple creation codes :)



Klopt! The instance creation code is located in the rooms.



You can use the room creation code for e.g. buttons! Check it out.
Yes I know you also have the creation code not on objects but in the room itself but I don't like to use it, everything becomes a mess. Also I've seen the video before and even that dude says he has found a better way of doing things. For your game or at least the style you want it to be you can maybe use somthing similar like "The Legend Of Zelda" uses
 
Anytime I need to programmatically fake instance creation code, I wrote a constructor script for it. Example:

Code:
/// textbox_create(x, y, text, color);

var x1 = argument[0],
    y1 =argument[1],
    txt = argument[2],
    col = argument[3];

var inst = instance_create (x1, y1, obj_textbox);

with (inst)
{
    text = txt;
    color = col;

    textbox_init(); // This replaces the create event
}

return (inst); // If you need to track the instance ID created with the script
Apologies for the random typos. I'm on my phone.

Edit: Cleaned up the code and added returning of the instance ID.
 
Last edited:
R

Rukola

Guest
Ok you guys. I'm going for these conductor scripts as well. Thanks for the replies <3
 
Top