PDA

View Full Version : [Tutorial] Basic PKSV tutorials


score_under
February 21st, 2008, 11:59 AM
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:

#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:

#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?

#org hello 'remember we defined that?
= Hello, I'm the result of your amazing\nscripting skill.
This will show the message:
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

#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!

score_under
February 22nd, 2008, 12:55 PM
Yes, Irish Witch, this is WAR!

If you don't know which offsets the freespace command gets, check the log file
(eg:

#DEFINE
-> start-of-script
FS -> 0x86B0B00
)
Section 2 -- I am a healer!

This is a very simple tutorial for a very simple command: healing.
Now, we start our script:

#org 0x86B1000 'Some space, usually free. Choose another offset if you want
#define warning freespace40
#define bye-bye freespace40
lock
faceplayer
message warning
showmsg
waitbutton
fadescreen 1
special 0x0 'yes, special OXOs
fadescreen 0
closemsg
message bye-bye
showmsg
waitbutton
closemsg
release
end

#org warning
= Hey, those trainers up there are tough.\nYou might need a little help.
#org bye-bye
= Ok, I healed your POKéMON!\nGo get 'em!
If you put a new line at the end of the script, the message box warning you of the EOF (end-of-file) does not appear.
Now, to explain the scripts:

#define warning freespace40
#define bye-bye freespace40
lock
faceplayer
message warning
This defines 2 places of free-space we can use.
Then, it locks the sprite and causes it to face the player.
Next it loads the free space named "warning" to the buffer for text.

showmsg
waitbutton
fadescreen 1
special 0x0 'yes, special OXOs
fadescreen 0
It shows the prepared message, and waits for the player to press any button. Then, it fades the screen to black, heals the player's pokémon, and fades back to the action.

closemsg
message bye-bye
showmsg
waitbutton
closemsg
release
end
Prepares the next message, shows it and waits for a button, etc, then releases the sprite and ends the script.


Remember to get the SVN copy for the latest bugfixes, features and commands!

master morty
June 30th, 2008, 09:18 AM
so far it seems really good

to get it better than irish which's pokescript you should really make yourself noticable



some how

Christos
June 30th, 2008, 11:54 PM
You have just revived the thread. It hasn't had a post for over a month.