기타

KGC, SG 필수 스크립트

by 백호 posted Feb 22, 2009
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄
KGC
$game_special_elements = {}
$imported = {}
$data_states = load_data("Data/States.rxdata")
$data_system = load_data("Data/System.rxdata")

위 스크립트는 어느 KGC 스크립트 보다 위에 있어야 됩니다


SG 필수1
#=============================================================================
# ** SG Settings Control
#=============================================================================
# sandgolem
# Version 3 (beta)
# 1.06.06
#=============================================================================
#
# Thanks Prexus, Saucetenuto, SephirothSpawn & Trickster!
# This script wouldn't exist without their help
#
#=============================================================================
#
# To check for updates or find more scripts, visit:
# http://www.gamebaker.com/rmxp/scripts/
#
# To use this script, copy it and insert it in a new section above "Main",
# under the default scripts and the SDK if you're using it.
#
# This script -MUST- be above all the SG Scripts, other than Loading Screen
# This script controls and saves all settings for the SG Scripts
#
# Have problems? You can leave me a message at:
# http://www.gamebaker.com/users/sandgolem
#
#=============================================================================
#
# These commands are explained better on pages where they're most useful.
#
# Commands added, can be used in event script:
#  sg_on('name')                    - turns that name to true
#  sg_on('name','name2','name3')
#  sg_off('name')                    - turns that name to false (off)
#  sg_off('name','name2','name3')
#  sg_st('word','name')              - turns name to the first value
#    or sg_st(#,'name','name2','name3')
#  sg_vst(var,'name1')              - Sets 'name' to what's in the variable
#  sg_vst(var,'name1','name2','name3')
#  sg_ar('name','','',#,...)        - creates a new array, replacing another
#                                      that has the same name
#  sg_ast('name','word','newword')  - turns the spot where word is in the
#                                      array to the newword
#  sg_ast('name',#,'newword') or    - turns what's placed at spot # in the
#    sg_ast('name',#,#)                array to the third option. Note: The
#                                      arrays start at 0, not 1
#  sg_2var(variable,'name')          - Should only be used for #s
#                                      Turns the variable to what's in 'name'
#  sg_2var(variable,'name','name2','name3')
#
# These are used to alter $game_sg in a more friendly way for non-scripters.
# Each command is for one setting ONLY. The ones with multiple names are for
# larger ones, like this:
#  $game_sg['encounter']['var'] = 5 would be sg_st(5,'encounter','var')
#
# You may also find a call script fix useful, allows lines to continue to the
# next:  http://www.gamebaker.com/rmxp/scripts/call-script-fix.htm
#
#=============================================================================

if $sg_loaded != true
  $data_sg = {}
end

$sg_defaults = {}

class SG_Start
  def construct(i)
    if $sg_defaults[i] == false
      $game_sg[i] = false
    elsif $sg_defaults[i] == nil
      $game_sg[i] = nil
    elsif $sg_defaults[i] == true
      $game_sg[i] = true
    elsif $sg_defaults[i].is_a?(Fixnum)
      $game_sg[i] = $sg_defaults[i]
    else
      $game_sg[i] = $sg_defaults[i].clone
    end
  end
 
  def start_game
    $game_sg = {}
    sg_temp = $sg_defaults.keys
    for i in 0...sg_temp.size
      construct(sg_temp[i])
    end
  end
end

class Scene_Title
  alias sandgolem_settings_title_newgame command_new_game
  def command_new_game
    sg_temp = SG_Start.new
    sg_temp.start_game
    sg_temp = nil
    sandgolem_settings_title_newgame
  end
end

def sg_makesetting(name,name2,name3,setting)
  if name2 == nil
    $game_sg[name.downcase] = setting
  elsif name3 == nil
    $game_sg[name.downcase][name2.downcase] = setting
  elsif name3 != nil
    $game_sg[name.downcase][name2.downcase][name3.downcase] = setting
  end
end

def sg_on(name,name2=nil,name3=nil)
  sg_makesetting(name,name2,name3,true)
end
 
