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

Basics of Scripting

destinedjagold

You can contact me in PC's discord server...
8,593
Posts
16
Years
    • Seen Dec 23, 2023
    ~Understanding the Basics of Scripting~
    by destinedjagold

    Introduction...
    Hello there pipz.
    I'm destinedjagold, the maker of the Ruby Destiny series. This is my first scripting tutorial, so I hope this'll be useful for those who are new to hacking/modding...

    Opening Message...
    Okay, so I have read a comment where scripting tutorials were only understandable by those who already have experience in scripting/hacking.
    So I decided to make a scripting tutorial that hopefully, will be easy to understand for those who are new to the fields of scripting...

    Note...
    • This tutorial is for those who are new to scripting/hacking...
    • This tutorial uses HackMew's XSE tool...


    I. The Syntax of Scripting
    Code:
    #dynamic 0x800000
    
    #org @start
    //commands here
    end
    That's the structure of the script...
    To understand what those are, the commands #dynamic 0x800000 tells XSE where it'll store/write the script in your ROM.
    #org @start is the beginning of your script. It's like a
    front cover of a book. @start should not have any duplicates... It tells XSE that the script starts there.
    The commands will be discussed later on...
    And every book has a back cover, and that's what end is. It tells XSE that your script ends there.


    II. A Simple Talking Script
    Code:
    #dynamic 0x800000
    
    #org @start
    lock
    faceplayer
    message @1 0x6
    release
    end
    
    #org @1
    = Hello World!
    In the example script, you can then see that I have added some commands to our little script. Let's discuss the commands...
    • lock - It locks the PLAYER in place...
    • faceplayer - It makes the NPC face you if you talk to him...
    • message - tells XSE that a message box will show up containing texts...
    • @1 - the address of the message (remember that there shouldn't be any duplicates of any adress)
    • 0x6 - a message type. This is just an ordinary message...
    • release - tells XSE to unlock the PLAYER, so he can move again...


    III. Addresses
    And now, we have an address... If you recall, one of our commands in the example script is message @1 0x6 where @1 is an address of your message command.

    Code:
    #org @1
    = Hello World!
    What does address mean in scripting?
    • It tells XSE where to locate your messages, movements, or continuation scripts...
    So, since you're the one scripting, you are telling XSE where your message is...


    IV. Flow of Scripting
    How does the ROM read the script?
    Well, just like us, we read from top to bottom. The same towards scripts. XSE reads it from top to bottom...
    Code:
    #dynamic 0x800000
    
    #org @start
    lock
    faceplayer
    message @1 0x6
    release
    end
    
    #org @1
    = Hello World!
    In this example script, XSE will start reading the script from the top, towards the bottom. So it first reads the #dynamic 0x800000.
    Let's not discuss about how XSE searches for free space... This is a scripting tutorial, anyways...
    The script will be read in a top-bottom method. So...
    1. lock will be read first, which locks the PLAYER in place...
    2. faceplayer is read next, where the NPC will face the PLAYER...
    3. then the message...
    4. since the message tells the script a location address of it's content, it goes to the address, which is #org @1, and then goes back...
    5. and then the PLAYER's released...
    6. and the script ended...
    And so, in the game, the script will work like this...
    1. When you talk to an NPC, the PLAYER is locked...
    2. And then, the NPC will face the PLAYER...
    3. And then a message will display...
    4. And then, you are released...
    5. And the script ended...


    [a id]putrom[/a id]
    ~Putting The Script In Our ROM~
    Newly Added - July 26, 2010

    Opening Message...
    Now you understand the basics of scripting. But now comes the question: how to we put it into our ROMs...?
    It's quite simple. Here's a step by step procedure on how to do so...

    Note...
    You will need the following...
    • HackMew's XSE tool...
    • LU-HO's Advance Map tool...

    Step-by-Step Procedure...

    I. Step 1...
    1. Open XSE...
    2. Press CTRL + O or go to 'File' and click 'Open'.
    3. Select your ROM (the one with the .gba extension).
    Spoiler:


    II. Step 2...
    1. Write your script...
    2. After you are done, click the 'gears' icon...
    Spoiler:


    III. Step 3...
    1. After clicking the gear icon, a pop-up will appear...
    2. The first address is usually highlighted first, and is usually the one you'll need.
    3. Click the 'Copy' button...
    Spoiler:


    IV. Step 4...
    1. Open Advance Map, and open your ROM through that tool...
    2. Search for the event that you want your script to be inserted...
    3. Write/paste the offset you copied from XSE onto the event's Script Offset in Advance Map (the '$' symbol should be there)...
    Spoiler:


    And voila~
    You have inserted your script~

    ---o0o---

    Scripting Tutorials...
    added on February 11, 2013
    - About Flags - post by .parado✗
    - Make Trainer Battles 1 - a video tutorial
    - Make Trainer Battles 2 - a video tutorial
    - Make Wild Battles - a video tutorial
    - Making NPC's Move Part 1 - a video tutorial
    - Making NPC's Move Part 2 - a video tutorial

    ---o0o---

    Ending Message...
    Okay, so that's the basics of scripting...
    If you need to learn more advance scripting, a lot of tutorials are available around here in the Documents and Tutorials...
    I might add something else in this tutorial but for now...
     
    Last edited:

    Resultz

    All- round Poke-Whizz
    583
    Posts
    14
    Years
  • I cant believe I'm the first to reply, this helped me so much thanks!

    The only problem for me is how do i link the Dynamic offsets to the sprites in A-Map?
     

    DuoRyan

    Hack'in as usual, it seem.
    335
    Posts
    14
    Years
  • I cant believe I'm the first to reply, this helped me so much thanks!

    The only problem for me is how do i link the Dynamic offsets to the sprites in A-Map?
    you have to compile by going to xse and going to tool and click batch compiler and then you get a offset like for example.
    If i compile destinedjagold script above and I get offset 800000 [which the first offset you used] I then put on a person event.
    Hope I help!
     
    82
    Posts
    13
    Years
  • Hai guys...i need help..sorry if i posted it on wrong place idk where to post it...

    always when i want to make a script in xse after when i want ot save the script into the rom it says unknown keyword ''lock'' on the line 4...why..help
     

    DuoRyan

    Hack'in as usual, it seem.
    335
    Posts
    14
    Years
  • Resultz

    All- round Poke-Whizz
    583
    Posts
    14
    Years
  • Okay i have one more problem, what exactly do i do when i've done the script, and want to compile it. It just asks me to save it but i dont know where or what as D:
     
    7
    Posts
    13
    Years
  • Hey guys, I'm new here and just wanted to ask a 2questions?

    I've searched alot to try and find the answer here but no luck...

    My questions are:

    1. In Xse, I do everything right, codes etc...follow them strictly step by step.
    -----------------------------
    #dynamic 0x800000

    #org @start
    lock
    faceplayer
    message @1 0x6
    release
    end

    #org @1
    = Hello World
    --------------------------------

    . When I test it, the character simply turns to me but he doesn't talk...Can't seem to figure out whats wrong. Any help would be greatly appreciated guys. ( Also, if I use FSF to find free space and I put it copy it to Xse, when I finish the codes and press compile, a box comes on saying that "THE ROM DOESN'T HAVE ENOUGH SPACE"..And the FSF option within Xse is unclickable , its not highlighted at all. Any tips also?
    -----------
    2. When I create a new house using a new map on advance map, I can't seem to enter the house when I test it. The screen goes black and the game freezes... All warps are correctly inserted and I've checked it so many times. Do you know what i'm doing wrong?

    Thank you Everyone
     

    destinedjagold

    You can contact me in PC's discord server...
    8,593
    Posts
    16
    Years
    • Seen Dec 23, 2023
    I added some new info on the first post.
    It's all about how you can insert your created scripts onto your ROM.
    Hopefully, it'll help some new hackers/modders.
     
    79
    Posts
    13
    Years
    • Seen Aug 27, 2014
    excuse me does anybody know how to make specific events happen after other ones? like if i wanted to put the officer jenny in fire reds vermillion city like in yellow and have her give me a squirtle only after i beat lt surge. how would i do that?
     

    Zeffy

    g'day
    6,402
    Posts
    15
    Years
    • Seen Feb 7, 2024
    excuse me does anybody know how to make specific events happen after other ones? like if i wanted to put the officer jenny in fire reds vermillion city like in yellow and have her give me a squirtle only after i beat lt surge. how would i do that?
    Flags, dood!

    Ask around in the Script Help thread/Simple Questions. They'll be much more of help there. :D
     
    79
    Posts
    13
    Years
    • Seen Aug 27, 2014
    thank you for pointing me in the right direction zeffy!

    and my lab seems to disagree with drinking out of the toilet
     
    24
    Posts
    12
    Years
    • Seen Jun 11, 2013
    okay this seems like a wrong question,but i need something REALLY simple. One script.I tried this, but I keep on messing up. All I want is for an old man to talk like "Hi!" or something. My first script; failed
     
    2
    Posts
    12
    Years
    • Seen Oct 2, 2011
    Can you help me? I want to learn how to make one of those scripts that activate battles in Pokemon Ruby. (Like starting a battle with Regice by pressing a in front of him.)
     

    DaleFails

    Pokémon: Giovanni Origins developer
    206
    Posts
    12
    Years
    • Seen today
    What is the code for your Rivals name? As its only [RIVAL] in advanced text..
     

    SupahNinja

    Scripting Ninja
    34
    Posts
    13
    Years
    • Seen Dec 23, 2011
    okay this seems like a wrong question,but i need something REALLY simple. One script.I tried this, but I keep on messing up. All I want is for an old man to talk like "Hi!" or something. My first script; failed

    Something like this should work:

    Code:
    #dynamic 0x800000
    
    #org @start
    msgbox @text 0x6
    end
    
    #org @text
    = Hi!

    When you compile it (the little gear button in XSE), It should give you an offset for @start (something after 800000, because that was the start of our dynamic offset).
    Copy that offset, and in Advance Map select the old man as a person event and put your copied offset in his Script Offset box.

    -----

    Can you help me? I want to learn how to make one of those scripts that activate battles in Pokemon Ruby. (Like starting a battle with Regice by pressing a in front of him.)
    You need the wildbattle command.
    The syntax is
    Code:
    wildbattle [national dex number] [level] [held item]
    All three variables need to be in hex.
    For the sake of example, let's say you want to battle a level 30 Raichu, holding a Potion.
    Raichu's National Dex number is 26, which in hex is 1A.
    30 (the level) in hex is 1E.
    The Potion's item number is 13, which in hex is D.
    So our code would be
    Code:
    wildbattle 0x1A 0x1E 0xD

    A full example script would look like
    Code:
    #dynamic 0x800000
    
    #org @start
    msgbox @raichu 0x6
    cry 0x1A
    wildbattle 0x1A 0x1E 0xD
    end
    
    #org @raichu
    = Raaiiiichuuuu!

    -----

    What is the code for your Rivals name? As its only [RIVAL] in advanced text..

    In XSE, it can be either
    Code:
    \v\h06
    or
    Code:
    [rival]
    .


    I just wrote all that from memory, but I can't see any errors in it right now.


    If yo need more help, check out the Script Help Thread.
     
    Last edited:

    AustinWolff

    has left
    100
    Posts
    12
    Years
  • I have another scripting problem, this one includes the money commands.

    I am using ruby and it is a script box script. The point is a guy walks up to you, gives you money, then walks away. however, here are the problems:

    Spoiler:


    Here is the script:

    Spoiler:
    !
     
    Last edited:

    wierddude22

    New hacker
    24
    Posts
    12
    Years
  • my script for a pokeball doesn't work :(
    Spoiler:


    when i take a step after receiving it, the sprite reappears
     
    Back
    Top