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

GML unassigned Variable (RTS turn base game)

Discussion in 'Game Design, Development And Publishing' started by aggro, Sep 1, 2019.

  1. aggro

    aggro Member

    Joined:
    Sep 1, 2019
    Posts:
    2
    Hey all

    Ive been following Talent Lost tutorial on making a RPG turn base game.
    Most of the guide works. But when it comes to making creating a control object code, I get a
    "unassighned variable states referenced"
    Link to vid:
    @ 16:41 of the video.

    I have basically followed the video step by step. Only difference is that, he is using the older version of GameMaker.

    I created 2 events within the Object, Create & Step.
    The coding for Create is...

    /// @description object control
    global.state = states.p_turn;
    global.selected = noone;

    and for the Step...

    /// @description state control
    switch (global.state)
    {
    case states.p_turn: scr_state_player_turn(); break;
    }

    Exactly the same as how Talent Lost has set it up. But it wont compile due to the event errors.

    Cheers in advance
     
  2. aggro

    aggro Member

    Joined:
    Sep 1, 2019
    Posts:
    2
    Hey all.

    I managed to fix the intial error but now within the Object control events; Step:
    I am getting another error saying "variable states only referenced once"

    code...


    /// @description state control
    switch (global.state)
    {
    case states.p_turn: scr_state_player_turn(); break; < Line with error
    }

    I have tried rewriting the scr and no change.
    The scr has no errors within itself.

    cheers in advance
     
  3. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    4,214
    It looks like "states" is an enum from context, do you create it properly? Or did you solve it by making it a global variable?
    It looks like you could solve this by just adding another case in the switch statement (a dummy if needed) so that you refer to it twice, in either case.
     

Share This Page