1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 Variable Definition not reading

Discussion in 'Programming' started by William Garrison, Nov 8, 2019 at 12:31 PM.

  1. William Garrison

    William Garrison Member

    Joined:
    Apr 16, 2019
    Posts:
    50
    Okay, so I have this in the creation code...
    Code:
    s_default = sTestBlock;
    
    sprite_index = s_default;

    and this in the variable definitions...

    [​IMG]

    and in the room this is what I set it to...

    [​IMG]

    Yet it doesn't seem to read the variable definition in the room. I change the variable to a different sprite via the variable definition but it still remains on the test block as set in the creation code.
     
  2. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,960
    Variable definitions are compiled and run on the instance BEFORE the create event, so the create event code is overriding what you have in the variable definition.
     
  3. William Garrison

    William Garrison Member

    Joined:
    Apr 16, 2019
    Posts:
    50
    Okay so what I want to do is have an object that I can set the sprite index on inside of the room but different sprites on multiple instances of the same object. Is this not achievable with variable definitions? I see people all the time setting something to say "0" in their create then using a variable definition to change the integer. Works for that, why not this? And how do i?
     
  4. William Garrison

    William Garrison Member

    Joined:
    Apr 16, 2019
    Posts:
    50
    I figured it out. I just removed the...
    Code:
    s_default = sTestBlock;
    from the creation code -- XD
     

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