• 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?".
  • Forum moderator applications are now open! Click here for details.
  • 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.

Script Help Thread (DO NOT REQUEST SCRIPTS)

Status
Not open for further replies.
190
Posts
14
Years
  • Seen Apr 14, 2016
I'll explain :)

A variable is just a simple number - there are quite a few variables that have not been used in the original game and those are the ones you should use for your scripts. You should not use 4050 over and over again, but you should use different variables for each script - I recommend writing down the ones you use and just keep going forward (i.e. next variable is 4051).

All unused variables in the game are set to 0 to start with. In order to change the number a variable is set to, you use the setvar command (setvar stands for set variable).

The most important things are the Var Number and Var Value boxes in A-Map. For instance, if you put 4050 as the var Number and 0000 as the Var Value for a script, that script will only activate when stepped on if variable number 4050 is set to the value 0. Since all variables are automatically set to 0 at the start of the game, the script will activate the first time you step on it, presuming you do not change the variable before hand in any other script.

In order to prevent the script from running again, you just need to set the variable to something other than the Var Value you have given the script - the best number being the next in sequence.

So, in a script you would want to happen only the first time it is stepped on, and not again, you would write "setvar 0x4050 0x1" - this would set the value of variable 4050 to 0001. Since it is set to 0001, it will not activate the next time it is stepped on, because you have told the script in A-Map to only activate when variable 4050 is set to 0.

The reason you don't want to use 4050 or any other variable over and over again for different scripts, is because you'll likely be changing the variable's value - the only reason the scripts should share the same variable number is if they are somehow related to or dependent on each other, like if one script should only activate once another script has been completed.

I hope all that makes sense. :)

I thought the checkflag/setflag sequence did that? sorry to bother you but can u explain the difference between variables and flags?
 

metapod23

Hardened Trainer
673
Posts
15
Years
  • Seen Aug 18, 2016
I thought the checkflag/setflag sequence did that? sorry to bother you but can u explain the difference between variables and flags?

You can use flags to do that, but it's actually more work and not as efficient.

The difference between flags and variables, for the most part, is that flags can only be see to either "on" (0x1) or "off" (0x0) while variables can be set to any number. Of course, they are used for different things - variables are used for scripts, flags are used for hiding sprites, etc. I'm not an expert on the differences between the two, though.

But really, there's no need to end the script with a setflag to prevent it from happening again. That would then require a checkflag at the beginning of the script. For example, which is simpler?

Script using Flags to deactivate the script
Code:
#org @start
lock
checkflag 0x1000
if 0x1 goto @done
<insert script here>
setflag 0x1000
release
end

#org @done
release
end

Script using Variable to deactivate the script
Code:
#org @start
lock
<insert script here>
setvar 0x4050 0x1
release
end

The latter script is simpler and more efficient, and doesn't require an extra script like the checkflag does.

It's just better when dealing with scripts to use setvar than checkflag/setflag. Flags are good to use for some people scripts, like for when a person gives out an item - the setflag and checkflag system is the best course, imo, to prevent the person from handing out the same item over and over - but it's not the best option for scripts, because they are executed via variables, so it makes sense to activate/deactivate them using those same variables.
 
190
Posts
14
Years
  • Seen Apr 14, 2016
You can use flags to do that, but it's actually more work and not as efficient.

The difference between flags and variables, for the most part, is that flags can only be see to either "on" (0x1) or "off" (0x0) while variables can be set to any number. Of course, they are used for different things - variables are used for scripts, flags are used for hiding sprites, etc. I'm not an expert on the differences between the two, though.

But really, there's no need to end the script with a setflag to prevent it from happening again. That would then require a checkflag at the beginning of the script. For example, which is simpler?

Script using Flags to deactivate the script
Code:
#org @start
lock
checkflag 0x1000
if 0x1 goto @done
<insert script here>
setflag 0x1000
release
end

#org @done
release
end

Script using Variable to deactivate the script
Code:
#org @start
lock
<insert script here>
setvar 0x4050 0x1
release
end

The latter script is simpler and more efficient, and doesn't require an extra script like the checkflag does.

It's just better when dealing with scripts to use setvar than checkflag/setflag. Flags are good to use for some people scripts, like for when a person gives out an item - the setflag and checkflag system is the best course, imo, to prevent the person from handing out the same item over and over - but it's not the best option for scripts, because they are executed via variables, so it makes sense to activate/deactivate them using those same variables.

Thanks for the verification. but when using a scripts that requires another script to be done before it, is it still possible to use setvar?
 

metapod23

Hardened Trainer
673
Posts
15
Years
  • Seen Aug 18, 2016
Thanks for the verification. but when using a scripts that requires another script to be done before it, is it still possible to use setvar?

Yes. If the first script was set to var 4050 and var value 0000, you would likely end the script with setvar 0x4050 0x1 so it wouldn't activate again.

