Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Can Someone Help Me With This?, Editing Some Scripts By A Newbie
SleepingSirenx
post Nov 1 2011, 08:08 AM
Post #1


The SMT Maniac
Group Icon

Group: Revolutionary
Posts: 125
Type: Developer
RM Skill: Undisclosed




I want to create a window inside the menu where when a certain command is confirmed, it will show a window saying "Quicksave Successful!"
Here is the script i've been experimenting
CODE
#============================================================================
# Confirmation Window
#============================================================================
  class Window_Confirmation < Window_Base
  def initialize
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = "Lucida Sans Unicode"
    self.contents.font.size = 18
    refresh
  end
#------------------------
# Confirmation Text
#------------------------
def refresh
  self.contents.clear
  self.contents.font.name = "Lucida Sans Unicode"
  self.contents.font.size = 18
  self.contents.draw.text = "Quicksave Successful!"
  self.contents.draw.text = "Returning to Title Screen"
end
end


But I always get an error saying syntax error occured on the "class Window_Confirmation < Window_Base" line. Anyone can help me with this? thank you.


__________________________

My First Game .... Yeah .... ~♥
I'm In Need Of A Team To Help Me WIth The Development Of My Game PM Me. :)
- DEMO's On Progress!

I Support This Projects!



Please Teach Me How To Script. :(
I'm Learning How To Script. But Still Teach Me How To Script :)
Damn THERMODYNAMICS! Makes My Head Spin!
Go to the top of the page
 
+Quote Post
   
maximusmaxy
post Nov 1 2011, 09:08 AM
Post #2


PZE whore
Group Icon

Group: Revolutionary
Posts: 131
Type: Scripter
RM Skill: Skilled




I fixed a couple of your errors, but I couldn't work out why you are getting a syntax error on the first line.

CODE
#============================================================================
# Confirmation Window
#============================================================================
class Window_Confirmation < Window_Base
  def initialize
    #i made the window size a bit smaller
    #super(x position, y position, width, height)
    super(160, 192, 320, 92)
    self.contents = Bitmap.new(width - 32, height - 32)
    #you only need to specify the font name and size once if it doesn't change
    self.contents.font.name = 'Lucida Sans Unicode'
    self.contents.font.size = 18
    refresh
  end
  #------------------------
  # Confirmation Text
  #------------------------
  def refresh
    self.contents.clear
    #all positions in a draw_text command are relative to the window
    #self.contents.draw_text(x position, y position, width, height, text)
    self.contents.draw_text(0,0,288,32,'Quicksave Successful!')
    self.contents.draw_text(0,32,288,32,'Returning to Title Screen')
  end
end


If you are getting the error when you start the game it may be something else other then this script,
but if not it may be a problem with how your creating the window.


__________________________
Check out the new PZE Forums! http://zeldaengine.net/index.php
Go to the top of the page
 
+Quote Post
   
Legacy
post Nov 1 2011, 03:21 PM
Post #3


B★RS Coding Ninja
Group Icon

Group: Global Mod
Posts: 1,414
Type: Scripter
RM Skill: Advanced
Rev Points: 15




If you are still getting an error, can you post a screen of the error box please happy.gif?


__________________________
Freelance Programmer (C#, C++, Ruby)
#onegameamonth


Have you seen the new Unity3D sections?..
Unity 3D Discussion
Unity Script Development
Unity Projects
Go to the top of the page
 
+Quote Post
   
SleepingSirenx
post Nov 1 2011, 09:56 PM
Post #4


The SMT Maniac
Group Icon

Group: Revolutionary
Posts: 125
Type: Developer
RM Skill: Undisclosed




I figured out why I was having a syntax error in the "class ..." line. I accidentally placed it upon the update command selection. My bad.
Now, does it require for me to create a scene for my said window? and where should i place it? here is the script i'm trying to edit (or destroy) .

CODE
#*********************************************************
#Final Fantasy VII menu setup
#*********************************************************
#To use:
#If you do not want Faces, go to line 94
#and change delete the # of draw_actor_graphic
#and put a # infront of draw_actor_face
#
#Create a new folder in the Characters folder, and call it Faces
#Adding faces: add a 80x80 picture with the same name as the characterset it
#corrosponds with in the Faces folder


#========================================
#�ˇ Window_Base
#--------------------------------------------------------------------------------
# Setting functions for the "Base"
#========================================


class Window_Base < Window

def draw_actor_face(actor, x, y)
face = RPG::Cache.character("Faces/" + actor.character_name, actor.character_hue)
fw = face.width
fh = face.height
src_rect = Rect.new(0, 0, fw, fh)
self.contents.blt(x - fw / 23, y - fh, face, src_rect)
end
end
def draw_actor_battler_graphic(actor, x, y)
  bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
  cw = bitmap.width
  ch = bitmap.height
  src_rect = Rect.new(0, 0, cw, ch)
  self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end

#========================================
#�ˇ Game_Map
#--------------------------------------------------------------------------------
# Setting functions for the Map
#========================================
class Game_Map

def name
$map_infos[@map_id]
end
end

#========================================
#�ˇ Window_Title
#--------------------------------------------------------------------------------
# Setting functions for the Title
#========================================
class Scene_Title
$map_infos = load_data("Data/MapInfos.rxdata")
for key in $map_infos.keys
$map_infos[key] = $map_infos[key].name
end
end




#==============================================================================
# �ˇ Window_MenuStatus
#------------------------------------------------------------------------------
#  Sets up the Choosing.
#==============================================================================

class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# Set up
#--------------------------------------------------------------------------
def initialize
  super(0, 0, 560, 454)
  self.contents = Bitmap.new(width - 32, height - 32)
  self.contents.font.name = "Arial"
  self.contents.font.size = 18
  refresh
  self.active = false
  self.index = -1
end
#--------------------------------------------------------------------------
# Drawing Info on Screen
#--------------------------------------------------------------------------
def refresh
  self.contents.clear
  @item_max = $game_party.actors.size
  for i in 0...$game_party.actors.size
    x = 94
    y = i * 110
    actor = $game_party.actors[i]
   # draw_actor_face(actor, 12, y + 90) #To get rid of the Face, put a "#" before the draw_ of this line
    draw_actor_graphic(actor, 48, y + 65) #and delete the "#" infront of draw of this line
    draw_actor_name(actor, x, y)
    draw_actor_level(actor, x + 144, y)
    draw_actor_state(actor, x + 280, y )
    draw_actor_exp(actor, x+ 144, y + 38)
    draw_actor_hp(actor, x, y + 38)
    draw_actor_sp(actor, x, y + 58)

  end
end
#--------------------------------------------------------------------------
# Update of Cursor
#--------------------------------------------------------------------------
def update_cursor_rect
  if @index < 0
    self.cursor_rect.empty
  else
    self.cursor_rect.set(0, @index * 110, self.width - 32, 96)
  end
end
end

#=======================================#
# �ˇWindow_GameStats                                                             #
# written by AcedentProne                                                          #
#------------------------------------------------------------------------------#

class Window_GameStats < Window_Base
def initialize
super(0, 0, 160, 60)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "Arial"
self.contents.font.size = 18
refresh
end

def refresh
self.contents.clear
#Drawing gold into separate commas by Dubealex
case $game_party.gold
   when 0..9999
     gold = $game_party.gold
   when 10000..99999
     gold = $game_party.gold.to_s
     array = gold.split(//)
     gold = array[0].to_s+array[1].to_s+","+array[2].to_s+array[3].to_s+array[4].to_s
   when 100000..999999
     gold = $game_party.gold.to_s
     array = gold.split(//)
     gold = array[0].to_s+array[1].to_s+array[2].to_s+","+array[3].to_s+array[4].to_s+array[5].to_s
   when 1000000..9999999
     gold = $game_party.gold.to_s
     array = gold.split(//)
     gold = array[0].to_s+","+array[1].to_s+array[2].to_s+array[3].to_s+","+array[4].to_s+array[5].to_s+array[6].to_s
   end
#Draw Gold
self.contents.font.color = system_color
gold_word = $data_system.words.gold.to_s
cx = contents.text_size(gold_word).width
cx2=contents.text_size(gold.to_s).width
self.contents.draw_text(4, 4, 120-cx-2, 32, gold_word)
self.contents.font.color = normal_color
self.contents.draw_text(124-cx2+1, 4, cx2, 32, gold.to_s, 2)
self.contents.font.color = system_color
# Draw "Time"
@total_sec = Graphics.frame_count / Graphics.frame_rate
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(4, -10, 120, 32, text, 2)
self.contents.font.color = system_color
self.contents.draw_text(4, -10, 120, 32, "Time")
end
#--------------------------------------------------------------------------
# Update of The count
#--------------------------------------------------------------------------
def update
super
if Graphics.frame_count / Graphics.frame_rate != @total_sec
   refresh
end
end
end

#==============================================================================
# �ˇ Window_Mapname
#------------------------------------------------------------------------------
# �@Draws the Map name
#==============================================================================

class Window_Mapname < Window_Base
#--------------------------------------------------------------------------
# Set up
#--------------------------------------------------------------------------
def initialize
super(0, 0, 320, 44)
self.contents = Bitmap.new(width - 60, height - 32)
self.contents.font.name = "Arial"
self.contents.font.size = 17
refresh
end
#--------------------------------------------------------------------------
# Draws info on screen
#--------------------------------------------------------------------------
def refresh
self.contents.clear

# Map Name
#map = $game_map.name
self.contents.font.color = system_color
self.contents.draw_text(4, -10, 220, 32, "Location")
self.contents.font.color =  normal_color
self.contents.draw_text(175, -10, 80, 32, $game_map.name)
end
end
#============================================================================
# Confirmation Window
#============================================================================
class Window_Confirmation < Window_Base
  def initialize
    #i made the window size a bit smaller
    #super(x position, y position, width, height)
    super(160, 192, 320, 92)
    self.contents = Bitmap.new(width - 32, height - 32)
    #you only need to specify the font name and size once if it doesn't change
    self.contents.font.name = 'Lucida Sans Unicode'
    self.contents.font.size = 18
    refresh
  end
  #------------------------
  # Confirmation Text
  #------------------------
  def refresh
    self.contents.clear
    #all positions in a draw_text command are relative to the window
    #self.contents.draw_text(x position, y position, width, height, text)
    self.contents.draw_text(0,0,288,32,'Quicksave Successful!')
    self.contents.draw_text(0,32,288,32,'Returning to Title Screen')
  end
end

#==============================================================================
# �ˇ Scene_Menu
#------------------------------------------------------------------------------
# FF7 menu layout as requested by AcedentProne.
#==============================================================================

class Scene_Menu
#--------------------------- edit-------------------------------
attr_reader :status_window
#/--------------------------- edit-------------------------------

def initialize(menu_index = 0)
@menu_index = menu_index
end
def main
    
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "Status"
    s5 = "Memory"
    s6 = "Quicksave"
    s7 = "Quit"


#--------------------------- edit-------------------------------  
# Command menu
   @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
@command_window.x = 640 - @command_window.width
@command_window.y = 480
@command_window.z = 110
@command_window.index = @menu_index
#If certain options are avaliable
if $game_party.actors.size == 0
   @command_window.disable_item(0)
   @command_window.disable_item(1)
   @command_window.disable_item(2)
   @command_window.disable_item(3)
end
if $game_system.save_disabled
   @command_window.disable_item(4)
end
#Showing location window
@map = Window_Mapname.new
@map.x = 640 - @map.width
@map.y = 0 - @map.height - 1
@map.z = 110
#Showing the game stats
@game_stats_window = Window_GameStats.new
@game_stats_window.x = 0 - @game_stats_window.width
@game_stats_window.y = 480 - @map.height - @game_stats_window.height
@game_stats_window.z =110
  
#Showing the Menu Status window
@status_window = Window_MenuStatus.new
@status_window.x = 640
@status_window.y = 8
@status_window.z = 100

    
Graphics.transition
loop do
   Graphics.update
   Input.update
   update
   if $scene != self
     break
   end
end
Graphics.freeze
@command_window.dispose
@game_stats_window.dispose
@status_window.dispose
@map.dispose
end
#--------------------------------------------------------------------------
#Defining the delay
#--------------------------------------------------------------------------
def delay(seconds)
for i in 0...(seconds * 1)
   sleep 0.01
   Graphics.update
end
end
#--------------------------------------------------------------------------
# Updating
#--------------------------------------------------------------------------
def update
@command_window.update
@status_window.update
@map.update
#Moving Windows inplace
gamepos = 640 - @game_stats_window.width
mappos = 480 - @map.height - 1
if @command_window.y > 0
@command_window.y -= 60
end
if @game_stats_window.x < gamepos
@game_stats_window.x += 80
end
if @map.y < mappos
@map.y += 80
end
if @status_window.x > 0
   @status_window.x -= 80
end
#Saying if options are active
if @command_window.active
   update_command
   return
end
if @status_window.active
   update_status
   return
end
end
#--------------------------------------------------------------------------
# Updating the Command Selection
#--------------------------------------------------------------------------
def update_command
# If B button is pushed
if Input.trigger?(Input::B)
   # Plays assigned SE
   $game_system.se_play($data_system.cancel_se)
   #Looping for moving windows out
    loop do
     if @command_window.y < 480
      @command_window.y += 40
     end
     if @game_stats_window.x > 0 - @game_stats_window.width
      @game_stats_window.x -= 40
     end
     if @map.y > 0 - @map.height
      @map.y -= 40
     end
     if @status_window.x < 640
      @status_window.x += 40
     end
     delay(0.5)
     if @status_window.x >= 640
      break
    end
   end
  # Go to Map
$scene = Scene_Map.new
   return
end
# If C button is pused
if Input.trigger?(Input::C)
   # Checks actor size
   if $game_party.actors.size == 0 and @command_window.index < 4
     # plays SE
     $game_system.se_play($data_system.buzzer_se)
     return
   end
   case @command_window.index
   when 0  
     $game_system.se_play($data_system.decision_se)
     loop do
     if @command_window.y < 480
      @command_window.y += 40
     end
     if @game_stats_window.x > 0 - @game_stats_window.width
      @game_stats_window.x -= 40
     end
     if @map.y > 0 - @map.height
      @map.y -= 40
     end
     if @status_window.x < 640
      @status_window.x += 40
     end
     delay(0.5)
     if @status_window.x >= 640
      break
    end
   end
     $scene = Scene_Item.new
   when 1
     $game_system.se_play($data_system.decision_se)
     @command_window.active = false
     @status_window.active = true
     @status_window.index = 0
      when 2  
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
   when 3  
     $game_system.se_play($data_system.decision_se)
     @command_window.active = false
     @status_window.active = true
     @status_window.index = 0

   when 4
     if $game_system.save_disabled
       $game_system.se_play($data_system.buzzer_se)
       return
     end
     $game_system.se_play($data_system.decision_se)
     loop do
     if @command_window.y < 480
      @command_window.y += 40
     end
     if @game_stats_window.x > 0 - @game_stats_window.width
      @game_stats_window.x -= 40
     end
     if @map.y > 0 - @map.height
      @map.y -= 40
     end
     if @status_window.x < 640
      @status_window.x += 40
     end
     delay(0.5)
     if @status_window.x >= 640
      break
    end
   end
    $scene = Scene_Save.new
    when 5
      #Play Decision SE
      $game_system.se_play($data_system.decision_se)
      # Quicksave Game
      $game_system.map_quicksave
      delay(0.5)
      #Return to Title Screen
      $scene = Scene_Title.new
    when 6
     $game_system.se_play($data_system.decision_se)
     loop do
     if @command_window.y < 480
      @command_window.y += 40
     end
     if @game_stats_window.x > 0 - @game_stats_window.width
      @game_stats_window.x -= 40
     end
     if @map.y > 0 - @map.height
      @map.y -= 40
     end
     if @status_window.x < 640
      @status_window.x += 40
     end
     delay(0.5)
     if @status_window.x >= 640
      break
    end
   end
      $scene = Scene_End.new
   return
end
end
#--------------------------------------------------------------------------
# Updating Status Screen
#--------------------------------------------------------------------------
def update_status
if Input.trigger?(Input::B)
   $game_system.se_play($data_system.cancel_se)
   @command_window.active = true
   @status_window.active = false
   @status_window.index = -1
   return
end
if Input.trigger?(Input::C)
   case @command_window.index
        when 1  # ƒXƒLƒ‹
        # ‚�‚ĚƒAƒNƒ^�[‚ĚŤs“���ŚŔ‚Ş 2 ˆČŹă‚̏ꍇ
        if $game_party.actors[@status_window.index].restriction >= 2
          # ƒuƒU�[ SE ‚đ‰‰‘t
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Śˆ’č SE ‚đ‰‰‘t
        $game_system.se_play($data_system.decision_se)
        # ƒXƒLƒ‹‰ć–Ę‚ɐŘ‚č‘�‚�
        $scene = Scene_Skill.new(@status_window.index)
        when 2
     $game_system.se_play($data_system.decision_se)
     loop do
     if @command_window.y < 480
      @command_window.y += 40
     end
     if @game_stats_window.x > 0 - @game_stats_window.width
      @game_stats_window.x -= 40
     end
     if @map.y > 0 - @map.height
      @map.y -= 40
     end
     if @status_window.x < 640
      @status_window.x += 40
     end
     delay(0.5)
     if @status_window.x >= 640
      break
    end
   end
     $scene = Scene_Equip.new(@status_window.index)
   when 3
     $game_system.se_play($data_system.decision_se)
     loop do
     if @command_window.y < 480
      @command_window.y += 40
     end
     if @game_stats_window.x > 0 - @game_stats_window.width
      @game_stats_window.x -= 40
     end
     if @map.y > 0 - @map.height
      @map.y -= 40
     end
     if @status_window.x < 640
      @status_window.x += 40
     end
     delay(0.5)
     if @status_window.x >= 640
      break
    end
   end
     $scene = Scene_Status.new(@status_window.index)
   end
   return
end
end
end
end



__________________________

My First Game .... Yeah .... ~♥
I'm In Need Of A Team To Help Me WIth The Development Of My Game PM Me. :)
- DEMO's On Progress!

I Support This Projects!



Please Teach Me How To Script. :(
I'm Learning How To Script. But Still Teach Me How To Script :)
Damn THERMODYNAMICS! Makes My Head Spin!
Go to the top of the page
 
+Quote Post
   
maximusmaxy
post Nov 2 2011, 05:00 AM
Post #5


PZE whore
Group Icon

Group: Revolutionary
Posts: 131
Type: Scripter
RM Skill: Skilled




There's a couple things you need to do to get the effect you desire.
The first thing you need to do is create your window object in your menu scene.

Find the main method in your menu scene, it looks like this:

CODE
def main
    
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "Status"
    s5 = "Memory"
    s6 = "Quicksave"
    s7 = "Quit"

#ect.

Anywhere under the word main you need to create the window like so.
Also you should set window visibility to false so you can't see it when you open the menu.
CODE
@confirmation_window = Window_Confirmation.new
@confirmation_window.visible = false

The main method should look something like this:

CODE
def main
    #create the confirmation window
    @confirmation_window = Window_Confirmation.new
    @confirmation_window.visible = false

    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "Status"
    s5 = "Memory"
    s6 = "Quicksave"
    s7 = "Quit"

#ect.


Then you need to find where you want to activate the window which I'm guessing is here:

CODE
when 5
      #Play Decision SE
      $game_system.se_play($data_system.decision_se)
      # Quicksave Game
      $game_system.map_quicksave
      delay(0.5)
      #Return to Title Screen
      $scene = Scene_Title.new


Instead of sending you back to scene title straight away we are going to show the window so it should look something like this

CODE
when 5
      #Play Decision SE
      $game_system.se_play($data_system.decision_se)
      # Quicksave Game
      $game_system.map_quicksave
      #show the confirmation window
      @confirmation_window.visible = true


After this we want it to check for your button input to send you back to the title, but we only want it to check for this said input when the window is showing. To do this we find the update section:

CODE
def update
@command_window.update
@status_window.update
@map.update
#ect.


and we're going to put in the check for your button input to exit to the title screen when the window is visible.

CODE
def update
#if the confirmation window is visible
if @confirmation_window.visible
  #if the input key is either C or X
  if Input.trigger?(Input::C) || if Input.trigger?(Input::B)
    #Play Decision SE
    $game_system.se_play($data_system.decision_se)
    #hide the confirmation window
    @confirmation_window.visible = false
    #exit to title scene
    $scene = Scene_Title.new
  end
  #cancel the rest of the update method
  return
end
@command_window.update
@status_window.update
@map.update
#ect.


Ok and finally we need to dispose the confirmation window to free it from the memory. Even though its not visible, it doesn't mean its not there. We dispose windows at the end of the main method. Find this section:

CODE
Graphics.freeze
@command_window.dispose
@game_stats_window.dispose
@status_window.dispose
@map.dispose
end


Now we are going to add the confirmation window to the list of other disposed windows.

CODE
Graphics.freeze
@command_window.dispose
@game_stats_window.dispose
@status_window.dispose
@map.dispose
#dispose the confirmation window aswell
@confirmation_window.dispose
end


And that should be it. I did this all from memory and haven't tested it at all because it's late and I'm tired wink.gif I may have forgotten something or I may have made a stupid spelling mistake so if it doesn't work or you can't figure it out I'll fix it tomorrow.


__________________________
Check out the new PZE Forums! http://zeldaengine.net/index.php
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 24th May 2013 - 03:16 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker