i get this error trying to start the game:
??'sodoku'? ? 0
nomethoderror
?
undefined method 'state' for sdk:module
sdk script:
#==============================================================================
# ** SDK
#==============================================================================
module SDK
#--------------------------------------------------------------------------
# * Version & Parts Log
#--------------------------------------------------------------------------
Version = 2.2
Parts = [1]
#--------------------------------------------------------------------------
# * Show Disable Messages
#--------------------------------------------------------------------------
Show_Error_Disable_Message = true
Show_Method_Overwrite_Error = true
#--------------------------------------------------------------------------
# * Script, Alias, Overwrite & Method Branch Log Logging
#
# List : 'script' => [scripter, version, date]
# Enabled : 'script' => boolean
# Aliases : 'script' => [ [class, old, new], ... ]
# Overwrites : 'script' => [ [class, method], ... ]
# Branches : [class, method] => [ method, ... ]
#--------------------------------------------------------------------------
@list = {}
@enabled = {}
@aliases = {}
@overwrites = {}
@method_branch_log = {}
@enabled.default = false
@aliases.default = []
@overwrites.default = []
@last_script = 'SDK'
#--------------------------------------------------------------------------
# * Logs a custom script
#--------------------------------------------------------------------------
def self.log(script, name, ver, date)
# Logs Script
@list[script] = [name, ver, date]
# Enables Script
@enabled[script] = true
# Sets Last Script
@last_script = script
end
#--------------------------------------------------------------------------
# * Logs an alias
#--------------------------------------------------------------------------
def self.log_alias(classname, oldmethodname, newmethodname)
# Gets Value
value = [classname, oldmethodname, newmethodname]
# Convert Values to Symbols
value.collect! { |x| (x.is_a?(Symbol) ? x : x.to_s.to_sym) }
# Creates Array
@aliases[@last_script] = [] unless @aliases.has_key?(@last_script)
# Stop if Method Logged
return if @aliases[@last_script].include?(value)
# Logs Alias
@aliases[@last_script] << value
# Check for overwrites
self.check_for_overwrites(value) if Show_Method_Overwrite_Error
end
#--------------------------------------------------------------------------
# * Logs an overwrite
#--------------------------------------------------------------------------
def self.log_overwrite(classname, methodname)
# Gets Value
value = [classname, methodname]
# Convert Values to Symbols
value.collect! { |x| (x.is_a?(Symbol) ? x : x.to_s.to_sym)}
# Creates Array
@overwrites[@last_script] = [] unless @overwrites.has_key?(@last_script)
# Stop if Overwrite Logged
return if @overwrites[@last_script].include?(value)
# Log Overwrite
@overwrites[@last_script] << value
# Check for aliases
self.check_for_aliases(value) if Show_Method_Overwrite_Error
end
#--------------------------------------------------------------------------
# * Logs an method branch
#--------------------------------------------------------------------------
def self.log_branch(classname, methodname, *sub_methods)
# Creates Key
key = [classname, methodname]
# Convert Values to Symbols
key.collect! { |x| (x.is_a?(Symbol) ? x : x.to_s.to_sym)}
# Creates Sub Method List (if none yet recorded)
@method_branch_log[key] = [] unless @method_branch_log.has_key?(key)
# Adds New Sub Methods
@method_branch_log[key] << sub_methods
# Organize Sub Method List
@method_branch_log[key].flatten!
@method_branch_log[key].uniq!
end
#--------------------------------------------------------------------------
# * Check Requirements
#--------------------------------------------------------------------------
def self.check_requirements(version = 2.2, parts = [1], scripts = [])
# Start Missing Requirements
missing_reqs = {}
# Checks Version
unless Version >= version
missing_reqs[0] = version
end
# Checks Required Part
for part in parts
unless Parts.include?(part)
missing_reqs[1] = parts
break
end
end
# Checks Required Scripts
if scripts.is_a?(Array)
for script in scripts
unless self.enabled?(script)
missing_reqs[2] = [] unless missing_reqs.has_key?(2)
missing_reqs[2] << script
end
end
elsif scripts.is_a?(Hash)
scripts.each do |script, v|
if self.enabled?(script) == false
missing_reqs[2] = [] unless missing_reqs.has_key?(2)
missing_reqs[2] << script
next
else
if @list[script][1] < v
missing_reqs[3] = {} unless missing_reqs.has_key?(3)
missing_reqs[3][script] = v
end
end
end
end
# If Script Needing Disabled
unless missing_reqs.size == 0
# Disable Script
self.disable(@last_script)
# If Show Auto Disable Script Message
if Show_Error_Disable_Message
# Show Error Message
self.auto_disable_script_message(@last_script, missing_reqs)
end
end
end
#--------------------------------------------------------------------------
# * Enabled Test
#--------------------------------------------------------------------------
def self.enabled?(script, version = nil)
if version != nil && @list.has_key?(script)
return false unless @list[script][1] >= version
end
return @enabled[script]
end
#--------------------------------------------------------------------------
# * Enables the passed script
#--------------------------------------------------------------------------
def self.enable(script)
@enabled[script] = true
end
#--------------------------------------------------------------------------
# * Disables the passed script
#--------------------------------------------------------------------------
def self.disable(script)
# Disable Script
@enabled[script] = false
end
#--------------------------------------------------------------------------
# * Returns a list of custom scripts
#--------------------------------------------------------------------------
def self.return_log(script = '')
return script == '' || @list.include?(script) == false ?
self.sorted_log : @list[script]
end
#--------------------------------------------------------------------------
# * Returns a list of enabled scripts
#--------------------------------------------------------------------------
def self.return_enabled_log(script = '')
return script == '' || self.enabled?(script) == false ?
self.sorted_enabled_log : @enabled[script]
end
#--------------------------------------------------------------------------
# * Returns alias log
#--------------------------------------------------------------------------
def self.return_alias_log(script = '')
return script == '' || @list.include?(script) == false ?
self.sorted_alias_log : @aliases[script]
end
#--------------------------------------------------------------------------
def self.return_overwrite_log(script = '')
return script == '' || @list.include?(script) == false ?
self.sorted_alias_log : @aliases[script]
end
#--------------------------------------------------------------------------
# * Writes a list of the custom scripts to a file
#--------------------------------------------------------------------------
def self.write(scripts = self.sorted_log)
# Opens / Creates File & Writes Script Listings
file = File.open('Scripts List.txt', 'wb')
for script in scripts
l = "#{script[0]} : #{script[1]} Version #{script[2]} (#{script[3]})\n"
file.write(l)
end
file.close
end
#--------------------------------------------------------------------------
# * Writes a list of the enabled scripts to a file
#--------------------------------------------------------------------------
def self.write_enabled
self.write(self.sorted_enabled_log)
end
#--------------------------------------------------------------------------
# * Writes a list of the aliases
#--------------------------------------------------------------------------
def self.write_aliases
# Opens / Creates File & Writes Script Listings
file = File.open('Alias List.txt', 'wb')
for sname in @aliases.keys.sort
for a in @aliases[sname]
c, o, n = "Class: #{a[0]}", "Old Name: #{a[1]}", "New Name: #{a[2]}"
file.write("#{sname} - #{c} - #{o} - #{n}\n")
end
end
file.close
end
#--------------------------------------------------------------------------
# * Writes a list of the overwrites
#--------------------------------------------------------------------------
def self.write_overwrites
# Opens / Creates File & Writes Script Listings
file = File.open('Overwrites List.txt', 'wb')
for sname in @overwrites.keys.sort
for o in @overwrites[sname]
file.write("#{sname} - Class: #{o[0]} - Method:#{o[1]}\n")
end
end
file.close
end
#--------------------------------------------------------------------------
# * Sort Script List
#
# sort_type : 0 - Scripter, 1 - Script Name
#--------------------------------------------------------------------------
def self.sorted_log(sort_type = 0)
# Creates Sorted Nested Array
nested = @list.sort do |a, b|
sort_type == 0 ? a[1][0] <=> b [1][0] : a[0] <=> b[0]
end
# Creates Sorted List
lst = []
nested.each do |x|
x.flatten!
lst << ((sort_type == 0 ? [x[1], x[0]] : [x[0], x[1]]) << x[2] << x[3])
end
# Return List
return lst
end
#--------------------------------------------------------------------------
# * Sort Enabled Script List
#
# sort_type : 0 - Scripter, 1 - Script Name
#--------------------------------------------------------------------------
def self.sorted_enabled_log(sort_type = 0)
# Creates Sorted Nested Array
nested = @list.sort do |a, b|
sort_type == 0 ? a[1][0] <=> b [1][0] : a[0] <=> b[0]
end
# Creates Sorted List
lst = []
nested.each do |x|
next unless @enabled[x[0]]
x.flatten!
lst << ((sort_type == 0 ? [x[1], x[0]] : [x[0], x[1]]) << x[2] << x[3])
end
# Return List
return lst
end
#--------------------------------------------------------------------------
# * Show Auto Disable Error Message
#
# Missing Reqs = { type => parameters }
#
# Type 0 : Not High Enough Version
# Parameters : [version_required]
#
# Type 1 : SDK Parts Missing
# Parameters : [part, ...]
#
# Type 2 : Missing Script
# Parameters : [script, ...]
#
# Type 3 : Not High Enough Script Version
# Parameters : {script => version, ...}
#--------------------------------------------------------------------------
def self.auto_disable_script_message(script, missing_reqs)
# Start Message Text
t = 'The following script has been disabled : ' + script
# If Missing Reqs Specified
unless missing_reqs.size == 0
# Adds Message Text
t += ' for the following reasons : '
ta = []
# Pass Through Missing Reqs
missing_reqs.each do |type, parameters|
# Branch By Type
case type
when 0 # Not High Enough SDK Version
ta << 'SDK version not high enough version. Please update to ' +
'at least version ' + parameters.to_s
when 1 # Missing SDK Part
ta << 'You are missing part of the SDK. Please add the following ' +
'parts - ' + parameters.join(' & ')
when 2 # Missing Scripts
parameters.each do |script|
ta << 'Script missing - ' + script
end
when 3 # Not High Enough Version
parameters.each do |script, v|
ta << 'Script not high enough version - ' + script +
' (Required ' + v.to_s + 'or higher)'
end
end
end
# Add Message Text
t += ta.join(' ; ')
end
# Print Error Message
p t
end
#--------------------------------------------------------------------------
# * Check for Overwrites
#
# Value = [classname, oldmethodname, newmethodname]
#--------------------------------------------------------------------------
def self.check_for_overwrites(value)
# Pass Through All Method Branches
@method_branch_log.each do |classmethod, submethods|
# If Class name matches & Sub Methods Include Method
if classmethod[0] == value[0] && submethods.include?(value[1])
# Pass Throug All Script Overwrites
@overwrites.each do |script, overwrites|
# Pass Through Overwrite List
overwrites.each do |cm|
# If Method Matches
if classmethod == cm
# Print Error
p 'The following script will not work : ' + @last_script,
'Reason : The (' + script + ') overwrites the ' +
'method ' + cm[1].to_s + ' erasing the branched method ' +
value[1].to_s + ' branched from ' + value[0].to_s + ' that ' +
'the ' + script + ' uses'
return
end
end
end
end
end
end
#--------------------------------------------------------------------------
# * Check for Aliases
#
# Value = [classname, methodname]
#--------------------------------------------------------------------------
def self.check_for_aliases(value)
# Check If Method Ever Aliased
@aliases.each do |script, list|
# Pass Through Alias List
list.each do |con|
# If Class & Method Match
if con[0] == value[0] && con[1] == value[1]
# Print Error
p 'The following script will not work : ' + script,
'Reason : The (' + @last_script + ') overwrites the method ' +
value[1].to_s + ' aliased from ' + "#{con[1]} to #{con[2]}" +
'found in class ' + value[0]
end
end
end
# Pass Through All Method Branches
@method_branch_log.each do |classmethod, submethods|
# If Class name matches & Sub Methods Include Method
if classmethod == value
# Pass Through Aliases
@aliases.each do |script, list|
# Pass Through Alias List
list.each do |con|
# If Sub Methods Include Old Method
if submethods.include?(con[1])
# Print Error
p 'The following script will not work : ' + script,
'Reason : The (' + @last_script + ') overwrites the ' +
'method ' + con[1].to_s + ' erasing the branched method ' +
value[1].to_s + ' branched from ' + value[0].to_s + ' that '+
'the ' + script + ' uses'
end
end
end
end
end
end
#--------------------------------------------------------------------------
# * Evals text from an input source
#--------------------------------------------------------------------------
def self.text_box_input(element, index)
return if index == 0
commands = element.split('|')
eval(commands[index])
end
#--------------------------------------------------------------------------
# * Returns a list of parameters from an event's comments
#--------------------------------------------------------------------------
def self.event_comment_input(*args)
parameters = []
list = *args[0].list
elements = *args[1]
trigger = *args[2]
return nil if list == nil
return nil unless list.is_a?(Array)
for item in list
next unless item.code == 108 || item.code == 408
if item.parameters[0] == trigger
start = list.index(item) + 1
finish = start + elements
for id in start...finish
end
next if !list[id]
parameters.push(list[id].parameters[0])
return parameters
end
end
return nil
end
end
#==============================================================================
# ** SDK::Scene Base
#==============================================================================
class SDK::Scene_Base
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
main_variable # Main Variable Initialization
main_spriteset # Main Spriteset Initialization
main_sprite # Main Sprite Initialization
main_window # Main Window Initialization
main_audio # Main Audio Initialization
main_transition # Main Transition Initialization
loop do # Scene Loop
main_loop # Main Loop
break if main_break? # Break If Breakloop Test
end # End Scene Loop
Graphics.freeze # Prepare for transition
main_dispose # Main Dispose
main_end # Main End
end
#--------------------------------------------------------------------------
# * Main Processing : Variable Initialization
#--------------------------------------------------------------------------
def main_variable ; end
#--------------------------------------------------------------------------
# * Main Processing : Spriteset Initialization
#--------------------------------------------------------------------------
def main_spriteset ; end
#--------------------------------------------------------------------------
# * Main Processing : Sprite Initialization
#--------------------------------------------------------------------------
def main_sprite ; end
#--------------------------------------------------------------------------
# * Main Processing : Window Initialization
#--------------------------------------------------------------------------
def main_window ; end
#--------------------------------------------------------------------------
# * Main Processing : Audio Initialization
#--------------------------------------------------------------------------
def main_audio ; end
#--------------------------------------------------------------------------
# * Main Processing : Transition
#--------------------------------------------------------------------------
def main_transition
Graphics.transition
end
#--------------------------------------------------------------------------
# * Main Processing : Loop
#--------------------------------------------------------------------------
def main_loop
Graphics.update # Update game screen
Input.update # Update input information
main_update # Update scene objects
update # Update Processing
end
#--------------------------------------------------------------------------
# * Main Processing : Break Loop Test
#--------------------------------------------------------------------------
def main_break?
return $scene != self # Abort loop if sceen is changed
end
#--------------------------------------------------------------------------
# * Main Processing : Disposal
#--------------------------------------------------------------------------
def main_dispose
# Passes Through All Instance Variables
self.instance_variables.each do |object_name|
# Evaluates Object
object = eval object_name
# Pass Object To Auto Dispose
auto_dispose(object)
end
end
#--------------------------------------------------------------------------
# * Main Processing : Ending
#--------------------------------------------------------------------------
def main_end ; end
#--------------------------------------------------------------------------
# * Main Processing : Update
#--------------------------------------------------------------------------
def main_update
# Passes Through All Instance Variables
self.instance_variables.each do |object_name|
# Evaluates Object
object = eval object_name
# Pass Object To Auto Update
auto_update(object)
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update ; end
#--------------------------------------------------------------------------
# * Main Processing : Auto Dispose
#--------------------------------------------------------------------------
def auto_dispose(object)
# Return If Object isn't a Hash, Array or Respond to Dispose
return unless object.is_a?(Hash) || object.is_a?(Array) ||
object.respond_to?(:dispose)
# If Hash Object
if object.is_a?(Hash)
object.each do |key, value|
# Pass Key & Value to Auto Dispose
auto_dispose(key) ; auto_dispose(value)
end
return
end
# If Array Object
if object.is_a?(Array)
# Pass All Object to Auto Dispose
object.each {|obj| auto_dispose(obj)}
return
end
# If Responds to Dispose
if object.respond_to?(:dispose)
# If Responds to Disposed? && is Disposed or Responds to Disable
# Dispose and dispose is disabled
if (object.respond_to?(:disposed?) && object.disposed?) ||
(object.respond_to?(:disable_dispose?) && object.disable_dispose?)
# Return
return
end
# Dispose Object
object.dispose
end
end
#--------------------------------------------------------------------------
# * Main Processing : Auto Update
#--------------------------------------------------------------------------
def auto_update(object)
# Return If Object isn't a Hash, Array or Respond to Update
return unless object.is_a?(Hash) || object.is_a?(Array) ||
object.respond_to?(:update)
# If Hash Object
if object.is_a?(Hash)
object.each do |key, value|
# Pass Key & Value to Auto Update
auto_update(key) ; auto_update(value)
end
return
end
# If Array Object
if object.is_a?(Array)
# Pass All Object to Auto Update
object.each {|obj| auto_update(obj)}
return
end
# If Responds to Update
if object.respond_to?(:update)
# If Responds to Disable Update & Update Disabled
if object.respond_to?(:disable_update?) && object.disable_update?
# Return
return
end
# Update Object
object.update
end
end
end
#==============================================================================
# ** Object
#==============================================================================
class Object
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :disable_dispose, :disable_update
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
if @sdk_disableupdate_stack.nil?
alias_method :sdk_disableupdate_object_init, :initialize
@sdk_disableupdate_stack= true
end
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Original Initialization
sdk_disableupdate_object_init
# Turn Disable Flags Off
@disable_dispose, @disable_update = false, false
end
#--------------------------------------------------------------------------
# * Disable Dispose
#--------------------------------------------------------------------------
def disable_dispose?
return @disable_dispose
end
#--------------------------------------------------------------------------
# * Disable Update
#--------------------------------------------------------------------------
def disable_update?
return @disable_update
end
end
#==============================================================================
# ** Module
#==============================================================================
class Module
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
if @sdk_logalias_stack.nil?
alias sdk_aliaslog_aliasmethod alias_method
@sdk_logalias_stack= true
end
#--------------------------------------------------------------------------
# * Alias Method
#--------------------------------------------------------------------------
def alias_method(newmethodname, oldmethodname)
# Log Alias
SDK.log_alias(self, oldmethodname, newmethodname)
# Original Alias Method
sdk_aliaslog_aliasmethod(newmethodname, oldmethodname)
end
end
#==============================================================================
# ** Bitmap
#==============================================================================
class Bitmap
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :disable_dispose
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
if @sdk_bitmap_stack.nil?
alias_method :sdk_bitmap_init, :initialize
@sdk_bitmap_stack = true
end
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(*args)
# Original Initialization
sdk_bitmap_init(*args)
# Turn Disable Dispose ON
@disable_dispose = true
end
end
#==============================================================================
# ** RPG::Event::Page::Condition
#==============================================================================
class RPG::Event::Page::Condition
#--------------------------------------------------------------------------
# * Conditions Met?
#--------------------------------------------------------------------------
def conditions_met?(map_id, event_id)
# Switch 1 condition confirmation
if @switch1_valid && $game_switches[@switch1_id] == false
return false
end
# Switch 2 condition confirmation
if @switch2_valid && $game_switches[@switch2_id] == false
return false
end
# Variable condition confirmation
if @variable_valid && $game_variables[@variable_id] < @variable_value
return false
end
# Self switch condition confirmation
if @self_switch_valid
key = [map_id, event_id, @self_switch_ch]
if $game_self_switches[key] == false
return false
end
end
# Returns True
return true
end
end
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
# This class is for all in-game windows.
#==============================================================================
class Window_Base
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
return if self.disposed?
# Dispose if window contents bit map is set
if self.contents != nil
self.contents.dispose
end
super
end
end
#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
# This window deals with general command choices.
#==============================================================================
class Window_Command < Window_Selectable
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :commands
#--------------------------------------------------------------------------
# * Command
#--------------------------------------------------------------------------
def command(index = self.index)
return @commands[index]
end
#--------------------------------------------------------------------------
# * Commands
#--------------------------------------------------------------------------
def commands=(commands)
# Return if Commands Are Same
return if @commands == commands
# Reset Commands
@commands = commands
# Resets Item Max
item_max = @item_max
@item_max = @commands.size
# If Item Max Changes
unless item_max == @item_max
# Deletes Existing Contents (If Exist)
unless self.contents.nil?
self.contents.dispose
self.contents = nil
end
# Recreates Contents
self.contents = Bitmap.new(width - 32, @item_max * 32)
end
# Refresh Window
refresh
end
end
#==============================================================================
# ** Window_HorizCommand
#------------------------------------------------------------------------------
# This window deals with general command choices. (Horizontal)
#==============================================================================
class Window_HorizCommand < Window_Selectable
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :commands
attr_accessor :c_spacing
attr_accessor :alignment
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(width, commands, c_spacing = (width - 32) / commands.size)
# Compute window height from command quantity
super(0, 0, width, 64)
@commands = commands
@item_max = commands.size
@column_max = @item_max
@c_spacing = c_spacing
@alignment = 1
self.contents = Bitmap.new(@item_max * @c_spacing, height - 32)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Command
#--------------------------------------------------------------------------
def command(index = self.index)
return @commands[index]
end
#--------------------------------------------------------------------------
# * Commands
#--------------------------------------------------------------------------
def commands=(commands)
# Return if Commands Are Same
return if @commands == commands
# Reset Commands
@commands = commands
# Resets Item Max
item_max = @item_max
@item_max = @commands.size
@column_max = @item_max
# If Item Max Changes
unless item_max == @item_max
# Deletes Existing Contents (If Exist)
unless self.contents.nil?
self.contents.dispose
self.contents = nil
end
# Recreates Contents
self.contents = Bitmap.new(@item_max * @c_spacing, height - 32)
end
# Refresh Window
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
def draw_item(index, color)
command = commands[index]
x = index * @c_spacing + 4
self.contents.font.color = color
self.contents.draw_text(x, 0, @c_spacing - 8, 32, command, @alignment)
end
#--------------------------------------------------------------------------
# * Disable Item
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
self.cursor_rect.set(@c_spacing * @index, 0, @c_spacing, 32)
end
end
#==============================================================================
# ** Window_SaveFile
#------------------------------------------------------------------------------
# This window displays save files on the save and load screens.
#==============================================================================
class Window_SaveFile < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# file_index : save file index (0-3)
# filename : file name
#--------------------------------------------------------------------------
def initialize(file_index, filename)
super(0, 64 + file_index % 4 * 104, 640, 104)
self.contents = Bitmap.new(width - 32, height - 32)
@file_index = file_index
@filename = filename
@time_stamp = Time.at(0)
@file_exist = FileTest.exist?(@filename)
if @file_exist
file = File.open(@filename, "r")
@time_stamp = file.mtime
@characters = Marshal.load(file)
@frame_count = Marshal.load(file)
@game_system = Marshal.load(file)
@game_switches = Marshal.load(file)
@game_variables = Marshal.load(file)
@total_sec = @frame_count / Graphics.frame_rate
file.close
end
refresh
@selected = false
end
end
#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
# This interpreter runs event commands. This class is used within the
# Game_System class and the Game_Event class.
#==============================================================================
class Interpreter
#--------------------------------------------------------------------------
# * Script
#--------------------------------------------------------------------------
def command_355
# Set first line to script
script = @list[@index].parameters[0] + "\n"
# Loop
loop do
# If next event command is second line of script or after
if @list[@index+1].code == 655
# Add second line or after to script
script += @list[@index+1].parameters[0] + "\n"
# If event command is not second line or after
else
# Abort loop
break
end
# Advance index
@index += 1
end
# Evaluation
eval(script)
# Continue
return true
end
end
and the script i want to use:
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Sudoku Puzzles', 'SephirothSpawn', 1, '2006-08-06')
#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('Sudoku Puzzles')
#==============================================================================
# ** SudokuPuzzles
#==============================================================================
module SudokuPuzzles
#--------------------------------------------------------------------------
# * Create Solution File
#--------------------------------------------------------------------------
Create_Solution_File = true
#--------------------------------------------------------------------------
# * Sound Effects
#--------------------------------------------------------------------------
Puzzle_Solved_SE = load_data("Data/System.rxdata").decision_se
Puzzle_Unsolved_SE = load_data("Data/System.rxdata").buzzer_se
#--------------------------------------------------------------------------
# * Default Difficulty
#
# ~ How Many Will be showed upon start up
#--------------------------------------------------------------------------
Default_Difficulty = 35
#--------------------------------------------------------------------------
# * This Will Save All Solutions the Maker Comes Up With
#--------------------------------------------------------------------------
def self.save_solution(solution_table)
# Test For Saved Solution File
unless FileTest.exist?('Data/SudokuSolutions.rxdata')
save_data([], 'Data/SudokuSolutions.rxdata')
end
# Collects Saved Solution List
saved_solutions = load_data('Data/SudokuSolutions.rxdata')
# Saves List to Data File
saved_solutions << solution_table
# Resaves New Solution to File
save_data(saved_solutions, 'Data/SudokuSolutions.rxdata')
end
#--------------------------------------------------------------------------
# * Generate Solution
#--------------------------------------------------------------------------
def self.generate_solution
# Creates Solution Table Data
@solution = Table.new(9, 9)
# Assigns Each Tile a Number
81.times do
# Collects Cell Ranges
ranges = self.collect_cell_ranges
# If No Ranges
if ranges.nil?
self.generate_solution
return
end
# Gets Min Range
min_range = ranges.values.min
# Gets Index of Min Range
index = ranges.index(min_range)
# Gets Index X Y Coordinates
x = index % 9
y = index / 9
# Collects Ranges
range = self.collect_range(x, y)
# Sets Solution Value
@solution[x, y] = range[rand(range.size)]
end
# Saves Solution to Data File
self.save_solution(@solution)
end
#--------------------------------------------------------------------------
# * Collect Cell Ranges
#--------------------------------------------------------------------------
def self.collect_cell_ranges
# Starts Ranges Hash
ranges = {}
# Checks All Cells
for i in 0...81
# Gets X Y Coordinates
x = i % 9
y = i / 9
# If No Number in Cell
if @solution[x, y] == 0
# If No Possible Range For Cell
if self.collect_range(x, y).size == 0
# Restart Setup Solution
self.generate_solution
return
end
# Store Range
ranges = collect_range(x, y).size
end
end
# Return Ranges
return ranges
end
#--------------------------------------------------------------------------
# * Collects Possible Numbers For Cell
#--------------------------------------------------------------------------
def self.collect_range(x, y)
# Gets All Possible Numbers
range = (1..9).to_a
# Checks Column & Row Numbers And Removes Impossible Numbers
for i in 0...9
if range.include?(@solution[i, y])
range.delete(@solution[i, y])
end
if range.include?(@solution[x, i])
range.delete(@solution[x, i])
end
end
# Checks Sub-Cell And Removes Impossible Numbers
subcell_size = 3
subcell_x = x / subcell_size
subcell_y = y / subcell_size
for y_count in 0...subcell_size
for x_count in 0...subcell_size
x_ = subcell_x * subcell_size + x_count
y_ = subcell_y * subcell_size + y_count
if range.include?(@solution[x_, y_])
range.delete(@solution[x_, y_])
end
end
end
# Returns Possible Numbers
return range
end
end
#==============================================================================
# ** Game_SudokuPuzzles
#==============================================================================
class Game_SudokuPuzzles
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Starts Data
@data = []
end
#--------------------------------------------------------------------------
# * Get Puzzle Data
#--------------------------------------------------------------------------
def [](puzzle_id)
# Creates Unstarted Data
if @data[puzzle_id].nil?
@data[puzzle_id] = Game_SudokuPuzzle.new
end
return @data[puzzle_id]
end
#--------------------------------------------------------------------------
# * Set Puzzle Data
#--------------------------------------------------------------------------
def []=(puzzle_id, number_cells = SudokuPuzzles::Default_Difficulty)
# Creates Unstarted Data
@data[puzzle_id] = Game_SudokuPuzzle.new(number_cells)
end
#--------------------------------------------------------------------------
# * Reset Puzzle Data
#--------------------------------------------------------------------------
def reset_puzzle_data(puzzle_id)
n = number_cells = SudokuPuzzles::Default_Difficulty
unless @data[puzzle_id].nil?
n = @data[puzzle_id].number_cells
end
@data[puzzle_id] = Game_SudokuPuzzle.new(n)
end
end
#==============================================================================
# ** Game_SudokuPuzzle
#==============================================================================
class Game_SudokuPuzzle
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :number_cells
attr_reader :showncells
attr_reader :player_numbers
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(number_cells = SudokuPuzzles::Default_Difficulty)
# Picks Random Solution File
saved_solutions = load_data('Data/SudokuSolutions.rxdata')
@solution = saved_solutions[rand(saved_solutions.size)]
# Sets Up Shown Cell Numbers & Player Cells
@number_cells = number_cells
setup_showncells(number_cells)
# Creates Solution File
if SudokuPuzzles::Create_Solution_File
@solution.create_file('Sudoku Solution File.txt')
end
end
#--------------------------------------------------------------------------
# * Sets Up Shown Cells
#--------------------------------------------------------------------------
def setup_showncells(number_cells)
@showncells = Table.new(9, 9)
@player_numbers = Table.new(9, 9)
i = 0
until i == number_cells
x, y = rand(9), rand(9)
if @showncells[x, y] == 0
@showncells[x, y] = @solution[x, y]
@player_numbers[x, y] = @solution[x, y]
i += 1
end
end
end
#--------------------------------------------------------------------------
# * Solved
#--------------------------------------------------------------------------
def solved?
# Test Player Entered Each Number
for x in 0..8
for y in 0..8
return false if @player_numbers[x, y] == 0
end
end
# Test Rows
for i in 0..8
return false unless test_rows(i)
end
# Test Columns
for i in 0..8
return false unless test_columns(i)
end
# Test Sub-Cells
for i in 0..8
return false unless test_subcells(i)
end
# Return Solved
return true
end
#--------------------------------------------------------------------------
# * Test Row Numbers
#--------------------------------------------------------------------------
def test_rows(y)
numbers = []
for i in 0..8
return false if numbers.include?(@player_numbers[i, y])
numbers << @player_numbers[i, y]
end
return numbers.sort == (1..9).to_a
end
#--------------------------------------------------------------------------
# * Collect Column Numbers
#--------------------------------------------------------------------------
def test_columns(x)
numbers = []
for i in 0..8
return false if numbers.include?(@player_numbers[x, i])
numbers << @player_numbers[x, i]
end
return numbers.sort == (1..9).to_a
end
#--------------------------------------------------------------------------
# * Collect Sub-Cell Numbers
#--------------------------------------------------------------------------
def test_subcells(n)
numbers = []
subcell_x = n % 3
su