1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GM:S 1.4 Check if object has creation code

Discussion in 'Programming' started by xxTheFryxx, Dec 4, 2019.

Tags:
  1. xxTheFryxx

    xxTheFryxx Member

    Joined:
    Dec 4, 2019
    Posts:
    6
    I have an object and I need to check to see if it’s been given creation code, otherwise it sets a variable. How can I go about this?
     
  2. Homunculus

    Homunculus Member

    Joined:
    Jun 20, 2016
    Posts:
    817
    The creation code is run after the create event, can't you just set the variable in the create event and overwrite it in the creation code instead?
     
  3. xxTheFryxx

    xxTheFryxx Member

    Joined:
    Dec 4, 2019
    Posts:
    6
    I tried this, but it seems the creation code runs before the create event.
     
  4. Homunculus

    Homunculus Member

    Joined:
    Jun 20, 2016
    Posts:
    817
    The creation code is definitely run after the create event. If you find some variables are not the way they should be, there may be something else going on (like some code in the room start event or step that changes those values).
    You can check the above by adding a show_debug_message in both events and look for the resulting order in the console, if you are unsure.

    Can't really help you more than this without the actual code or more details.
     
    TsukaYuriko likes this.
  5. TsukaYuriko

    TsukaYuriko Q&A Spawn Camper Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    1,766
    The creation code runs before the Create event in old versions - pre-Studio, if memory serves me right. Any version that's not 5 years old should run the creation code after the Create event.
     
    Yal and Homunculus like this.
  6. xxTheFryxx

    xxTheFryxx Member

    Joined:
    Dec 4, 2019
    Posts:
    6
    I’m running 1.4
     
  7. xxTheFryxx

    xxTheFryxx Member

    Joined:
    Dec 4, 2019
    Posts:
    6
    It’s 1.4, I mean it would be very nice if the create event came after but on my version it sadly just doesn’t. Is there any workaround?
     
  8. TsukaYuriko

    TsukaYuriko Q&A Spawn Camper Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    1,766
    o_O

    If this isn't working on your end, there might be a problem with how your project is set up. Please post all relevant code and how you're checking when which event runs, as there should be absolutely no way for the Create event to run after the creation code.
     
  9. Homunculus

    Homunculus Member

    Joined:
    Jun 20, 2016
    Posts:
    817
    TsukaYuriko likes this.
  10. YellowAfterlife

    YellowAfterlife ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    2,442
    For a workaround you could have a controller object call event_user() on all object types of interest and process variables there
     
  11. TsukaYuriko

    TsukaYuriko Q&A Spawn Camper Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    1,766
    A workaround should not be necessary, though, as the event order of these two was changed specifically to accommodate for this exact situation - setting a variable in the Create event to a default value with the option to override in the instance creation code.
     
  12. Homunculus

    Homunculus Member

    Joined:
    Jun 20, 2016
    Posts:
    817
    I can think of a few workarounds, but I’m always wary of workarounds for code that should not be broken to begin with, you may potentially end up treating the symptoms without addressing the cause
     
  13. xxTheFryxx

    xxTheFryxx Member

    Joined:
    Dec 4, 2019
    Posts:
    6
  14. xxTheFryxx

    xxTheFryxx Member

    Joined:
    Dec 4, 2019
    Posts:
    6
    Okay so I took a look. Thank you all for your info and help, I managed to get it working.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice