• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

How do variants/Variables work?

53
Posts
8
Years
    • Seen Aug 25, 2023
    https://www.pokecommunity.com/showpost.php?p=9963746&postcount=8

    I went to this post but did not help me much. Below is the error when I try to make it.

    undefined reference to `VAR_PALLET_TOWN_STATE'

    I am new to scripting on the GBA but I have scripted and can competently script on the GBC and the scripting language is similar between both of them. However I do not not get the issue is.

    #define VAR_DAILY_BP 0x40F1
    #define VAR_WALLY_CALL_STEP_COUNTER 0x40F2
    #define VAR_SCOTT_FORTREE_CALL_STEP_COUNTER 0x40F3
    #define VAR_ROXANNE_CALL_STEP_COUNTER 0x40F4
    #define VAR_SCOTT_BF_CALL_STEP_COUNTER 0x40F5
    #define VAR_RIVAL_RAYQUAZA_CALL_STEP_COUNTER 0x40F6
    #define VAR_PALLET_TOWN_STATE 0x40F7

    Is where the Pallet variant is is in my vars.h so I have no idea what is going on. I am trying to set up a trigger that stops the player from leaving the town without a Pokémon when the VAR_PALLET_TOWN_STATE variable is 0.
     
    53
    Posts
    8
    Years
    • Seen Aug 25, 2023
    That's basically the whole error message.

    PalletTown_OnTransition:
    setvar VAR_PALLET_TOWN_STATE, 0
    end

    Pallet_Town_MapCoordEvents:
    coord_event 9, 0, 0, VAR_PALLET_TOWN_STATE, 0, PalletTown_EventScript_NeedPokemonTriggerLeft

    And this is the only place where it is. I want to make a trigger event to make the player not leave the Pallet Town I made. And to do that I need the Variable to be 0 which is similar to the map scenes on the GBC.

    However it keeps spitting out

    "undefined reference to `VAR_PALLET_TOWN_STATE'"

    Despite the fact that it is vey much defined.
     
    247
    Posts
    6
    Years
    • Seen May 12, 2024

    I would recommend double checking the spelling of your variable everywhere it is used/defined. It's common for a single character that's not supposed to be there to show up, or one character that should be there to be missing.

    Also, where does the error message say that VAR_PALLET_TOWN_STATE is undefined? Does it give an error for both the scripts.inc and events.inc files, or only one of them?
     
    53
    Posts
    8
    Years
    • Seen Aug 25, 2023
    The only place it shows up is in those files (the one that actually defines it it and the script itself) and like here they are all spelled the same with no missing characters. As for the full error message.

    arm-none-eabi-ld: data/map_events.o: in function `Pallet_Town_MapCoordEvents':
    (.rodata+0x70fa): undefined reference to `VAR_PALLET_TOWN_STATE'
    Makefile:343: recipe for target 'pokeemerald.elf' failed
    make[1]: *** [pokeemerald.elf] Error 1
    Makefile:361: recipe for target 'debugging' failed
    make: *** [debugging] Error 2

    This is what it says. So I am trying to figure out why its not compiling as this is my first time scripting on the GBA games. However trying to figure out why its "undefined" Clearly its defined.
     
    53
    Posts
    8
    Years
    • Seen Aug 25, 2023
    I commented out this

    PalletTown_OnTransition: @ 81E7DDB
    @setvar VAR_PALLET_TOWN_STATE, 0
    end

    And now it woks. Still trying to figure it out how variables work for making scene scripts or trigger events.
     

    Lunos

    Random Uruguayan User
    3,114
    Posts
    15
    Years
  • Is it possible that maybe you have 2 different copies of Pokeemerald, and you defined the variable (not "variant" btw, that makes no sense) in the wrong one?
    Because yes, a variable simply needs to be defined in include/constants/vars.h in the same way you showed in the main post, and then you can use it normally.
     
    Back
    Top