The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > ROM Hacking > Tools, Tutorials & Resources
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read

Notices

Tools, Tutorials & Resources Various tools to help you develop your hacks can be found here.
New threads in this forum are to be approved by a moderator before they are displayed.


Reply
 
Thread Tools
  #1    
Old July 6th, 2009, 05:11 PM
destinedjagold's Avatar
destinedjagold
Oh Hai Thar~ 'ω'
Community Supporter
 
Join Date: May 2007
Location: Philippines
Gender: Male
Nature: Careful
~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...


~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...
__________________
3DS FC: 0061-1111-6462
SV: 1364 | Rock Safari: Dwebble, Corsola and Barbaracle

Last edited by destinedjagold; 2 Days Ago at 11:32 PM. Reason: added some video tutorial links...
Reply With Quote
  #2    
Old July 12th, 2010, 06:03 AM
Resultz's Avatar
Resultz
All- round Poke-Whizz
 
Join Date: Aug 2009
Location: Yorkshire, England
Gender: Male
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?
__________________
MY HACK:
LOOKING FOR HELP MAKING POKEMON HYACINTH:
APPLY IN THE THREAD!;
MANY POSITIONS AVAILABLE!

Reply With Quote
  #3    
Old July 12th, 2010, 07:30 AM
DuoRyan's Avatar
DuoRyan
Hack'in as usual, it seem.
 
Join Date: Nov 2009
Location: Somewhere.
Age: 17
Gender: Male
Nature: Calm
Quote:
Originally Posted by Resultz View Post
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!
Reply With Quote
  #4    
Old July 12th, 2010, 04:10 PM
Resultz's Avatar
Resultz
All- round Poke-Whizz
 
Join Date: Aug 2009
Location: Yorkshire, England
Gender: Male
SO i copy the script offset onto the sprite rather than the sprite offset onto the script?
__________________
MY HACK:
LOOKING FOR HELP MAKING POKEMON HYACINTH:
APPLY IN THE THREAD!;
MANY POSITIONS AVAILABLE!

Reply With Quote
  #5    
Old July 13th, 2010, 12:45 AM
Tropical Sunlight's Avatar
Tropical Sunlight
The Faltine
 
Join Date: Mar 2008
Location: Slovenia
Age: 18
Gender: Male
Send a message via Windows Live Messenger to Tropical Sunlight
This is really basic.
It should encourage even more people to learn scripting themselves
__________________
Reply With Quote
  #6    
Old July 17th, 2010, 01:23 AM
tuna97's Avatar
tuna97
Togepi
 
Join Date: Jul 2010
Location: somewhere
Gender: Male
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
Reply With Quote
  #7    
Old July 17th, 2010, 06:10 AM
DuoRyan's Avatar
DuoRyan
Hack'in as usual, it seem.
 
Join Date: Nov 2009
Location: Somewhere.
Age: 17
Gender: Male
Nature: Calm
Quote:
Originally Posted by tuna97 View Post
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
think you should post the question here there where most script are fix by people.
http://www.pokecommunity.com/showthread.php?t=163576
Reply With Quote
  #8    
Old July 22nd, 2010, 12:04 PM
Resultz's Avatar
Resultz
All- round Poke-Whizz
 
Join Date: Aug 2009
Location: Yorkshire, England
Gender: Male
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:
__________________
MY HACK:
LOOKING FOR HELP MAKING POKEMON HYACINTH:
APPLY IN THE THREAD!;
MANY POSITIONS AVAILABLE!

Reply With Quote
  #9    
Old July 22nd, 2010, 12:12 PM
fdotdizzle's Avatar
fdotdizzle
Beginning Trainer
 
Join Date: Jul 2010
Location: Narnia
Gender: Male
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
Reply With Quote
  #10    
Old July 26th, 2010, 02:18 AM
destinedjagold's Avatar
destinedjagold
Oh Hai Thar~ 'ω'
Community Supporter
 
Join Date: May 2007
Location: Philippines
Gender: Male
Nature: Careful
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.
__________________
3DS FC: 0061-1111-6462
SV: 1364 | Rock Safari: Dwebble, Corsola and Barbaracle
Reply With Quote
  #11    
Old July 26th, 2010, 03:38 AM
joshblevins's Avatar
joshblevins
 
Join Date: Jul 2010
Gender: Male
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?
Reply With Quote
  #12    
Old July 26th, 2010, 04:41 AM
Zeffy's Avatar
Zeffy
bowties are cool
 
Join Date: Apr 2009
Location: Philippines
Gender: Male
Quote:
Originally Posted by joshblevins View Post
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
__________________
Reply With Quote
  #13    
Old July 26th, 2010, 04:54 AM
joshblevins's Avatar
joshblevins
 
Join Date: Jul 2010
Gender: Male
thank you for pointing me in the right direction zeffy!

and my lab seems to disagree with drinking out of the toilet
Reply With Quote
  #14    
Old August 25th, 2011, 03:29 AM
mihir
Unhatched Egg
 
Join Date: May 2011
Gender: Male
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
Reply With Quote
  #15    
Old October 2nd, 2011, 02:27 PM
Sephirothxxx's Avatar
Sephirothxxx
Beginning Trainer
 
Join Date: Oct 2011
Gender: Male
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.)
Reply With Quote
  #16    
Old October 9th, 2011, 03:19 AM
DaleH771's Avatar
DaleH771
I know who you are.
 
Join Date: Oct 2011
Gender: Male
What is the code for your Rivals name? As its only [RIVAL] in advanced text..
Reply With Quote
  #17    
