[Resolved]Script Not working

Started by Ryex, July 26, 2008, 10:20:03 am

Previous topic - Next topic

Ryex

July 26, 2008, 10:20:03 am Last Edit: July 29, 2008, 10:17:08 am by Ryex
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

CP.trigger('hi', 4, 0)


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
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

Of course I don't know what's going on since I wrote it out of my head. What do you expect? -_-
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

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 no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

I mean that I found bugs and fixed them just by looking through the code. There could be another not so obvious bug.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

is it possible to call the interpreter's method for changing selfswichs instead of making our own?
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

You still have to code that call. In the end it's the same.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

July 29, 2008, 10:02:24 am #6 Last Edit: July 29, 2008, 10:12:02 am by Ryex
I FIXED IT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  :haha: :haha: :haha: :haha: :D 8)

I desired to inspect the interrupter further so I put an extra line the said
p @paramertes[0].to_s


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")
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Fantasist

Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




Ryex

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
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

LMAO! I never would have thought. BTW, you can use ' instead of ". Strings with ' are processed a bit faster than with ".
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

i knew that...  just slipped my mind...
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />