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

[Other✓] Script tile problem

Red John

Progressing Assembly hacker
  • 137
    Posts
    10
    Years
    Hello guys. I am having some serious problem with script tiles. What i wanted to do is create a script tile in which if you step on, you MIGHT find an item. But i dont understand what var and value i should fill in A-map. If it is zero, the game freezes. If it is something else than the script always happens. I tried compiling the script to an NPC, and it worked fine, so the script is not causing problems. A total n00b here :P
     
    Well, if you want it to be a one-time only event, then you'll either have to use vars or flags for that. For now, I suggest you use flags. There are scripting tutorials in the tutorials section for that.

    Anyway, on A-Map, set the [Unknown] and [Var Number] to 0003 and 4000 respectively.
    Spoiler:

    And then add a check and set flag commands into your script.
     
    Well, if you want it to be a one-time only event, then you'll either have to use vars or flags for that. For now, I suggest you use flags. There are scripting tutorials in the tutorials section for that.

    Anyway, on A-Map, set the [Unknown] and [Var Number] to 0003 and 4000 respectively.
    Spoiler:

    And then add a check and set flag commands into your script.

    Flags might be a tiny bit easier to understand, but you'd be better off using a var.
    Here's the thing
    Var is short for Variable. A variable's purpose is to hold a value to later be checked.
    For example, you have a script in which you have to choose either Charizard or Blastoise.
    If you choose Charizard you give the var a value of 1.
    If you choose Blastoise then you give the var a value of 2.
    In a later script, you check the var too see wheter the var is at 0x1 or at 0x2
    Now, in this specific case, what you do is that you set a var and a value to a script tile. If the box in amap for value has 1, and the var number 4050, the script will only run if the var 4050 has a value of 1
    With that said, if you dont change the value of the var before the player steps on the script tile, the script wont happen
    Now let's say that in some script you assigned 0x1 to 0x4050
    Now, when you step in the tile the script will run
    Now, if at the end of the script you put setvar 0x4050 0x2, the value of the var will now be 2, and the script wont happen once you step on the script tile
    Hope I helped and didn't sound confusing.
    (closing notes, all vars are 0 before any changed has been applied to them, and safe variables range between 4011 and 40FF)
    EDIT: forgot to say, you also don't need to put 0003 in the unknown box in amap, it does the same as not putting anything
     
    I am not that much n00b -_- i know what they do and i know how to work with them. But the problem is i dont understand how to make them work on a script tile. I used random 0xa so and compared lastresult with 0x2 and if it matches than u get an item. It works at NPC but not on tiles
     
    I am not that much n00b -_- i know what they do and i know how to work with them. But the problem is i dont understand how to make them work on a script tile. I used random 0xa so and compared lastresult with 0x2 and if it matches than u get an item. It works at NPC but not on tiles

    Alright then, I guess I'll just try to get back the 7 hours of my life it took me to write that reply ;.;
    You wanna send your script? I'm sure we can make it work
     
    OK here it is
    Spoiler:

    ...as I mentioned, use these values on your script tile.
    Spoiler:

    ...or if you're using FireRed, try using [4050] instead of [4000] on the Var number.

    And I suggest you add flags on that script so it won't repeat itself.
    Like so...

    Code:
    #dynamic 0x7200000
    
    #org @start
    [COLOR="Red"]checkflag 0x200
    if 0x1 goto @done[/COLOR]
    random 0xA
    compare lastresult 0x2
    if 0x1goto @giveit
    end
    
    #org @giveit
    giveitem 0xd 0x1 MSG_FIND
    [COLOR="red"]setflag 0x200[/COLOR]
    end
    
    [COLOR="red"]#org @done
    end[/COLOR]

    But I suggest you check scripting tutorials and see which flags are free to use for your ROM~
     
    One thing that should be added to what Destinedjagold said is that when you have a green script tile, you HAVE to use a var. I've tried, it doesn't do anything otherwise. To do that, you just need to put

    "setvar 0xYYYY 0xZ"

    The Ys being what variable you choose, and the Z being any number that ISN'T what you put in the "Unknown" box in advance map. I don't know exactly how it works, but I know that if "Z" is the same as what you put in the "Unknown" box, it won't work.

    If you use this method to prevent your script from running again, then flags are unnecessary unless you're using them for something else in the script, such as a sprite disappearing. When you step on the tile again, and have done the process of setting the variable correctly, nothing will happen.
     
    So, I tried your script on my ROM, and after a couple edits I was able to get it to work.

    For the record, I was using PKSV, but XSE should be similar (but with different commands possibly. Giveitem wasn't recognized in PKSV so I replaced it with additem)

    Here's what I did (the important parts highlighted in red):

    #dynamic 0x720000
    #org @start
    random 0xa
    compare lastresult 0x2
    if 0x1 jump @giveit
    jump @end

    end

    #org @giveit
    additem POTION 0x1
    message @find
    callstd MSG_SIGN
    fanfare 0x102
    waitfanfare

    setvar 0x4000 0x0
    end

    #org @end
    release
    setvar 0x4000 0x0
    end


    #org @find
    = \v\h01 found a POTION!

    I basically added another script for it to go to when you don't find the item. When I didn't have this it just froze, so I recommend putting it in for safety. You need to put the "setvar" in both the "give it" script and the "end" script.

    Also I couldn't get the "MSG_FIND" thing to work right. It just gave me weird text. So I made a separate message for it. I have no idea if the MSG_FIND works for you, so you can disregard it too.

    Also, to have the script run over and over, you just set the "Unknown" value to the same thing that you set the variable too.

    I also put in a fanfare, to make it sound more professional. You can use this or not.
     
    Yes, nothing happens when i step on it, i know it is random, but it should happen 1 out of 10 times, but it doesn't

    Ok, here's what. Put this in your script tile:
    Code:
    #dynamic 0x720000
    
    #org @start
    lock
    giveitem 0xd 0x1 MSG_FIND
    release
    end

    If you recieve your item, then the problem is your script.
    If it doesn't work, you just failed at following our instructions :P
     
    One thing that should be added to what Destinedjagold said is that when you have a green script tile, you HAVE to use a var. I've tried, it doesn't do anything otherwise. To do that, you just need to put

    "setvar 0xYYYY 0xZ"

    The Ys being what variable you choose, and the Z being any number that ISN'T what you put in the "Unknown" box in advance map. I don't know exactly how it works, but I know that if "Z" is the same as what you put in the "Unknown" box, it won't work.

    If you use this method to prevent your script from running again, then flags are unnecessary unless you're using them for something else in the script, such as a sprite disappearing. When you step on the tile again, and have done the process of setting the variable correctly, nothing will happen.
    "I know that if "Z" is the same as what you put in the "Unknown" box, it won't work."
    IIRC the Unknown box doesn't have anything to do with "Z". In a script tile, you're basically saying "If the value in this variable is equal to Z, run the script". Z is by default 0. Since most of the unknowns in FR are 3 , I'm assuming you did "setvar 0xYYYY 0x3" or something like that sometime during your hacking career, which wouldn't have made the script run unless you had set the value of var 0xYYYY to 3 before you stepped on the green tile.
     
    The whole entire "setvar" concept is pretty new to me, actually. I just know that when I did the script I posted before, I had "Z" be the same as what I set the var to, which caused the script to run every time I stepped on the tile. Setting the variable to something not in the unknown box is like setting a flag, but slightly more complicated.
     
    The whole entire "setvar" concept is pretty new to me, actually. I just know that when I did the script I posted before, I had "Z" be the same as what I set the var to, which caused the script to run every time I stepped on the tile. Setting the variable to something not in the unknown box is like setting a flag, but slightly more complicated.
    I'm going to correct you there: Setting the var to something not in the var value box is like setting a flag. The unknown box doesn't have anything to do with setting vars. In your script, you made 0xZ equal to 0x0 right? Which was equal to the number in the var value box right? That's why the script runs every single time. If Z is equal to the var value, the script will run. If it's not, the script won't run. That's why people make their 'Z' value something other than 0 when they want their script to run only once. The var value is 0 by default, so setting 'Z' to something other than 0 after you're done with your script will make it so that the script won't run again.
    EDIT: This is probably derailing the purpose of the thread right here, so I'm going to stop here.
     
    Back
    Top