• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • 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.

[Other✓] Level Scripts and Setvars Questions and Issue

CosmicBlazer

Batman
  • 190
    Posts
    12
    Years
    Alright, I got my first level script working, but the problem is that it keeps activating. i have setvar 4000 0x1 used.

    Spoiler:



    Second, "So, if we take the situation above where we had the var as 0x4050 and the value at 0 and we don't want the script to run again, simply add this to the end of your script. setvar 4050 0x1" quoted from the Flags,Vars and Script Tutorial thread. I did this except had 4000 has the var, but it keeps activating.

    Third (sorry last one xD) quoted from the same thread "Vars are like the X in math. They can be anything up to 0xFFFF which is a little over 65,000. Like flags, they are used to track progression throughout the game, but they are also used to store information."

    Does this imply that I could use the var 4000 as many times?
     
    You've set 0x4000 to 0x0 in your script :( needs to he 0x1.

    And no, what that last bit means is that variables have different values. Unlike flags, you can set them to 0x2, 0x3, etc. similar to flags there are also quite a few you can use. Check out karatekid's flags/variables thread for safe variables for flags. :)
     
    I was going to reply with a code fix, but Magic basically said what needs to be done. However there's a bit of the script that I don't understand your reasoning behind:
    Code:
    #dynamic 0x800000
    
    #org @start
    [COLOR="Red"]checkflag 0x82F
    if 0x1 goto @dont[/COLOR]
    applymovement 0x1 @move
    waitmovement 0x0
    msgbox @hi 0x6
    setflag 0x82F
    applymovement 0x1 @do
    waitmovement
    setvar 0x4000 0x0
    release 
    end
    
    [COLOR="red"]#org @dont
    clearflag 0x82F
    release
    end[/COLOR]
    
    #org @move
    #raw 0x62
    #raw 0x11
    #raw 0x13
    #raw 0x13
    #raw 0x4A
    #raw 0xfe
    
    #org @hi
    = Hey hunny. Here are your \n Running shoes.
    
    #org @do
    #raw 0x12
    #raw 0x12
    #raw 0x10
    #raw 0x2
    Why do you check if the Running Shoes have already been set? Once your level script runs once, it won't run again, so you don't need to check anything. Also, even if this format was correct, why would you clear the Running Shoes flag right after activating it? If that happened, you would obtain the Running Shoes and then you would be confiscated of them, so it would make no sense.

    So basically, the parts in red can be deleted as they serve no purpose whatsoever.
     
    I was going to reply with a code fix, but Magic basically said what needs to be done. However there's a bit of the script that I don't understand your reasoning behind:
    Code:
    #dynamic 0x800000
    
    #org @start
    [COLOR="Red"]checkflag 0x82F
    if 0x1 goto @dont[/COLOR]
    applymovement 0x1 @move
    waitmovement 0x0
    msgbox @hi 0x6
    setflag 0x82F
    applymovement 0x1 @do
    waitmovement
    setvar 0x4000 0x0
    release 
    end
    
    [COLOR="red"]#org @dont
    clearflag 0x82F
    release
    end[/COLOR]
    
    #org @move
    #raw 0x62
    #raw 0x11
    #raw 0x13
    #raw 0x13
    #raw 0x4A
    #raw 0xfe
    
    #org @hi
    = Hey hunny. Here are your \n Running shoes.
    
    #org @do
    #raw 0x12
    #raw 0x12
    #raw 0x10
    #raw 0x2
    Why do you check if the Running Shoes have already been set? Once your level script runs once, it won't run again, so you don't need to check anything. Also, even if this format was correct, why would you clear the Running Shoes flag right after activating it? If that happened, you would obtain the Running Shoes and then you would be confiscated of them, so it would make no sense.

    So basically, the parts in red can be deleted as they serve no purpose whatsoever.

    Hehe, I'm still a noob at this stuff but even though I had the clearflag it still gave me the running shoes XD anyway thank you very much. However, i changed it 0x1 but it still resetted the script. This script occurs when I go downstairs from my room. I'm using script type 2 do I need to use another type?
     
    Hehe, I'm still a noob at this stuff but even though I had the clearflag it still gave me the running shoes XD
    The shoes won't be confiscated the first time you run the script. Rather, if it runs a second time, the result of checkflag 0x82F will be 0x1 (true) resulting in the confiscation.
    i changed it 0x1 but it still resetted the script.
    Your AdvancedMap values must be wrong. Care to take a screen shot?
     
    The shoes won't be confiscated the first time you run the script. Rather, if it runs a second time, the result of checkflag 0x82F will be 0x1 (true) resulting in the confiscation.

    Your AdvancedMap values must be wrong. Care to take a screen shot?

    Here you go
     
    So, I tested out your script in a clean ROM and I see what your problem is. The variable you used (0x4000) is appearently already being taken by something else in the game and is constantly being updated.

    Short story-short, I changed your variable to 0x4011 and the script worked as intended and only ran a single time.

    If you want to know which flags/variables are safe to use in your ROM, give this thread a quick read: https://www.pokecommunity.com/threads/302347
    Near the bottom will be the safe vars/flags that you should be using.
     
    So, I tested out your script in a clean ROM and I see what your problem is. The variable you used (0x4000) is appearently already being taken by something else in the game and is constantly being updated.

    Short story-short, I changed your variable to 0x4011 and the script worked as intended and only ran a single time.

    If you want to know which flags/variables are safe to use in your ROM, give this thread a quick read: https://www.pokecommunity.com/threads/302347
    Near the bottom will be the safe vars/flags that you should be using.

    Thank you very much Renegade, it worked now. Yeah that was the thread i was looking at. I don't know why i used 4000. Anyway now when i was reading the safe vars 4011-40FF. I can use 4099? or 40AA? Something like that, it seems dumb but i want to make sure.
     
    Anyway now when i was reading the safe vars 4011-40FF. I can use 4099? or 40AA?
    Yes, variables 0x4011-0x40FF are all safe to use and aren't really being used by the game (in any significant way). So this would include: 4011-4019, 401A-401F, 4020-4029, etc. It's all hexadecimal, so if you don't already know how to count using it, just use the calculator on the right side of XSE.

    So punch in (hex mode) '4019 + 1' and you will get '= 401A'. You can keep using these until you hit 40FF.

    In case it crosses your mind, don't worry about running out of variables because it won't happen. I mean, you have like 200 or 500 flags you can use (forgot exactly how many) and you'll be using them a lot more then variables. In case it ever does occur (where you run out of vars or flags), read this thread to learn how to expand the amount that you can use: https://www.pokecommunity.com/threads/302476
     
    Yes, variables 0x4011-0x40FF are all safe to use and aren't really being used by the game (in any significant way). So this would include: 4011-4019, 401A-401F, 4020-4029, etc. It's all hexadecimal, so if you don't already know how to count using it, just use the calculator on the right side of XSE.

    So punch in (hex mode) '4019 + 1' and you will get '= 401A'. You can keep using these until you hit 40FF.

    In case it crosses your mind, don't worry about running out of variables because it won't happen. I mean, you have like 200 or 500 flags you can use (forgot exactly how many) and you'll be using them a lot more then variables. In case it ever does occur (where you run out of vars or flags), read this thread to learn how to expand the amount that you can use: https://www.pokecommunity.com/threads/302476

    Ok thank you for all your help Renegade
     
    Back
    Top