PDA

View Full Version : [Essentials script] BW Gender Selection Screen


Nickalooose
July 21st, 2013, 03:15 PM
Hello, this is my first public Script that I have created and not helped or given advice on, made from scratch.

It is a basic version of a gender selection screen based on BW and BW2.
Quick to implement, no messing around.
Easy to manage.
Make your game look more professional.

How to add:
Simple, just throw this code into an empty script section above Main and name it GenderSelect.
Place all pictures into the Graphics/Pictures, folder.
Remove the Gender selection event within Prof. Oaks Intro (the "Are you a boy or a girl" part), and instead place this script:
scene=GenderPickScene.new
screen=GenderPick.new(scene)
screen.pbStartScreen

All pictures should be named:
Male = Select_A
Female = Select_B
Male Base = Select_ABase
Female Base = Select_BBase.

All pictures can be edited of course and modifications to the script should be made.

Screenshots:

http://imageshack.com/a/img703/6960/q9x.png
http://imageshack.com/a/img542/218/3ll.png
http://imageshack.com/a/img18/215/j8gd.png
http://imageshack.com/a/img845/4646/x2w6.png
http://imageshack.com/a/img823/6958/ad62.png
http://imageshack.com/a/img842/5364/y0h4.png
http://imageshack.com/a/img541/5153/w9u.png


Code:

#==============================================================================#
# V2 Created by Nickalooose
# Please Credit If used.
#==============================================================================#
# FIXES: Save issue.
#==============================================================================#
# How To Use:
# To use, remove the player gender event.
# The "Are you a boy or a girl", event.
# And add:
# scene=GenderPickScene.new
# screen=GenderPick.new(scene)
# screen.pbStartScreen
# as a single script event.
#
# Sprites included, are at recommended size for a 512x384 standard
# Essentials game.
# Should work in any Essentials.
#==============================================================================#
class GenderPickScene

def pbUpdate
pbUpdateSpriteHash(@sprites)
end

