• 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.

[Script✓] [Emerald] Items as HMs: Checkitem doesn't seem to work

McPaul

On my way to become a controversial and hated memb
  • 289
    Posts
    7
    Years
    Here is the first script I made:

    '---------------
    #org 0xE3CFBC
    lockall
    checkflag 0x867
    if 0x0 goto 0x8290721
    checkitem 0x167 0x1
    compare LASTRESULT 0x6
    if 0x1 goto 0x8290721
    setanimation 0x0 LASTRESULT
    bufferitem 0x0 0x167
    checkitem 0x167 0x1
    msgbox 0x829072E MSG_YESNO '"This tree looks like it can be\ncu..."
    compare LASTRESULT 0x0
    if 0x1 goto 0x829072B
    msgbox 0x8290771 MSG_KEEPOPEN '"[player] used [buffer1]!"
    closeonkeypress
    doanimation 0x2
    waitstate
    goto 0x8290710

    '---------------
    #org 0x290721
    msgbox 0x829077D MSG_KEEPOPEN '"This tree looks like it can be\ncu..."
    releaseall
    end

    '---------------
    #org 0x29072B
    closeonkeypress
    releaseall
    end

    '---------------
    #org 0x290710
    applymovement LASTTALKED 0x829071F
    waitmovement 0x0
    hidesprite LASTTALKED
    releaseall
    end


    '---------
    ' Strings
    '---------
    #org 0x29072E
    = This tree looks like it can be\ncut down!\pWould you like to use [buffer1]?

    #org 0x290771
    = [player] used [buffer1]!

    #org 0x29077D
    = This tree looks like it can be\ncut down!


    '-----------
    ' Movements
    '-----------
    #org 0x29071F
    #raw 0x5B 'mov5B
    #raw 0xFE 'End of Movements


    The problem is that I can cut trees even if I don't have the item 0x167 in my bag despite using the checkitem command. Why is this happening? Did I do wrong somewhere?

    Thanks for your answers.
     
    Last edited:
    Here's a version of your script that will work:

    Spoiler:


    Your issue stemmed these three lines in your original script:
    checkitem 0x167 0x1
    compare LASTRESULT 0x6
    if 0x1 goto 0x8290721

    The checkitem command works by comparing the number of a specified item that you have to a chosen value (in this case, 0x1). If you have that many of the item or more, 0x800D is set to 0x1, if you have less, its set to 0x0. The compare line is then completely wrong, as 0x800D will never have 0x6 as a value from the previous command. This run on also breaks the if command as it will always be false, allowing the script to continue regardless as to whether you have the item or not.

    Whenever you're making a script, I'd highly suggest that you use dynamic pointers. It ensures that you don't overwrite anything in the ROM by accident and if you're trying to get help here, its easier for others to follow the script's structure.
     
    Back
    Top