Now if you had another script after which you only wanted to activate once that previous script has been completed, in A-Map you would simply set the var # to 4050 and the var value to 0001 and it would only activate if variable 4050 is set to 1, which would only happen when it is manually set in the previous script. So no checkflags are needed.

In the last script, you would end with setvar 0x4050 0x2 - that would prevent both scripts from being activated, because the value of variable 4050 is neither 0 or 1 after that.
 
69
Posts
13
Years
  • Seen Jan 8, 2012
so i understand that setvar 0x4050 0x1 deactivates the script from happening again, but you do you make a script only happen after another scipt using setvar? or do i absolutely have to use flags for that?
 

metapod23

Hardened Trainer
673
Posts
15
Years
  • Seen Aug 18, 2016
so i understand that setvar 0x4050 0x1 deactivates the script from happening again, but you do you make a script only happen after another scipt using setvar? or do i absolutely have to use flags for that?

No, if you have scripts that are independent of each other, just use different var #s for each script (i.e. one script be activated using var # 4050, the next by var # 4051, the next by var # 4052, etc).

I'm honestly not sure where this idea that you only put 4050 as the var # for all scripts got started - of course it will work if you never set variable 4050 to any other value, but it's pretty inefficient.
 

masterquestmq

Enthusiastic Rom Hacker
194
Posts
13
Years
  • Seen Nov 19, 2023
Cant compile script

Made an applymovement and trainer battle script combine
script works perfectly up to the battle
after the battle i need to restep on the script tile for the msgbox and 2nd applymovement command to work.

did i do something wrong here?
basically i need the script to continue even after the battle.

#dynamic 0x800A7F

#org @start
checkflag 0x202
if 0x0 goto @see
if 0x1 goto @end
end

#org @see
lock
applymovement 0x03 @walk
waitmovement 0x03
trainerbattle 0x0 0x004 0x0 @before @after
msgbox @talk 0x6
applymovement 0x03 @away
waitmovement 0x03
setflag 0x202
release
end

#org @walk
#raw 0x65
#raw 0x0
#raw 0xC
#raw 0xFE

#org @before
= YOU! You probably never attended\nany academy. Too young to even\lhave a Pokemon. People like you\lare not wanted here.

#org @after
= I LOST?

#org @talk
= All that hard work for nothing.

#org @away
#raw 0x1
#raw 0xD
#raw 0xD
#raw 0x3
#raw 0xF
#raw 0x1
#raw 0xFE

#org @end
release
end
 
Last edited:
4
Posts
13
Years
  • Seen Jun 12, 2011
Hidesprite problems

i don't get hidesprite D: it just dosent seem to work this is what i put for hidesprite plz help

hidesprite 0x1
hidesprite 0x2
hidesprite 0x3
hidesprite 0x4
hidesprite 0x5
hidesprite 0x6
hidesprite 0x7
hidesprite 0x8
 

DrFuji

[I]Heiki Hecchara‌‌[/I]
1,691
Posts
14
Years
Made an applymovement and trainer battle script combine
script works perfectly up to the battle
after the battle i need to restep on the script tile for the msgbox and 2nd applymovement command to work.

did i do something wrong here?
basically i need the script to continue even after the battle.

Spoiler:

Changes in red.

There are a few types of trainerbattle scripts which have their own functions and are all denoted by the value you place after the command. As you can see, I changed the 0x0 in your original script to 0x1, which indicates that the script will be continuing after the trainer battle - Placing 0x0 ends the script immediately after the battle which was why you had to step on it agin. When using a 0x1 trainerbattle script you will have to add an extra pointer to the part of the script which will continue after the battle (in this case, @continue).

Other sorts of trainer battles include 0x4 (double battle) and 0x9 (the first FR rival battle which includes Oak's tips).

i don't get hidesprite D: it just dosent seem to work this is what i put for hidesprite plz help

hidesprite 0x1
hidesprite 0x2
hidesprite 0x3
hidesprite 0x4
hidesprite 0x5
hidesprite 0x6
hidesprite 0x7
hidesprite 0x8

Can you elaborate on this? Its pretty vague and doesn't explain what sort of problem you are having.

Anyway, you have to use the HEX value of the 'Person event No' of the person you want to hide. For example, if you want to hide someone with a number of 6, use hidesprite 0x6, or if someone has the number 12, use hidesprite 0xC.

If you want someone to disappear for good, set a flag in the script and then put that same flag in the 'Person ID' part of the sprite you want to hide.
 
63
Posts
13
Years
  • Seen Dec 6, 2023
okay, script noob here

I need to add a couple battles in the game. I've searched for an offset in FSF, it gives me E42000 as first empty offset (I've searched for 1024 empty FF bytes, just to be safe.)

then, I'm trying to add this script
Spoiler:


It gives me an error, saying "Not enough free space found. Cannot compile."

WHAT THE HELL AM I DOING WRONG?
 

SPG

Pyroblock
88
Posts
13
Years
  • Age 27
  • Seen May 4, 2013