Old October 9th, 2011, 05:22 AM
SupahNinja's Avatar
SupahNinja
Scripting Ninja
 
Join Date: Mar 2011
Gender: Male
Quote:
Originally Posted by mihir View Post
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.

-----

Quote:
Originally Posted by Sephirothxxx View Post
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!
-----

Quote:
Originally Posted by DaleH771 View Post
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.
__________________
SupahNinja

My feelings on
ROM hacking:

-I like scripting a lot.
-Mapping is almost as fun.
-Hex editing isn't bad at all.
-I do NOT enjoy spriting.
-I've been meaning to start learning ASM for a while, but I don't ever seem to have enough time.

Favorites:

-My favorite color is green.
-My favorite type is fire.
-My favorite Pokémon are:
Growlithe, Charizard, Mew,
Giratina, Haxorus, and Aggron.
SupahNinja

Last edited by SupahNinja; October 9th, 2011 at 06:50 AM.
Reply With Quote
  #18    
Old October 13th, 2011, 02:01 PM
minime010's Avatar
minime010
|...I have returned...|
 
Join Date: May 2010
Location: Somewhere over the Rainbow, Way up high
Gender: Male
Nature: Gentle
Thanks DJG, Cleared up alot of things for me. No wonder why I didn't understand Deigoisawesome's tutorial
__________________
~I support~



Ever wanted a hack that allowed you to play as Team Rocket?
Or maybe even join the police force?
Join Team Rocket today, and help make amazing things happen!
-On Hold-
Reply With Quote
  #19    
Old December 14th, 2011, 05:14 PM
AustinWolff's Avatar
AustinWolff
has left
 
Join Date: Aug 2011
Location: LA, California
Age: 16
Gender: Male
Nature: Brave
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:
1. the showmoney command doesnt work, meaning the money box never appears.

2. the person ID is 0211 in Amap, and in my script I setflag 0x211 but he doesnt disapear


Here is the script:

Spoiler:
#dynamic 0x800000

#org @start
checkflag 0x212
if 0x1 goto @done
applymovement 0x3 @move
waitmovement 0x0
msgbox @1 0x6
showmoney 0x00 0x00 0x00
givemoney 0x1F4 0x00
updatemoney 0x00 0x00 0x00
hidemoney 0x00 0x00
msgbox @2 0x6
msgbox @3 0x6
applymovement 0x3 @move2
waitmovement 0x0
setflag 0x212
setflag 0x211
release
end

#org @move
#raw 0x56
#raw 0x0A
#raw 0x0A
#raw 0xFE

#org @move2
#raw 0x16
#raw 0x16
#raw 0x16
#raw 0x16
#raw 0x16
#raw 0x16
#raw 0x16
#raw 0xFE

#org @1
= Hi trainer! I feel the need\nto share my money!

#org @2
= [red_rs]\v\h01: Thanks!

#org @3
= [blue_rs]Savings Guy: No problem
!
__________________
I have left. Feel free to disable my account.

Last edited by AustinWolff; December 25th, 2011 at 01:55 PM.
Reply With Quote
  #20    
Old February 8th, 2012, 12:09 PM
wierddude22's Avatar
wierddude22
New hacker
 
Join Date: Aug 2011
Location: My house
Age: 18
Gender: Male
Nature: Jolly
Send a message via Windows Live Messenger to wierddude22 Send a message via Skype™ to wierddude22
my script for a pokeball doesn't work
Spoiler:
#dynamic 0x800000
#org @start
giveitem 0x16 0x1 0x1
hidesprite 0x2
end


when i take a step after receiving it, the sprite reappears
__________________
I envy many of you
Reply With Quote
  #21    
Old February 8th, 2012, 01:38 PM
destinedjagold's Avatar
destinedjagold
Oh Hai Thar~ 'ω'
Community Supporter
 
Join Date: May 2007
Location: Philippines
Gender: Male
Nature: Careful
Quote:
Originally Posted by wierddude22 View Post
my script for a pokeball doesn't work
Spoiler:
#dynamic 0x800000
#org @start
giveitem 0x16 0x1 0x1
hidesprite 0x2
end


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.
__________________
3DS FC: 0061-1111-6462
SV: 1364 | Rock Safari: Dwebble, Corsola and Barbaracle
Reply With Quote
  #22    
Old February 11th, 2012, 09:33 AM
djfunky's Avatar
djfunky
Unhatched Egg
 
Join Date: Aug 2011
Gender: Male
I keep failing at making a pokeball... =\
Ty for the tut tho.
__________________
Reply With Quote
  #23    
Old September 15th, 2012, 10:36 AM
Hack Attack's Avatar
Hack Attack
Hacking Master
 
Join Date: Sep 2012
Location: North Wildwood, Nj
Age: 16
Gender: Male
Nature: Relaxed
Why when i copy the code and paste it on the sprite and look at the script its something different than what i typed?
Reply With Quote
  #24    
Old October 3rd, 2012, 01:51 AM
Rise_of_Darkrai
Unhatched Egg
 
Join Date: Sep 2012
Gender: Male
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?
Reply With Quote
  #25    
Old December 12th, 2012, 03:58 PM
Scrambledgraphics's Avatar
Scrambledgraphics
 
Join Date: Dec 2012
Location: Kanto
Gender: Female
Nature: Adamant
Where do I get the Xse stuff? And........What is Hex code? I'm new and I want to hack. I know almost NOTHING about computers and ROMs.
__________________
Hacks I support:

Reply With Quote
Reply
Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 02:31 AM.


Style by Nymphadora, artwork by Sa-Dui.
Like our Facebook Page Follow us on Twitter © 2002 - 2014 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2014 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.