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.

Please read, this should be easy...

Kraft

Sponsor

Okay, I have been thinking about my last request, and why no one would do it (hehe, I wouldnt do it either)

So, here is this new request, and I hope it will be easier...
-----------------------
Basically, I would like a script that checks for a Event on a certain XY of the map.

I know that I can do this with variables and Switches, but when you try to place more than one moving block in a map, it can get really confusing...

So basically, I would like to place a script call on a map that looked something like this;

$script_event (0001; 06; 12; 15)

Basically, the 0001 is the event, the 06 is the X of the map, the 12 is the Y of the map, and the 15 is the switch that flips on when the event in the script (0001) is on the X,Y in that script call.

And if the event moves off of the XY, then the Switch (15 in this case) will flip back off.

----------------------
Can someone please do this?

Thanks!

~Kraft
 
I've not tested, but it should do the trick. You can have different setup for each map, and can test for many events in the same map. You just have to fill the Hash correctly.
Code:
class Game_Map
  KRAFT_THING = {7 => [[1, 6, 12, 15], [2, 6, 12, 16]],
    8 => [[1, 7, 15, 17]]}
  alias kraft_switch_gmmap_updt update
  def update
    kraft_switch_gmmap_updt
    if KRAFT_THING.has_key?(@map_id)
      for thing in KRAFT_THING[@map_id]
        old_switch = $game_switches[thing[3]]
        $game_switches[thing[3]] = @events[thing[0]].x == thing[1] && @events[thing[0]].y == thing[2]
        @need_refresh = true if $game_switches[thing[3]] != old_switch
      end
    end
  end
end
This code will check for:
a) event 1 @ map 7 in (6, 12) to activate switche 15
b) event 2 @ map 7 in (6, 12) to activate switch 16
c) event 1 @ map 8 in (7, 15) to activate switch 17

I can't test it now, but you can tell me what happens.
 

Kraft

Sponsor

I tried it... and there is an error on line 4 (alias kraft_switch_gmmap_updt update)

I think it was a Syntax error, and then on the error there was a some of these (;) on it.

Thanks though, I understand how it works, and it is great!
 

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