Go Back   The PokéCommunity Forums > Creative Discussions > Game Development > Scripts & Tutorials

Notices
For all updates, view the main page.

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.



Reply
Click here to go to the first staff post in this thread.  
Thread Tools
  #1    
Old July 21st, 2013 (03:15 PM). Edited August 23rd, 2013 by Nickalooose.
Nickalooose
--------------------
 
Join Date: Mar 2008
Gender: Female
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:
Code:
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:
Spoiler:










Code:
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:
Spoiler:

Save Issue.
Attached Thumbnails
Select_A.png‎   Select_B.png‎   Select_ABase.png‎   Select_BBase.png‎  
Reply With Quote
  #2    
Old July 21st, 2013 (04:11 PM). Edited July 21st, 2013 by Harvey_Create.
Harvey_Create's Avatar
Harvey_Create
Pokemon Apex Team Member
 
Join Date: Nov 2012
Location: Iowa
Gender: Male
Nature: Naughty
Send a message via Skype™ to Harvey_Create
And to think i was going to make this myself. :L Thanks Man

And this works on Essentials 9 as well!
__________________
This signature has been disabled.
Exceeds signature width limit (strictly 600 pixels or less).
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
Reply With Quote
  #3    
Old July 23rd, 2013 (05:31 AM).
Derxwna Kapsyla's Avatar
Derxwna Kapsyla
X-Class Project, Derxwna, #003
 
Join Date: Jun 2011
Location: Margate, FL
Age: 21
Gender: Male
Nature: Lax
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
__________________
Development Blog:
For more information future news and updates to any projects, the following blogs are where I post information. You can usually hit me with a message there when it comes to bug reports or feedback, or general conversation about something.
Game Projects:
In Progress:
Reply With Quote
  #4    
Old July 23rd, 2013 (06:44 AM).
Nickalooose
--------------------
 
Join Date: Mar 2008
Gender: Female
Go into the script and add:
$game_switches[x]=true.
Underneath lines 152 and 185, where x is the number of your switch.
Reply With Quote
  #5    
Old July 23rd, 2013 (05:16 PM).
Maruno's Avatar
Maruno
Lead Dev of Pokémon Essentials
 
Join Date: Jan 2008
Location: England
I would've gone for checking the player's gender afterwards and fiddling with switches based on that.
__________________
Reply With Quote
  #6    
Old July 23rd, 2013 (11:10 PM).
Nickalooose
--------------------
 
Join Date: Mar 2008
Gender: Female
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
Reply With Quote
  #7    
Old July 24th, 2013 (12:55 AM).
Dylanrockin's Avatar
Dylanrockin
Horizon Seeker - Symphonic Horizon Lead Dev.
 
Join Date: May 2011
Age: 19
Gender: Male
Nature: Timid
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.
__________________



As a reminder, do not take any of the artwork from my thread, or deviantART. Do not use, or post it anywhere. YouTube, dA, etc.
Reply With Quote
  #8    
Old July 24th, 2013 (03:29 AM).
Maruno's Avatar
Maruno
Lead Dev of Pokémon Essentials
 
Join Date: Jan 2008
Location: England
Quote originally posted by Dylanrockin:
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.
__________________
Reply With Quote
  #9    
Old July 25th, 2013 (04:01 AM).
Nickalooose
--------------------
 
Join Date: Mar 2008
Gender: Female
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).
Reply With Quote
  #10    
Old July 28th, 2013 (05:10 PM).
Nickalooose
--------------------
 
Join Date: Mar 2008
Gender: Female
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
Reply With Quote
  #11    
Old August 18th, 2013 (12:05 AM).
unmaestropokemon
 
Join Date: Aug 2013
help me

Exception: RuntimeError
Message: Script error within event 1, map 1 (Intro):
Exception: SyntaxError
Message: (eval)in `pbExecuteScript'compile error
(eval) 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'
Reply With Quote
  #12    
Old August 23rd, 2013 (06:58 AM). Edited August 23rd, 2013 by Nickalooose.
Nickalooose
--------------------
 
Join Date: Mar 2008
Gender: Female
Remove the final full stop, it shouldn't be there.
Reply With Quote
  #13    
Old November 19th, 2013 (01:08 AM).
Lanyons's Avatar
Lanyons
Love Type
 
Join Date: Nov 2013
Location: Colorado, USA
Gender: Female
Nature: Bold
Thanks for this, I will be using it later for my game
Reply With Quote
  #14    
Old November 21st, 2013 (03:46 AM).
Rayquaza.'s Avatar
Rayquaza.
Lead Dev in Pokémon Chaos
 
Join Date: Sep 2011
Location: United Kingdom
Age: 18
Gender: Male
Nature: Adamant
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.
__________________
Reply With Quote
  #15    
Old November 22nd, 2013 (07:55 AM).
Nickalooose
--------------------
 
Join Date: Mar 2008
Gender: Female
Quote originally posted by Rayquaza.:
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.
Reply With Quote
  #16    
Old December 11th, 2013 (03:18 AM). Edited December 11th, 2013 by Chrisario.
Chrisario's Avatar
Chrisario
Friend code :0018 2912 2366 let me know
 
Join Date: Jul 2013
Location: In friend Safari
Age: 18
Gender: Male
Nature: Adamant
I need help with this where in the script should I put

here is something that a tried but this looks not right
[SPOILER]
Attached Thumbnails
Prof juniper non transparnet.PNG‎  
Reply With Quote
Reply
Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 07:09 AM.