Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

event commands can move?

Aran

Member

Okay, lookin in the help file for details on an event's list of event commands i stumble upon parameters and it reads: "Array containing the Move command arguments. The contents vary for each command."

my question:
RPG Maker XP Help File":386ca51t said:
"Array containing the Move command arguments. The contents vary for each command."
what the fuk?

okay, so now event commands can move, right?

no, seriously. a little help understanding this.
 
RMXP Help File":zjprqsay said:
RPG::MoveCommand
Data class for the Move command.

Superclass : Object
Referrer : RPG::MoveRoute
Attributes
code
Move command code.

parameters
Array containing the Move command arguments. The contents vary for each command.

Definition
Code:
module RPG
  class MoveCommand(code = 0, parameters = [])
    def initialize
      @code = code
      @parameters = parameters
    end
    attr_accessor :code
    attr_accessor :parameters
  end
end

An RPG::MoveCommand is a class object that holds information, which is used in the 'Set Move Route' event command. The information is held in RPG::MoveRoute

Code:
module RPG
  class MoveRoute
    def initialize
      @repeat = true
      @skippable = false
      @list = [RPG::MoveCommand.new]
    end
    attr_accessor :repeat
    attr_accessor :skippable
    attr_accessor :list
  end
end

Within the @list variable. If you wish to know what each @code, and @parameter for the RPG::MoveCommand objects is, check out Game_Character def move_type_custom.
 

Aran

Member

Gotcha. so why would it be necessary to be checking if the event can move when searching an event for comments? (that's what i'm doing)

and a second question would be, how do you check what the comment says?

i kno to use the syntax:
Code:
for [i]variable[/i] in 0...$game_map.events[[i]id[/i]].list[[i]id[/i]].code == 108]
when looking for a comment
 
... That's some fucked up syntax.

Go, grab the RMXP SDK v1.5, and check out this method:

def self.event_comment_input(*args)

Do you know what it does? EVERYTHING.

Code:
for event in $game_map.events.values
  parameters = SDK.event_comment_input(event, 4, 'Enemy Setup')

the arguments you send to the function are:

(event, elements, start_tag)

event is the event object, elements are how many 'Comments' are going to be after the first one found, and start_tag is the text that should appear in the comment where the list will be generated from.

For example, my Action Battle System:

Comment: ABS Setup
Comment: Name Ghost
Comment: Troop Ghosties
Comment: Trigger LOCAL A

To get this to work with the SDK Event Comment Input method, you'd do the following:

parameters = SDK.event_comment_input(<EventObject>, 3, 'ABS Setup')

It will scan the event commands until it finds a Comment that contains 'ABS Setup', and will then return the string elements of the next few comments (the number is determined by the second argument in the call, so in this case, 3.)

'parameters' would then return an array, that looks something like this:

["Name Ghost", "Troop Ghosties", "Trigger LOCAL A"]

See how that works?

---

As far as your first question, I have no idea wtf you are talking about.
 

Aran

Member

As much as I like that function in the SDK (but don't really like the SDK itself), the whole purpose of me doing this is for practice. I'll take shortcuts when I can finally do a nice long script... that works... (don't comment on how long that may take).

as for my second question from before, with this be it?:

Code:
if list[[i]id[/i]].code == "Hello World!"
#do whatever
 
You are completely off. Have you even read anything about the basics on Ruby? I'm really glad you are trying, and putting a lot of effort into it, but it honestly looks like you are starting from the middle and working your way outwards, rather than at the start and working to the end.

Okay, a <Game_Event> object has a variable called 'list', which you are looking for.

That variable contains an array of RPG::EventCommand objects, which have three variables available:
code: the event code (this is an integer value that represents what kind of event command is being used. Comments will return 108)
indent: This is useless, ignore it.
parameters: The description in the help file for this is WRONG. Parameters can be any number of things, depending on what type of event command it is. For example, if it is a Message Window command, the parameters would be a string. You can see what they are by looking in the Interpreter at how they are used.

So, lets say that the variable event is already set to a <Game_Event> object, so it's easy for us. You'd probably want to do this in a loop:
Code:
for event in $game_map.events.values
That will check every event on the map, one by one, using the variable name event.

Now, you'd want to check the event's list, so you can see what commands it has, and hopefully find the appropriate Comment.

Code:
for item in event.list
This will loop through all the event commands in the list, calling them item.

Code:
if item.code == 108
This will return true, if the code is a Comment, which is exactly what we want.

You can now determine the contents of the comment by checking that item's parameters variable.

Code:
comment = item.parameters[0]
You now officially have a variable set to the contents.

So this code would look like this:

Code:
for event in $game_map.events.values
  for item in event.list
    if item.code == 108
      comment = item.parameters[0]
    end
  end
end

If you want to test this, create a new map/project whatever, create an Event and give it a comment that says 'Hello World' and a Call Script. The EventCommand window show look as follows:

Code:
[color=green]Comment: Hello World[/color]
[color=grey]Call Script: event = $game_map.events[1]
for item in event.list
  if item.code == 108
    comment = item.parameters[0]
    print comment
  end
end[/color]

Try that out, and see how it works.
 

Aran

Member

That code works like a charm, but, Prex, I knew most of that. I learned one or two more tricks, but that's about it. However, since I understand 'parameters' (thanx to that splendid example) maybe now I can proceed.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top