기타

SG_Settings Control by sandgolem

by 백호 posted Feb 22, 2009
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄
http://www.gamebaker.com/rmxp/scripts/settings-control.htm
  sandgolem씨의 스크립트 설정을 조작하거나 저장하는 역할을 하는 스크립트로, 다른 스크립트들 위에 있어야 합니다.  몇몇 스크립트 사용시 필수.


#=============================================================================
# ** SG Settings Control
#=============================================================================
# sandgolem
# Version ZERO.b
# 3.04.06
#=============================================================================
#
# Thanks 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 and any that rewrite loading/saving.
#
# This script controls and saves all settings for the SG Scripts
#
# If you're adding new scripts to an old game and need to convert people's
# saved games, check the above site soon for SG Settings Converter
#
# Have problems? You can leave me a message at:
# http://www.gamebaker.com/users/sandgolem
#
#=============================================================================
#
# Commands added, can be used in event script:
#  sg_on('name')                    - turns that name to true
#  sg_off('name')                    - turns that name to nil (off)
#  sg_set('name','word')            - turns name to the following setting
#    or sg_set('name',#)             
#  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
#
# Be careful while setting arrays in the event script window, if it splits the
# line during a string your string will have a n attached (and won't work).
#
# I'll see about releasing a fix for that before this script is ver 1
#
#=============================================================================

$game_sg = { 'enabled' => true }

def sg_on(name)
  $game_sg[name.downcase] = true
end
 
def sg_off(name)
  $game_sg[name.downcase] = false
end
 
def sg_set(name,set)
  $game_sg[name.downcase] = 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

begin
  SDK.log("SG Script Control", "Sandgolem", 1, "24.03.06")
  @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)
      sandgolem_control_load_read(file)
      $game_sg = Marshal.load(file)
    end     
  end
 
  rescue
  if @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)
        sandgolem_control_load_read(file)
        $game_sg = Marshal.load(file)
      end     
    end
  end
  @temp = nil
end

# Don't change this unless you know what you're doing