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.
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.
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?
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
(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?
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.
sorry but bump I did after all it is only half solved! :^_^':