okay, script noob here

I need to add a couple battles in the game. I've searched for an offset in FSF, it gives me E42000 as first empty offset (I've searched for 1024 empty FF bytes, just to be safe.)

then, I'm trying to add this script
Spoiler:


It gives me an error, saying "Not enough free space found. Cannot compile."

WHAT THE HELL AM I DOING WRONG?

use #dynamic 0x800000

so you dont have to go through all the steps you just did finding free space because this will do it for you
 
4
Posts
13
Years
  • Seen Jun 12, 2011
umm about the gone for good drfuji could you show that in a script please because i don't exactly know where to put it.
 
1,421
Posts
13
Years
umm about the gone for good drfuji could you show that in a script please because i don't exactly know where to put it.
He means that you need an unused flag to enter in the Person ID in Advance-Map and the same flag in the script. Just type in the command setflag 0x[ Insert person ID here] before the end of the script.
 
4
Posts
13
Years
  • Seen Jun 12, 2011
oh its not the command is working the script is just glithing up. when i open the script it says bufferboxname 0xD9 0xE8 and not all those setflags i put up D:!
 

destinedjagold

You can contact me in PC's discord server...
8,593
Posts
16
Years
  • Age 33
  • Seen Dec 23, 2023
oh its not the command is working the script is just glithing up. when i open the script it says bufferboxname 0xD9 0xE8 and not all those setflags i put up D:!

that usually happens when you write a script and insert it in the ROM, and then edit it again, making it longer, and writing it back to the ROM again.
I suggest making a back-up copy of your hack, and writing the script into a new offset again.
 
63
Posts
13
Years
  • Seen Dec 6, 2023
EDIT: Nevermind, already found what was wrong, it worked by changing trainer's battle sprite
 
Last edited:

Shukumei

Teh Haxxorz
27
Posts
14
Years
I'm having trouble with a custom pokemon center script.
I compiled this script into a FR rom and then went into Nurse Joy's options in Advance Map and changed her script offset to the hex address of @welcome but when I go to play it and I talk to her it just gives me the little text bleep but doesn't show any text. And even though I put a lockall command at the start of my script, no one locks.

Don't worry about the content of the messages. They're not what I have in the original script. They're just placeholders to show you what should be happening.

Code:
#dynamic 0x800000

#org @welcome
lockall
faceplayer
msgbox @hello 0x6
checkgender
compare 0x800D 0x0
if 0x1 goto @boy
msgbox @girlM 0x5
compare 0x800D 0x0
if 0x0 goto @yesF
goto @no
end

#org @boy
msgbox @boyM 0x5
compare 0x800D 0x0
if 0x0 goto @yesM
goto @no
end

#org @no
msgbox @deny 0x06
release
end

#org @yesF
Msgbox @agree 0x6
fadescreen 0x1
Msgbox @headf 0x6
special 0x0
fadescreen 0x0
goto @end
end

#org @yesM
Msgbox @agree 0x6
fadescreen 0x1
Msgbox @headm 0x6
special 0x0
fadescreen 0x0
goto @end
end

#org @end
msgbox @goodbye 0x6
release
end

#org @hello
= This should show when you talk to her

#org @girlM
= This should show if you're female

#org @boyM
= This should show if you're male

#org @deny
= This should show if you decide not to heal

#org @agree
= This should show before the screen fade if you decide to heal

#org @headf
= This should show while the screen is black if you're female

#org @headm
= This should show while the screen is black if you're male

#org @goodbye
= This should show after your pokemon are healed

Update: I tried it in saphire too and it did the exact same thing so either it's a problem with XSE, Advance Map, or what I truely expect; I'm just rusty and I screwed up my script.
 
Last edited by a moderator:
42
Posts
13
Years
  • Seen Aug 13, 2021
Shinyzer w/ Trainers

So I was playing around with Hack Mew's Shinyzer, and making wild/giveaway Pokemon shiny is working for me just fine, but apparently I don't get how to call it for trainers. I wanted to test it out on the first trainer in FireRed (Bug Catcher w/ Weedle and Caterpie) and make the Caterpie shiny. However when I use this, it comes up with a completely different battle and no shiny Pokemon.
Code:
#dynamic 0x800000
'---------------
#org @start
setvar 0x8003 0x102
trainerbattle 0x0 0x66 0x0 @first @second
msgbox @defeated 0x2 "Ssh! You'll scare the bugs away.\n..."
end


'---------
' Strings
'---------
#org @first
= Hey! You have POKéMON!\nCome on!\lLet's battle 'em!

#org @second
= No!\nCATERPIE can't hack it!

#org @defeated
= Ssh! You'll scare the bugs away.\nAnother time, okay?
I wanted to be able to give Gym Leaders a shiny as their strongest Pokemon, but since this seems like it should be so easy I can't figure out what is wrong.
 
Status
Not open for further replies.
Back
Top