CODE:class Game_Event
attr_reader :id
end
module CP
def self.first_event_comment(event, comment)
return (event.list.is_a?(Array) && event.list[0].code == 108 &&
event.list[0].parameters[0] == comment)
end
def self.find_first_event(dir = $game_player.direction, range = 1, string = '')
case dir
when 2
(1..range).each {|i| $game_map.events.each_value {|event|
if event.x == $game_player.x && event.y == $game_player.y + i &&
CP.first_event_comment(event, string)
return event.id
end}}
when 4
(1..range).each {|i| $game_map.events.each_value {|event|
if event.y == $game_player.y && event.x == $game_player.x - i &&
CP.first_event_comment(event, string)
return event.id
end}}
when 6
(1..range).each {|i| $game_map.events.each_value {|event|
if event.y == $game_player.y && event.x == $game_player.x + i &&
CP.first_event_comment(event, string)
return event.id
end}}
when 8
(1..range).each {|i| $game_map.events.each_value {|event|
if event.x == $game_player.x && event.y == $game_player.y - i &&
CP.first_event_comment(event, string)
return event.id
end}}
end
return 0
end
def self.trigger(string, range, switch)
event_id = self.find_first_event($game_player.direction, range, string)
return if event_id == 0
key = [$game_map.map_id, event_id, switch]
$game_self_switches[key] = true
end
end
Purpose The Above Code dose the fallowing. when called like this
CP.trigger('string', range, switch)
It checks in fount of the player and finds the first event that has comment 'string' in the first line on the currently running page that is within range then it takes that event and switches self switch switch (it can be 0, 1, 2, 3, for a, b, c, or d) to on
Problem heres the problem I made a common event that calls the script like this
I then made a skill that calls that common event and gave the skill menu use and gave the fighter class access to it at lv 1
then I made an event in the first page I made a comment on the first line that said hi and on the second page I Required self switch a to be on and set it to auto run and made it do several things like text and battle processing. but when you used the skill nothing happened. I used the 'p' command to print things to test if things were working and they were the problem lies in flipping the self switch
and neither I nor Blizzard knows what going wrong
Of course I don't know what's going on since I wrote it out of my head. What do you expect? -_-
bliz even when you write something out of your head its good thought most of the code was already there you just reorganized it and optimized it
I mean that I found bugs and fixed them just by looking through the code. There could be another not so obvious bug.
is it possible to call the interpreter's method for changing selfswichs instead of making our own?
You still have to code that call. In the end it's the same.
I FIXED IT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :haha: :haha: :haha: :haha: :D 8)
I desired to inspect the interrupter further so I put an extra line the said
jest before it made the key
then I mad an event that just changed the self switch to a. it turns out that the window popped up with
"A"so you were wrong it is not
0,
1,
2,
3 for the self switches. instead it is
"A", "B",
"C",
"D"so when you call it you have to put the self switch in a capital quoted string
oh and this this is necessary right after changing the switch
$game_map.need_refresh = true
I tried it with out and it did not work
so here is the whole completed code that works
class Game_Event
attr_reader :id
end
module CP
def self.first_event_comment(event, comment)
return (event.list.is_a?(Array) && event.list[0].code == 108 &&
event.list[0].parameters[0] == comment)
end
def self.find_first_event(dir = $game_player.direction, range = 1, string = '')
case dir
when 2
(1..range).each {|i| $game_map.events.each_value {|event|
if event.x == $game_player.x && event.y == $game_player.y + i &&
CP.first_event_comment(event, string)
return event.id
end}}
when 4
(1..range).each {|i| $game_map.events.each_value {|event|
if event.y == $game_player.y && event.x == $game_player.x - i &&
CP.first_event_comment(event, string)
return event.id
end}}
when 6
(1..range).each {|i| $game_map.events.each_value {|event|
if event.y == $game_player.y && event.x == $game_player.x + i &&
CP.first_event_comment(event, string)
return event.id
end}}
when 8
(1..range).each {|i| $game_map.events.each_value {|event|
if event.x == $game_player.x && event.y == $game_player.y - i &&
CP.first_event_comment(event, string)
return event.id
end}}
end
return 0
end
def self.trigger(string, range, switch)
event_id = self.find_first_event($game_player.direction, range, string)
return if event_id == 0
key = [$game_map.map_id, event_id, switch]
$game_self_switches[key] = true
$game_map.need_refresh = true
end
end
you call it like this
CP.trigger('string', range, "switch")
Yay, more energy to you then :D
yay now i have three!! wait some one must of downed me at some point because I used to have three anyway... any way YAY POWER UP
LMAO! I never would have thought. BTW, you can use ' instead of ". Strings with ' are processed a bit faster than with ".
i knew that... just slipped my mind...