Jump to content


Photo
- - - - -

Instance Creation Code


  • Please log in to reply
100 replies to this topic

#31 Blue_Ninja_Frog

Blue_Ninja_Frog

    GMC Member

  • New Member
  • 304 posts

Posted 07 April 2007 - 02:13 AM

Okay, question. Exactly WHEN do the actions in the Instance Creation Code get executed? In order to use this properly I will need to know this.
  • 0

#32 Chronic

Chronic

    Administrator

  • Global Moderators
  • 2729 posts
  • Version:GM:Studio

Posted 07 April 2007 - 09:07 AM

All i know is that its sometime before the instances create event. You'll have to do your own tests to see if anything is ran any earlier if required.
  • 0

#33 Daniel-Dane

Daniel-Dane

    GMC Member

  • New Member
  • 3581 posts

Posted 07 April 2007 - 09:37 AM

Okay, question. Exactly WHEN do the actions in the Instance Creation Code get executed? In order to use this properly I will need to know this.

<{POST_SNAPBACK}>

Why didn't you test it first?

Here is the order: (GM7)
1. Creation code
2. Create event
3. Game start event
4. Room start event
  • 0

#34 Jenner

Jenner

    Jenner

  • GMC Member
  • 904 posts

Posted 07 April 2007 - 09:54 AM

Thanks a lot Chronic, you just made my life a lot easyer. Please if you have more tricks like this one POST IT!
  • 0

#35 Grego

Grego

    GMC Member

  • New Member
  • 1155 posts

Posted 07 April 2007 - 11:32 AM

First, in the current room (if any) all instances get a room-end event. Next the non-persistent instances are removed (no destroy event is generated!).
Next, for the new room the persistent instances from the previous room are added.
All new instances are created and their creation events are executed (if the room is not persistent or has not been visited before).
When this is the first room, for all instances the game-start event is generated.
Now the room creation code is executed.
Finally, all instances get a room-start event.


Is that what you meant about the order..?
  • 0

#36 PLAY: More

PLAY: More

    Press F8 to enter BIOS

  • New Member
  • 824 posts

Posted 07 April 2007 - 11:53 AM

All i know is that its sometime before the instances create event. You'll have to do your own tests to see if anything is ran any earlier if required.

<{POST_SNAPBACK}>

I think it's after the Room Start but before Instance Create event.
  • 0

#37 Blue_Ninja_Frog

Blue_Ninja_Frog

    GMC Member

  • New Member
  • 304 posts

Posted 07 April 2007 - 04:24 PM

In my experiences with it, It runs before the create event which became a bother due to unknown variables and the like >.>
  • 0

#38 Splayer

Splayer

    GMC Member

  • New Member
  • 130 posts

Posted 17 April 2007 - 04:09 AM

Wow! Someone sticky this now! You have no idea how many problems this solves that i've had in the past. Thank you so much!
  • 0

#39 Igl00

Igl00

    GMC Member

  • New Member
  • 327 posts

Posted 19 April 2007 - 12:37 PM

Hmm... Why is it, that almost all the ppl here on GMC, didn´t knew that function? It was, kinda the first thing i learned, when i decided to start coding... Weird!
  • 0

#40 dark_master4

dark_master4

    GMC Member

  • GMC Member
  • 1220 posts
  • Version:GM:Studio

Posted 19 April 2007 - 01:32 PM

I knew this function existed 'cause I did read the whole manual... But I don't know why, I kinda forgot to use it because of everything I was learning at the same time. You tut is well done and did remind me this existed and I'll definetly use it in the futur, if needed.
  • 0

#41 >Leroy222<

>Leroy222<

    GMC Member

  • New Member
  • 473 posts

Posted 21 April 2007 - 07:07 AM

Nicely written. I didnt know about this!

I must question the usefulness of the feature, however. Wouldn't it be better to use parents so you dont need to add creation code multiple times??
  • 0

#42 Jenner

Jenner

    Jenner

  • GMC Member
  • 904 posts

Posted 21 April 2007 - 01:39 PM

Is there anyway you can check if a local variable exists in another object? Without useing the with function?

Something like this:
object0 CREATION:
if object1.variable_local_exists("name") {fhspeed=2}
  • 0

#43 Dinsdale

Dinsdale

    GMC Member

  • New Member
  • 1389 posts

Posted 21 April 2007 - 08:47 PM

.....I never knew. 3 years, I never knew.
Is it me or is this not in the manual.
  • 0

#44 Chronic

Chronic

    Administrator

  • Global Moderators
  • 2729 posts
  • Version:GM:Studio

Posted 21 April 2007 - 11:37 PM

Is there anyway you can check if a local variable exists in another object? Without useing the with function?

Something like this:
object0 CREATION:
if object1.variable_local_exists("name") {fhspeed=2}

<{POST_SNAPBACK}>


This is untested but try using with(), for example

with(otherObject) {
  if variable_local_exists("name") {fhspeed=2}
}

  • 0

#45 LegacyCrono

LegacyCrono

    GMC Member

  • GMC Member
  • 616 posts

Posted 22 April 2007 - 11:55 AM

I remember that I found it a long time ago, when I didn't knew GML at all, so I think I just forgot that... ^^

