Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: Ryex on July 04, 2008, 02:04:23 pm

Title: [RESOLVED] short code to check event comments in the first line
Post by: Ryex on July 04, 2008, 02:04:23 pm
I need a short code that I can call with a Call script command and checks events in a line forward from the actor for a comment in the first line. and if that comment is the string your checking for it flips a self switch in that event to what you choose

you would call it like this

PLACE_CALL_SCRIPT_COMMAND_HERE('string checking for', #range to check, self switch setting to)

make sense?

I'm going to use this in a common event that is attached to a skill so when you use the skill on the map is activates events in range.
Title: Re: [Request] short code to check event comments in the first line
Post by: Blizzard on July 05, 2008, 07:12:46 am
This is what I use to test if the first line is a comment.

module CP
 
  def self.first_comment(event, comment)
    return (event.list.is_a?(Array) && event.list[0].code == 108 &&
        event.list[0].parameters[0] == comment)
  end
 
end


I use first line only because checking every line in all events on the map can create a massive lag problem. This here is the alternative that checks ALL lines which I, of course, don't recommend :

module CP
 
  def self.event_comment(event, comment)
    return (event.list.is_a?(Array) &&
        event.list.any? {|c| c.code == 108 && c.parameters[0] == comment})
  end
 
end


You can call them like:

CP.first_comment($game_map.events[ID], 'COMMENT_HERE')

CP.event_comment($game_map.events[ID], 'COMMENT_HERE')


Of course you can rename the "module CP" to whatever you want. ;) That call with return either true or false depending on whether the first line is a comment and matches the 'COMMENT_HERE' string. You can then simply change the state of a self switch. Self switches are identified an array which contains their map ID, their event's ID and their own ID (0, 1, 2 and 3 for A, B, C and D respectively). I suggest using this call if you operate events on the current map:

key = [$game_map.map_id, EVENT_ID, OWN_ID]
$game_self_switches[key] = true


or similar depending on whether you turn them on or off.
Title: Re: [Request] short code to check event comments in the first line
Post by: Phasedscar on July 05, 2008, 05:15:05 pm
I'm not exactly sure what the context of this is.  Are you talking about if an actor is facing an event and a condition is met the event's self switch will activate?
Title: Re: [Request] short code to check event comments in the first line
Post by: Ryex on July 13, 2008, 05:34:46 pm
sorry I was away for a week...

Ok thanks for your help now if I had a short code that checked the of event in a line facing the player

Diagram: ShowHide

(http://i15.photobucket.com/albums/a400/ryex/Exsamples/untitled3.jpg)


In the diagram the player is in said square facing left, the red line is the range if the range was three it would check the events in three squares in fount of the player. but is would check them in order from the fount.

for example it would check events in square 1 first and if their was the right comment it returns the event id and not check any of the other events, if there isn't then it would check square 2 and so on to the max or the range.

make sense?
Title: Re: [Request] short code to check event comments in the first line
Post by: Ryex on July 14, 2008, 08:28:39 pm
sorry clicked quote instead of modify by accident and was too lazy to go back and try again

If the above can be done I can merge the two methods to what I need Thanks to every one who has helped so far.

Title: Re: [Request] [Half Solved] short code to check event comments in the first line
Post by: Ryex on July 20, 2008, 04:59:24 pm
sorry but bump I did  after all it is only half solved! :^_^':