def sg_off(name,name2=nil,name3=nil)
  sg_makesetting(name,name2,name3,false)
  return true # 10 bonus points if you know why this is there! :)
end
 
def sg_st(set,name,name2=nil,name3=nil)
  sg_makesetting(name,name2,name3,set)
  return true # same reason, just incase
end

def sg_set(name,set) # Compatability
  sg_makesetting(name,nil,nil,set)
  return true # same reason, just incase
end

def sg_vst(set,name,name2=nil,name3=nil)
  sg_makesetting(name,name2,name3,$game_variables[set])
end

def sg_ar(array_name_string, *args)
  for i in 0...args.size
    if args[i].is_a?(String)
      args[i] = args[i].chomp
    end
  end
  $game_sg[array_name_string.downcase] = args
end

def sg_ast(array_name_string, changing, new)
  sg_temp = $game_sg[array_name_string]
  sg_temp2 = 0
  if changing.is_a?(String)
    loop do
      if sg_temp2 > sg_temp.size
        p 'Setting to change with sg_ast does not exist! Contact game creator'
        p 'Array named:', array_name_string, sg_temp
        p 'Attempted to change:', changing
        return
      end
      if sg_temp[sg_temp2] == changing
        sg_temp[sg_temp2] = new.chomp
        $game_sg[array_name_string] = sg_temp
        return
      end
      sg_temp2 += 1
    end
  else
    sg_temp[changing] = new.chomp
    $game_sg[array_name_string] = sg_temp
  end
end

def sg_2var(sg1,sg2,sg3=nil,sg4=nil)
  if sg2.is_a?(String)
    sg2 = sg2.downcase
  end
  if sg3 == nil
    $game_variables[sg1] = $game_sg[sg2].to_i
  else
    if sg3.is_a?(String)
      sg3 = sg3.downcase
    end
    if sg4 == nil
      $game_variables[sg1] = $game_sg[sg2][sg3].to_i
    else
      if sg4.is_a?(String)
        sg4 = sg4.downcase
      end
      $game_variables[sg1] = $game_sg[sg2][sg3][sg4].to_i
    end
  end
end

begin
  SDK.log("SG Settings Control", "sandgolem", 3, "1.06.06")
  @sg_temp == true
 
  class Scene_Save < Scene_File
    alias sandgolem_control_save_write write_data
    def write_data(file)
      sandgolem_control_save_write(file)
      Marshal.dump($game_sg, file)
    end
  end
 
  class Scene_Load < Scene_File     
    alias sandgolem_control_load_read read_data   
    def read_data(file)
      sg_temp = SG_Start.new
      sg_temp.start_game
      sandgolem_control_load_read(file)
      if !file.eof
        $game_sg = Marshal.restore(file)
        sg_temp2 = $sg_defaults.keys
        for i in 0...sg_temp2.size
          if !$game_sg.has_key?(sg_temp2[i])
            sg_temp.construct(sg_temp2[i])
          end
        end
      end
      sg_temp = nil
    end 
  end
  rescue
  if @sg_temp != true # if no sdk
   
    class Scene_Save < Scene_File
      alias sandgolem_control_save_write write_save_data
      def write_save_data(file)
        sandgolem_control_save_write(file)
        Marshal.dump($game_sg, file)
      end
    end
   
    class Scene_Load < Scene_File
      alias sandgolem_control_load_read read_save_data
        def read_save_data(file)
        sg_temp = SG_Start.new
        sg_temp.start_game
        sandgolem_control_load_read(file)
        if !file.eof
          $game_sg = Marshal.restore(file)
          sg_temp2 = $sg_defaults.keys
          for i in 0...sg_temp2.size
            if !$game_sg.has_key?(sg_temp2[i])
              sg_temp.construct(sg_temp2[i])
            end
          end
        end
        sg_temp = nil
      end
    end
  end
  @sg_temp = nil
end

SG 필수 2
#=============================================================================
# ** SG Window Control
#=============================================================================
# sandgolem
# Version 2
# 18.06.06
#=============================================================================
#
# Thanks Saucetenuto, SephirothSpawn & Trickster!
# This script wouldn't exist without their help
#
#=============================================================================