This is very useful for RPGs and what-not. You don't need to make hundreds of different obj_treasure, just make a single obj_chest and use Creation Codes! :) Great, I just want to try it right now! xD


SEE YA!!!!!
  • 0

#46 Serprex

Serprex

    GMC Member

  • New Member
  • 48 posts

Posted 22 April 2007 - 05:27 PM

Great how many people don't know about this,its a key part of lowering the number of objects I have.I'd like it if it were made easier to access and stuff.CTRL+Rclicking and copy pasting gets hard when almost every object needs a creation code with minor tweaks and stuff
I found it reading the panel in the room creator
  • 0

#47 Jenner

Jenner

    Jenner

  • GMC Member
  • 904 posts

Posted 22 April 2007 - 06:01 PM

Is there anyway you can check if a local variable exists in another object? Without useing the with function?

Something like this:
object0 CREATION:
if object1.variable_local_exists("name") {fhspeed=2}

<{POST_SNAPBACK}>


This is untested but try using with(), for example

with(otherObject) {
  if variable_local_exists("name") {fhspeed=2}
}

<{POST_SNAPBACK}>

hmm.. without with() ^_^
Anyways, I could use with(), but the problem is, that now the otherObject.fhspeed that changes, not mainObject.fhspeed
  • 0

#48 PL productions

PL productions

    GMC Member

  • New Member
  • 80 posts

Posted 22 April 2007 - 10:59 PM

Impressive... I have been in the dark to this function for so long. I never knew it existed. This will be useful in such things as RPG computers, or in room to room transfer.
  • 0

#49 jengajam

jengajam

    GMC Member

  • GMC Member
  • 522 posts

Posted 23 April 2007 - 09:05 PM

Thank you so Much! This will help me so much on my Rpg!
  • 0

#50 Games

Games

    GMC Member

  • Banned Users
  • 2968 posts

Posted 24 April 2007 - 11:47 PM

Very, very cool! This is a great answer to my current dilemma! What a strange coincidence! :P

#51 Jabberwock

Jabberwock

    GMC Member

  • New Member
  • 218 posts

Posted 30 April 2007 - 10:50 PM

I recently stumbled across this feature myself by accident. At first it didn't seem useful, but I think it could have some application with a dilemma I've been having in Mekanos - trying to make objects which can only be gotten once without having to make every room persistent.
  • 0

#52 Power-up

Power-up

    GMC Member

  • New Member
  • 465 posts

Posted 02 May 2007 - 12:42 AM

I've known about this for quite a while and use this and also the room creation code as well all the time, especially in SMTSG. I use it for things such as telling the item boxes what item to have and telling my doors which room to go to as well as what x and y Mario should be at in the new room.
  • 0

#53 Azure

Azure

    GMC Member

  • New Member
  • 1217 posts

Posted 04 May 2007 - 03:36 AM

I truly doubt that many people even knew that you could define an object like that. That's really handy when it comes to specifics. :D Thanks, man!

~ Axias
  • 0

#54 Aqua Pyro

Aqua Pyro

    ^ Self Portrait ^

  • New Member
  • 649 posts

Posted 16 May 2007 - 10:30 PM

Wow, I never knew this. This will be really helpfull, sinse I have a heck of a lot of objects used for one event that aren't even visable.
Thanks!
~Aqua
  • 0

#55 lachlan438

lachlan438

    GMC Member

  • New Member
  • 64 posts

Posted 25 May 2007 - 01:21 AM

That is so cool :) :D :ph34r:
  • 0

#56 Blastoiseiii

Blastoiseiii

    GMC Member

  • GMC Member
  • 322 posts

Posted 30 May 2007 - 07:23 PM

Creation code can be very powerful, but it also can make a game unwieldy. My memory ain't so hot, and my games tend to end up large and room spanning, so remembering what object gets what code can be very difficult. Checking creation code for many objects can be rather laborious, so try to limit how much code you have to have per object. Whenever possible, I'd suggest generalizing.
  • 0

#57 Sahaqiel

Sahaqiel

    GMC Member

  • New Member
  • 211 posts

Posted 01 June 2007 - 07:08 PM

Aw! Thanks! For the love of God, I was looking for something like this all around scripts, codes, whatever! I needed something like this! You're now the Awesomeness of All Creation.
Weeeooooo....
Sahaqiel
  • 0

#58 spliter

spliter

    GMC Member

  • New Member
  • 80 posts

Posted 02 June 2007 - 12:07 PM

whoa, a VERY useful function! If only I had know it before... like for the last 4 years I had to use exported files (I will probably still use them, I prefer my way of doing things) but funny how for last 4 years I used gm and only today I got to know this O_o
maybe I should search answers in more than just code.
Great thanks!
  • 0

#59 isjoeythere

isjoeythere

    GMC Member

  • New Member
  • 137 posts

Posted 03 June 2007 - 04:53 AM

The instance specific quality is amazing. Thanks!

Ooh, this will be so useful for staircases.
  • 0

#60 rayquazadude

rayquazadude

    GMC Member

  • New Member
  • 233 posts

Posted 18 June 2007 - 01:54 AM

Is there a way to modify creation code in GML, while the game is running? I want to make a level editor in a game that I'm working on and I need to use creation code with the functions for creating a room/objects/tiles in-game.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users