• 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
  • Age 33
  • Seen Dec 23, 2023
my script for a pokeball doesn't work :(
Spoiler:


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

That's where flags come in.
I haven't spare some time to add about flags, but there are scripting tutorials that covers this field in scripting.
 
7
Posts
11
Years
  • Seen Feb 15, 2021
I've written the entire example script, but when I click the gears, it just compiles at the bottom left then does nothing else. Am I doing something wrong?
 
1
Posts
11
Years
  • Seen Dec 14, 2012
Man. I hate bothering people with noob questions. Anyway. My script completely works untill the end.
When I talk with the trainer after the battle the messagebox with "Can you feel the despair" does not appear.
This is my script:

#dynamic 0x800000

#org @start
trainerbattle 0x0 0x001 0x0 @begin @what?
msgbox @beaten 0x6
release
end

#org @begin
= We're back!!

#org @what?
= As if I'm alone..

#org @beaten
= Can you feel the despair?
 

.parado✗

paranormal user
38
Posts
11
Years
@Zeoka
Maybe you still use XSE 1.0.0.0
If that is the case, instead of msgbox @pointer 0x6
you write..

msgbox @pointer
callstd 6

@AriArk
with \L you can make a new line.
with \p you can open a clear new msgbox.

If you use \p once, you must use \n and then \l afterwards :)
 

AriArk

Survey Corps
136
Posts
13
Years
@Zeoka
Maybe you still use XSE 1.0.0.0
If that is the case, instead of msgbox @pointer 0x6
you write..

msgbox @pointer
callstd 6

@AriArk
with \L you can make a new line.
with \p you can open a clear new msgbox.

If you use \p once, you must use \n and then \l afterwards :)
Thanks - that worked, if it doesn't take a huge amount of time, could you explain how flags work too. I go to prof.birch's lab to get Riolu but before that I could go onto the route and see Missingno (i'm not 100% sure if this is what flags are).
 

.parado✗

paranormal user
38
Posts
11
Years
Flags are nothing else than "checkers" in a Pokémon Game.
If someone gives you an item, you set a flag, that he can't give it to you twice, three times, endless.

It works this way..

#dynamic 0xXXXXX
#org @start
checkflag 0xyour_flag
if 0x1 call @got_it <---- this checks if the flag 0xyour_flag is set. If 0x1 (yes), call a pointer.
giveitem 0xItem 0xAmount 0x0 0x0 0x0
waitfanfare
closeonkeypress
setflag 0xyour_flag <---- Sets a flag. I prefer starting at 0x450 up to 0x7FF and 0x900-0xFFF
end

#org @got_it
end

Well, if you click the person again, it will automatically jump to @got_it and the script ends.
Attention! You can set every flag only once!
If you set for example setflag 0x500, you can check this flag everytime, to remove it, type

clearflag 0xyour_flag

Hope I helped :)
 

destinedjagold

You can contact me in PC's discord server...
8,593
Posts
16
Years
  • Age 33
  • Seen Dec 23, 2023
I have one more question - how do you add the POKéMON tab on the menu if you don't have a starter that you chose from professor birch's case.

If I recall correctly, you would need to add the code...
Code:
setflag 0x800
...to your script.
 

TubbieRanger

UNprofessional ROMhacker
5
Posts
6
Years
  • Age 47
  • Seen Oct 9, 2019
When I try to compile it it says Runtime Error 52 then crashes
 
1
Posts
3
Years
  • Age 23
  • Seen Feb 16, 2024
~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...

ive tried following what you said exactly and my game keeps crash ing when i interact with the NPC
 
100
Posts
1
Years
  • Age 28
  • Seen Sep 5, 2023
Hi, sorry if I'm hijacking the thread. But is there a special for the regional dex? Rather than the national PokéDex? I want to make a hack, but I kind of also want to make it a bit closer to the actual games.
 
Back
Top