• 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.

Scripting Error

Rayd12smitty

Shadow Maker
645
Posts
12
Years
  • Seen Feb 21, 2016
Hey guys. I am extremely new to scripting and am experimenting with different things by making custom scripts. I am working on making a PWT script. So since I am a noob, I am having trouble with a few basic commands. I have figured out a lot with Carmaniac's help and by looking through the existing scripts. There are two things I haven't figured out that I need right now and am hoping someone can tell me how.

1. I want to set a variable to a random number between 1 and 8. I am currently using this but am not sure if it is the right way or if it is working right.

Code:
$game_variables[84]=rand(1-8)

2. I understand how to call a sprite to the screen like this:

Code:
@sprites["Player Box"] = Sprite.new
@sprites["Player Box"].z = 2
@sprites["Player Box"].x = 0
@sprites["Player Box"].y = 0
@sprites["Player Box"].bitmap = RPG::Cache.picture("PWTBox1")

I want to make it so that the number in the filename (1) depends on a variable, the same one from above. I have looked at existing scripts and tried copying them but I keep getting errors.

Can someone show me how to do these 2 things?
 

Luka S.J.

Jealous Croatian
1,270
Posts
15
Years
1. When using the rand(x) command, the random numbers that will be output, will range from 0 to (x-1). To achieve what you want use
Code:
$game_variables[84]=rand(8)+1

2. To input variables (local or global) use the "#{x}" function, where x is the extra handler. So your bitmap load would look like
Code:
@sprites["Player Box"].bitmap = RPG::Cache.picture("PWTBox#{$game_variables[84]}")

[EDIT] If you're just starting out with coding, I suggest starting out with something smaller and reasonable. I coded 1642 lines of code from scratch for my PWT to function perfectly. That includes the visuals, matching AI, round AI, Trainer modifiers and generators.
 

Rayd12smitty

Shadow Maker
645
Posts
12
Years
  • Seen Feb 21, 2016
Thanks Luka. I was trying to think of something simpler, but this is the only real thing I want to do. I don't plan on coding in any AI. Pretty much everything will just be randomly generated.

Thanks especially for that second code. I've tried about 8 different things and none have worked.

Oh and another quick question.
How do you say "not equal" I believe it has something to do with exclamation points?
 
Last edited:

Luka S.J.

Jealous Croatian
1,270
Posts
15
Years
The PWT is quite a complicated system. Using the default methods for battling will not get you the right result. As I've already mentioned before, you need to consider several things first before attempting it. Even if you just plan to have the battles randomly set, you'll still need to find a way, to create rounds which generate the different trainers, and pair up opponents. Then random opponents get sent through the next round, but those would depend on the previous pairs that were fighting...and so on...

Oh and another quick question.
How do you say "not equal" I believe it has something to do with exclamation points?

There are several ways to do this. The easiest/safest would be using !(x) where x is the function and the !() 'round it inverts it. So you could have something like !(variable.nil?) to check if the variable is not nil, or !(variable==string) to check if the variable does not equal the string, or !(array.include?(integer)) to check if the array does not include the integer. Whatever you use, putting it in !() will invert that check.
 
Last edited:

Rayd12smitty

Shadow Maker
645
Posts
12
Years
  • Seen Feb 21, 2016
The PWT is quite a complicated system. Using the default methods for battling will not get you the right result. As I've already mentioned before, you need to consider several things first before attempting it. Even if you just plan to have the battles randomly set, you'll still need to find a way, to create rounds which generate the different trainers, and pair up opponents. Then random opponents get sent through the next round, but those would depend on the previous pairs that were fighting...and so on...



There are several ways to do this. The easiest/safest would be using !(x) where x is the function and the !() 'round it inverts it. So you could have something like !(variable.nil?) to check if the variable is not nil, or !(variable==string) to check if the variable does not equal the string, or !(array.include?(integer)) to check if the array does not include the integer. Whatever you use, putting it in !() will invert that check.

You are most likely right. I want to try and see how far I can get though. Thanks for the help. I have figured out how to get all the starting contestants set up, and make it so that the player is put randomly into the tournament bracket. I am just working on putting sprites together right now before I move onto the first battle.
 

Luka S.J.

Jealous Croatian
1,270
Posts
15
Years
You are most likely right. I want to try and see how far I can get though. Thanks for the help. I have figured out how to get all the starting contestants set up, and make it so that the player is put randomly into the tournament bracket. I am just working on putting sprites together right now before I move onto the first battle.

Regarding the battles themselves:
- You'll need to have a party cap (official game has 3 for single, 4 for double, 6 for tripple) which brings me to my next point, in the Trainers PBS file you'd need your opponents defined with all 6 Pokemon, and then your PWT system should choose the appropriate number of Pokemon from there. The official PWT makes it so that the Pokemon are randomly selected, so the same trainer could have a different party each time. Same goes for the player. You'd need to be able to choose which Pokemon to take into the tournament, but I think FL already made a script for that.
- You'll need a level cap (official game has it at 50 for the global tournaments), which goes together with the disabling of exp and money gain.
- Also like I said before, the games have the opponent say different things depending on the battle outcome. The default battle loading only supports one end-of-battle speech.

Don't mean to intimidate you by all this, but to pull of the PWT, you'll need to make edits to PokeBattle_Battle class and defs such as pbLoadTrainer and pbTrainerBattle.
 
Back
Top