def selectPlayer
@select=0
@sprites={}
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99998
@sprites["overlay"]=BitmapSprite.new(Graphics.width, Graphics.height)
@sprites["overlay"].z = 99999
@overlay=@sprites["overlay"].bitmap
@overlay.clear
# x is across
# y is down
# base a
@sprites["playerabase"]=Sprite.new
@sprites["playerabase"].z = 99998
@sprites["playerabase"].x = -200#0
@sprites["playerabase"].y = 102
@sprites["playerabase"].bitmap= BitmapCache.load_bitmap("Graphics/Pictures/Select_ABase")
# base b
@sprites["playerbbase"]=Sprite.new
@sprites["playerbbase"].z = 99998
@sprites["playerbbase"].x = 456#256
@sprites["playerbbase"].y = 102
@sprites["playerbbase"].bitmap= BitmapCache.load_bitmap("Graphics/Pictures/Select_BBase")
20.times do
@sprites["playerabase"].x+=10
@sprites["playerbbase"].x-=10
Graphics.update
Input.update
pbUpdate
end
# male
@sprites["playera"]=Sprite.new
@sprites["playera"].z = 99998
@sprites["playera"].x = 50
@sprites["playera"].y = 102
@sprites["playera"].bitmap= BitmapCache.load_bitmap("Graphics/Pictures/Select_A")
# female
@sprites["playerb"]=Sprite.new
@sprites["playerb"].z = 99998
@sprites["playerb"].x = 380
@sprites["playerb"].y = 102
@sprites["playerb"].bitmap= BitmapCache.load_bitmap("Graphics/Pictures/Select_B")
Kernel.pbMessage("Are you male or female?")
loop do
Graphics.update
Input.update
pbUpdate
if Input.trigger?(Input::C) && @select==0
Kernel.pbMessage("You must be male or female.")
Kernel.pbMessage("So, are you male or female?")
end
if Input.trigger?(Input::LEFT)
if @select==1
pbSEPlay("Choose")
@select=2
@sprites["playera"].color = Color.new(0, 0, 0, 200)#faded
@sprites["playerabase"].color = Color.new(0, 0, 0, 200)#faded
@sprites["playerb"].color = Color.new(0, 0, 0, 0)
@sprites["playerbbase"].color = Color.new(0, 0, 0, 0)
else
pbSEPlay("Choose")
@select=1
@sprites["playerb"].color = Color.new(0, 0, 0, 200)
@sprites["playerbbase"].color = Color.new(0, 0, 0, 200)
@sprites["playera"].color = Color.new(0, 0, 0, 0)#faded
@sprites["playerabase"].color = Color.new(0, 0, 0, 0)#faded
end
elsif Input.trigger?(Input::RIGHT)
if @select==2
pbSEPlay("Choose")
@select=1
@sprites["playerb"].color = Color.new(0, 0, 0, 200)
@sprites["playerbbase"].color = Color.new(0, 0, 0, 200)
@sprites["playera"].color = Color.new(0, 0, 0, 0)#faded
@sprites["playerabase"].color = Color.new(0, 0, 0, 0)#faded
else
pbSEPlay("Choose")
@select=2
@sprites["playera"].color = Color.new(0, 0, 0, 200)#faded
@sprites["playerabase"].color = Color.new(0, 0, 0, 200)#faded
@sprites["playerb"].color = Color.new(0, 0, 0, 0)
@sprites["playerbbase"].color = Color.new(0, 0, 0, 0)
end
elsif Input.trigger?(Input::UP)
if @select==1
pbSEPlay("Choose")
@select=2
@sprites["playera"].color = Color.new(0, 0, 0, 200)#faded
@sprites["playerabase"].color = Color.new(0, 0, 0, 200)#faded
@sprites["playerb"].color = Color.new(0, 0, 0, 0)
@sprites["playerbbase"].color = Color.new(0, 0, 0, 0)
else
pbSEPlay("Choose")
@select=1
@sprites["playerb"].color = Color.new(0, 0, 0, 200)
@sprites["playerbbase"].color = Color.new(0, 0, 0, 200)
@sprites["playera"].color = Color.new(0, 0, 0, 0)#faded
@sprites["playerabase"].color = Color.new(0, 0, 0, 0)#faded
end
elsif Input.trigger?(Input::DOWN)
if @select==2
pbSEPlay("Choose")
@select=1
@sprites["playerb"].color = Color.new(0, 0, 0, 200)
@sprites["playerbbase"].color = Color.new(0, 0, 0, 200)
@sprites["playera"].color = Color.new(0, 0, 0, 0)#faded
@sprites["playerabase"].color = Color.new(0, 0, 0, 0)#faded
else
pbSEPlay("Choose")
@select=2
@sprites["playera"].color = Color.new(0, 0, 0, 200)#faded
@sprites["playerabase"].color = Color.new(0, 0, 0, 200)#faded
@sprites["playerb"].color = Color.new(0, 0, 0, 0)
@sprites["playerbbase"].color = Color.new(0, 0, 0, 0)
end
end
if Input.trigger?(Input::C) && @select==1
pbSEPlay("Choose")
19.times do
@sprites["playera"].x+=9#192
@sprites["playerabase"].x-=10
@sprites["playerbbase"].x+=10
@sprites["playerb"].x+=10#192
Graphics.update
Input.update
pbUpdate
end
@sprites["playerabase"].opacity=0
@sprites["playerb"].opacity=0
@sprites["playerbbase"].opacity=0
pbWait(20)
if Kernel.pbConfirmMessage("So, you are male?")
pbChangePlayer(0)
pbEndScene
return true
else
@sprites["playerabase"].opacity=255
@sprites["playerb"].opacity=255
@sprites["playerbbase"].opacity=255
19.times do
@sprites["playera"].x-=9#192
@sprites["playerabase"].x+=10
@sprites["playerbbase"].x-=10
@sprites["playerb"].x-=10#192
Graphics.update
Input.update
pbUpdate
end
end
elsif Input.trigger?(Input::C) && @select==2
pbSEPlay("Choose")
19.times do
@sprites["playerb"].x-=8#150
@sprites["playerabase"].x-=10
@sprites["playerbbase"].x+=10
@sprites["playera"].x-=9#192
Graphics.update
Input.update
pbUpdate
end
@sprites["playerabase"].opacity=0
@sprites["playera"].opacity=0
@sprites["playerbbase"].opacity=0
pbWait(20)
if Kernel.pbConfirmMessage("So, you are female?")
pbChangePlayer(1)
pbEndScene
return true
else
@sprites["playerabase"].opacity=255
@sprites["playera"].opacity=255
@sprites["playerbbase"].opacity=255
19.times do
@sprites["playerb"].x+=8#50
@sprites["playerabase"].x+=10
@sprites["playerbbase"].x-=10
@sprites["playera"].x+=9#192
Graphics.update
Input.update
pbUpdate
end
end
end
end
end

def pbEndScene
pbFadeOutAndHide(@sprites){pbUpdate}
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
end

class GenderPick
def initialize(scene)
@scene=scene
end

def pbStartScreen
@scene.selectPlayer
@scene.pbEndScene
end
end


Credit me if used and if modifications are used.
Enjoy.

V2 FIXES:

