Thread: [Tutorial] Basic PKSV tutorials
View Single Post
  #1    
Old February 21st, 2008, 11:59 AM
score_under's Avatar
score_under
I program the *other* ASM.
 
Join Date: Aug 2005
Location: Hertfordshire, England
Age: 21
Nature: Rash
So, I think Irish Witch should not have all the attention :D

PROLOGUE:

To install PKSV,
  • Click the PKSV link in my signature
  • Download the latest version from the site
  • Extract it to a new folder.
  • Once it's in the correct folder, double-click AssociateShell.bat (if you don't have that file, get the latest version from my sig)
Something you might want to know: PKSV is case-insensetive. In other words, you can define a variable called "HeLlOwOrLd" and reference it as "heLLowORLd" if you wanted to.

How to compile
Save the script as a .PKS file. (i.e. "ThisIsAScript.pks")
Right-click the file and press "Compile".

Section 1 -- Basic Talking and Items

This section covers the talking and giving of items.
The first script shall be a talking script.

Open up notepad.
Save the empty file as "TalkingScript.pks" in the PKSV folder.
(This saves us time later)
Now, time to write the script.
First, we need to begin the script.
But at which offset? Let PKSV decide:
Code:
#define start-of-script FREESPACE10
#org start-of-script
As you can see, we (you and I, if you are following this tutorial) defined the variable "start-of-script" as a new section of free space, 0x10 bytes long (or 16 bytes in decimal).
This may seem complicated for some, but it is easy to get used to.
Now, we shall write a message.
Add this on:
Code:
#define hello FREESPACE40 '64 bytes of free space.
lock
faceplayer
msgbox hello
callstd msg_normal
release
end
Right. So we created even more free space, 64 bytes, and called the MsgBox function on it. Then we used callstd to show the message. Msg_normal is the type of message.
But where's the text?
Code:
#org hello 'remember we defined that?
= Hello, I'm the result of your amazing\nscripting skill.
This will show the message:
Quote:
Hello, I'm the result of your amazing
scripting skill.
Here, the line has split. "\n" is actually converted to a control code which tells Pokemon to change it into a new line.
Likewise, "\p" or "\l" signals a new paragraph.
Now, we make him give us some free stuff!
Red=updated, black=added
Quote:

#define start-of-script FREESPACE20
#org start-of-script
#define hello FREESPACE40 '64 bytes of free space.
lock
faceplayer
msgbox hello
callstd msg_normal
checkflag 0x200
#define already-done FREESPACE10
#define notdonemsg FREESPACE20
if 0x1 jump already-done
msgbox notdonemsg
callstd msg_normal
copyvarifnotzero 0x8000 0x2 'Copy the value for "ultra ball" into 0x8000
copyvarifnotzero 0x8001 0x5 'Five of them, please!
callstd MSG_OBTAIN 'You obtained the ultra ball!
closemsg 'close this message
setflag 0x200

release
end

#org already-done
release
end

#org notdonemsg
= Hi, I have some items here, but I'm not\na trainer so I can't use them.


#org hello 'remember we defined that?
= Hello, I'm the result of your amazing\nscripting skill.
Now, to see your code in action, right-click the .pks file and press "Compile".
Then, look in the log to see what the address was #defined as,
and finally, edit someone in advancemap to point to that address.
Run the rom, and talk to that person!
__________________
Plz not to PM me, I don't come here often enough. Email if you need me

Last edited by score_under; February 23rd, 2008 at 02:46 AM.