Top Level Namespace

Defined Under Namespace

Modules: Audio, Graphics, Input, RPG Classes: Bitmap, Color, Font, Plane, RGSSError, RGSSReset, Rect, Sprite, Table, Tilemap, Tone, Viewport, Window

Instance Method Summary (collapse)

Instance Method Details

- (Object) load_data(filename)

Loads data from a file and constructs an object from the data. This method is functionally equivalent to using Marshal.load on a file's contents. However, this method also supports loading files from within encrypted archives.

Examples:

Loading game data

save_file = load_data('saved_game.rvdata2')
puts "Name: #{save_file.name}"

Parameters:

  • filename (String)

    Path of the file to load from.

Returns:

  • (Object)

See Also:



36
37
38
39
40
# File 'lib/functions.rb', line 36

def load_data(filename)
  File.open(filename, 'rb') do |f|
    Marshal.load(f)
  end
end

- (nil) msgbox(arg = nil, *args)

Displays a message box with the values of the arguments passed into this method. The arguments will be concatenated together without a separator. Any arguments that are not a string will have #to_s called on them.

Examples:

Displaying a pop-up

msgbox("You got #{gold} gold!")
# Displays a message box containing "You got ___ gold!"

Non-string values

msgbox("Number of items: ", items.count)
# Displays a message box containing "Number of items: ###"

Parameters:

  • arg (defaults to: nil)

    First argument to display.

  • args

    Additional arguments to display.

Returns:

  • (nil)

See Also:



71
72
73
# File 'lib/functions.rb', line 71

def msgbox(arg = nil, *args)
  fail NotImplementedError
end

- (nil) msgbox_p(obj, *objs)

Displays objects in a human-readable format in a message box. The message box is identical to the one presented by ##msgbox. The difference is that this method calls #inspect on all of the arguments and concatenates them together with new-lines.

Examples:

Quick debug output

save_file = load_data('saved_game.rvdata2')
msgbox_p(save_file)
# Displays a message box detailing the contents of the save file.

Multiple objects

msgbox_p("Party members:", party[0], party[1], party[2])
# Displays a message box listing party members.

Parameters:

  • obj

    First object to display.

  • objs

    Additional objects to display.

Returns:

  • (nil)

See Also:



90
91
92
# File 'lib/functions.rb', line 90

def msgbox_p(obj, *objs)
  msgbox obj.inspect, "\n", *(objs.flat_map { |obj| [obj, "\n"] }[0...-1])
end

- (nil) rgss_main { ... }

Evaluates the provided block one time only. Detects a reset within the block caused by a user pressing the F12 key and re-runs the block in the event of a reset. This method is usually placed after all of the other scripts. It is essentially the entry-point to the game.

Examples:

Typical usage

rgss_main { SceneManager.run }

Yields:

  • Block to execute when the game starts.

Returns:

  • (nil)


10
11
12
# File 'lib/functions.rb', line 10

def rgss_main(&block)
  fail NotImplementedError
end

- (void) rgss_stop

Note:

This does not return and will not cause #rgss_main to return either. The only way to abort out of this method is to reset the game (F12).

This method returns an undefined value.

Stops execution and causes the game window to repeatedly redraw. Any pending graphics effects (such as transitions) will finish.

Examples:

Freezing the game on completion

if game_over?
  rgss_stop
end


23
24
25
# File 'lib/functions.rb', line 23

def rgss_stop
  loop { Graphics.update }
end

- (nil) save_data(obj, filename)

Saves an object to a file. The data stored in the file can be loaded again by using #load_data.

Examples:

Saving game data

save_file = SaveFile.new(name)
save_data(save_file, 'saved_game.rvdata2')

Parameters:

  • obj (Object)

    Object to save.

  • filename (String)

    Path of the file to save to.

Returns:

  • (nil)

See Also:



51
52
53
54
55
56
# File 'lib/functions.rb', line 51

def save_data(obj, filename)
  File.open(filename, 'wb') do |f |
    Marshal.dump(obj, f)
  end
  nil
end