RME
RME copied to clipboard
[RME] Implementing a new way to declare commands
Implementing a new way to declare commands (preparatory work for new documentation).
Illustration:
# Command's declaration's illustration
RME::Command::declare({:name => :move_to,
:parameters => [
{:name => :id,
:description => "Event-to-move's identifier",
:type => RME::Command::ParameterType::PositiveInteger},
{:name => :x,
:description => "Targeted x coordinate",
:type => RME::Command::ParameterType::Coordinate},
{:name => :y,
:description => "Targeted y coordinate",
:type => RME::Command::ParameterType::Coordinate},
{:name => :ghostly,
:description => "Tells whether the event can move through anything or not",
:type => RME::Command::ParameterType::Boolean,
:default => false}
]}) { |id, x, y, ghostly| puts "Moving event n°#{id} to (#{x}, #{y}) (ghostly? #{ghostly})" }
# RME::Command::move_to(11, 27, 32)
=begin
Moving event n°11 to (27, 32) (ghostly? false)
=end
# RME::Command::move_to(0, 10, 11, true)
=begin
Moving event n°0 to (10, 11) (ghostly? true)
=end
# RME::Command::move_to(9, 12)
=begin
Invalid parameter: y (should be a Coordinate of a point in a cartesian coordinate system (i.e.: `x` or `y`)). Actual value is nil (i.e.: not provided). (RuntimeError)
=end
# RME::Command::move_to(-23, 1, 1)
=begin
Invalid parameter: id (should be a Positive integer). Actual value is -23 (RuntimeError)
=end