Save Issue.

Harvey_Create
July 21st, 2013, 04:11 PM
And to think i was going to make this myself. :L Thanks Man

And this works on Essentials 9 as well!

Derxwna Kapsyla
July 23rd, 2013, 05:31 AM
How would you go about tweaking the script so that, when you select a character, it activates a certain switch.
For example, if you picked the Male Character, it sets a switch named "Male Character Selected" to ON, and the same for Female, except it sets "Female Character Selected" to ON.
Have a screenshot for visual aid
http://gyazo.com/b97b61b8fd09d9a465eaf06033962ab2.png

Nickalooose
July 23rd, 2013, 06:44 AM
Go into the script and add:
$game_switches[x]=true.
Underneath lines 152 and 185, where x is the number of your switch.

Maruno
July 23rd, 2013, 05:16 PM
I would've gone for checking the player's gender afterwards and fiddling with switches based on that.

Nickalooose
July 23rd, 2013, 11:10 PM
You're right, and I did write that out, but most people don't understand conditional branches let alone explanations of them, it was easier to just add that for him and others that haven't learnt rmxp yet, have a solution before the question "my switch always returns female, why?" lol

Dylanrockin
July 24th, 2013, 12:55 AM
I have one question, it relates to the above questioned by Derxwna Kapsyla. I was wondering if you can have separate starting points. Because with the default intro in Pokemon Essentials you can easily add specific starting points based on the gender the character chose. And since it is a script I was wondering a way that I can make it so that if someone chose the female character they would start somewhere completely different from where the male character starts.

Maruno
July 24th, 2013, 03:29 AM
I have one question, it relates to the above questioned by Derxwna Kapsyla. I was wondering if you can have separate starting points. Because with the default intro in Pokemon Essentials you can easily add specific starting points based on the gender the character chose. And since it is a script I was wondering a way that I can make it so that if someone chose the female character they would start somewhere completely different from where the male character starts.
That's beyond the scope of this tutorial. It's also a basic RMXP skill and involves, yes, a conditional branch. Have a look at the intro event, figure out which line transfers the player to a new map (there is only one line for this), and stick a conditional branch around it.

Nickalooose
July 25th, 2013, 04:01 AM
Like Maruno said, this script is to allow a visual, better looking way to pick Genders only... For things like switches and variables, other pictures or speeches, you will need to add them, before or after the selectPlayer script... This script will do nothing more than pick whether you are a boy or girl (as is intended).

Nickalooose
July 28th, 2013, 05:10 PM
Anyone using this script will need to update to the new one, the older one is acting like a little 5 year old and stops you from saving, but the problem is fixed nonetheless. Sorry for the inconveniences caused. Let me know if any new problems pop up.

For the fix and how to work, change selectPlayer within your event (if you already put this in your game), to:
scene=GenderPickScene.new
screen=GenderPick.new(scene)
screen.pbStartScreen

unmaestropokemon
August 18th, 2013, 12:05 AM
help me

Exception: RuntimeError
Message: Script error within event 1, map 1 (Intro):
Exception: SyntaxError
Message: (eval):3:in `pbExecuteScript'compile error
(eval):3: syntax error
***Full script:
scene=GenderPickScene.new
screen=GenderPick.new(scene)
screen.pbStartScreen.


Interpreter:276:in `pbExecuteScript'
Interpreter:1600:in `command_355'
Interpreter:494:in `execute_command'
Interpreter:193:in `update'
Interpreter:106:in `loop'
Interpreter:198:in `update'
Scene_Map:103:in `update'
Scene_Map:101:in `loop'
Scene_Map:114:in `update'
Scene_Map:68:in `main'

Nickalooose
August 23rd, 2013, 06:58 AM
Remove the final full stop, it shouldn't be there.

Lanyons
November 19th, 2013, 01:08 AM
Thanks for this, I will be using it later for my game :)

Rayquaza.
November 21st, 2013, 03:46 AM
In my opinion this script seems a bit needless because it is perfectly easy to make the same thing using events and switches (with zero scripting knowledge) and I should know; I have this sort of thing in my game.

Nickalooose
November 22nd, 2013, 07:55 AM
In my opinion this script seems a bit needless because it is perfectly easy to make the same thing using events and switches (with zero scripting knowledge) and I should know; I have this sort of thing in my game.

True, but why bother spending valuable minutes eventing something like this, when you can add it in 10 seconds, using this.

Chrisario
December 11th, 2013, 03:18 AM
I need help with this where in the script should I put

here is something that a tried but this looks not right
[SPOILER]http://http://imageshack.com/a/img15/2315/5kb0.png