# This script is used to display windows in their various settings, and is
# not required for all of the SG Scripts to work

# Display types:

#  0 or nothing = Icon on left
#  1            = Icon on right, with string a little ahead
#  2            = Icon on right, with string on left
#  3            = Text name on right, same as default gold window
#  4            = Text name on right, better spacing
#  5            = Text name on right, with string on left
#  6            = Text name on left
#  7            = Text name on left, followed by a :
#  8            = Icon only, centered in the window
#  9            = Text only, centered in the window
#  10          = String only, centered in the window
#  11          = Icon on right, with string a little more ahead

#=============================================================================
#
# To check for updates or find more scripts, visit:
# http://www.gamebaker.com/rmxp/scripts/
#
# To use this script, copy it and insert it in a new section above "Main",
# but under the default scripts and the SDK if you're using it. This script
# MUST be above all the SG Scripts that require it
#
# Have problems? You can leave me a message at:
# http://www.gamebaker.com/users/sandgolem
#
#=============================================================================

begin
  SDK.log("SG Window Control", "sandgolem", 2, "18.06.06")
  rescue
end

class Window_Base < Window
 
  def sg_draw_window(type,width,icon,text,string)
    if icon == nil
      icon = RPG::Cache.icon('049-Skill06')
    else
      icon = RPG::Cache.icon(icon)
    end
    if string == nil
      string = ' '
    end
    if text == nil
      text = ''
    end
    width -= 32
    cx = contents.text_size(text).width
    self.contents.clear
    case type.to_i
    when 0
      self.contents.draw_text(4, 0, width-8, 32, string, 2)
      src_rect = Rect.new(0, 0, 32, 32)
      self.contents.blt(0, 4, icon, src_rect)
    when 1
      self.contents.draw_text(4, 0, width-28, 32, string, 2)
      src_rect = Rect.new(0, 0, 32, 32)
      self.contents.blt(width-24, 4, icon, src_rect)
    when 2
      self.contents.draw_text(4, 0, width, 32, string)
      src_rect = Rect.new(0, 0, 32, 32)
      self.contents.blt(width-24, 4, icon, src_rect)
    when 3
      self.contents.draw_text(4, 0, width-8-cx, 32, string, 2)
      self.contents.font.color = system_color
      self.contents.draw_text(width-4-cx, 0, cx, 32, text, 2)
    when 4
      self.contents.draw_text(4, 0, width-14-cx, 32, string, 2)
      self.contents.font.color = system_color
      self.contents.draw_text(width-4-cx, 0, cx, 32, text, 2)
    when 5
      self.contents.draw_text(4, 0, width, 32, string)
      self.contents.font.color = system_color
      self.contents.draw_text(width-4-cx, 0, cx, 32, text, 2)
    when 6
      self.contents.draw_text(4, 0, width-8, 32, string, 2)
      self.contents.font.color = system_color
      self.contents.draw_text(4, 0, cx, 32, text)
    when 7
      self.contents.draw_text(4, 0, width-8, 32, string, 2)
      self.contents.font.color = system_color
      self.contents.draw_text(4, 0, cx, 32, text)
      self.contents.draw_text(cx+4, 0, 8, 32, ':')
    when 8
      cx = width / 2 - 12
      src_rect = Rect.new(0, 0, 32, 32)
      self.contents.blt(cx, 4, icon, src_rect)
    when 9
      self.contents.draw_text(0, 0, width, 32, text, 1)
    when 10
      self.contents.draw_text(0, 0, width, 32, string, 1)
    when 11
      self.contents.draw_text(4, 0, width-34, 32, string, 2)
      src_rect = Rect.new(0, 0, 32, 32)
      self.contents.blt(width-24, 4, icon, src_rect)
    end
  end
end

SG 스크립트 처음꺼는 어느 SG 스크립트보다 위에 있어야 되며
두번째꺼는 없어도 되는게 있지만, 없으면 안되는게 있으니,
첫번째거 바로 아래 넣는것을 추천