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.

Referring to an event on a different map

Hello, I'm making a stargate system, mainly by events. I've hit a little "Snag" however... I need to store the co-ordinates of an event in a variable. The problem is that the event i want to store to is on a differant map. Can RMXP's RGSS do that?
 
First i have to say... this is my first post :D
i like Stargate its cool...
but anyway

im not a scripter but i think i can help...

put @ before the "map_id" and all other variables that don't already have @ or $
 
Welcome to the forums ^^
Thanks for the advice, i know a little RGSS (much like yourself) as i can usually understand it from reading it. I can't script however.
Feel free to download the demo (look one post up)
 
Your system worked out pretty well. The only thing is, you have made it a lot harder on yourself than it has to be. If each world has a very specific Map ID, Map X and Map Y, you don't need to use all of those variables to check event locations, etc.

Basically, you have it set up on a password system, so you can code it just like a password. No checks needed.

Just write down every Stargate's Map ID, Map X and Map Y on a piece of paper. Now, combine them to make your 7-digit code that the player will input. Now, have the DHD call a Common Event. In the Common Event, set up Conditional Branches for each of the passcodes.

For example:

You have two Stargates.
To reach Stargate 1, you need to input 1234567
To reach Stargate 2, you need to input 4567890

Input Number: [001] 7 digit(s)
@Conditional Branch: Variable [001] = 1234567
<>Transfer Player (use direct transfer by clicking on the map you want and the location on the screen you want to transfer them to)
End Branch

@Conditional Branch: Variable [001] = 4567890
<>Transfer Player (transfer them to Stargate 2)
End Branch


Now just keep going for every gate. If you put each Conditional Branch inside each other (in other words, put the Conditional Branch for Stargate 2 inside of the Conditional Branch of Stargate 1, put Conditional Branch for Stargate 3 inside of Stargate 2, etc), you can use the Else handler to give the "Not Valid" message if the passcode the player entered is not one of the destinations.

Even if you have 20 worlds, you would only have to code 20 Conditional Branches, which really isn't too bad, considering all the time it probably took for you to develop the system you are using right now.

As for your system, it is really pretty innovative. You did a really good job, you just don't need to have all that work.

I still could not get the second link to work, though....
 
I have make a demo, with scripts: Stargate.rar

You can copy the events from the demo, and remember to add this in a section over main:
Code:
class Interpreter
  def stargate(var)
    map_id = var / 100000
    x = (var / 1000 * 100 - map_id * 10000) / 100
    y = var / 10 - map_id * 10000 - x * 100
    map_infos = load_data("Data/MapInfos.rxdata")
    if map_infos[map_id].is_a?(RPG::MapInfo)
      map = load_data(sprintf( "Data/Map%03d.rxdata", map_id))
      x_gate = map.events[1].x
      y_gate = map.events[1].y
      return [map_id, x, y+1] if x == x_gate and y == y_gate
    end
    return [-1,-1,-1]
  end
end
 
about the Id001 thing, i know, it was something i'd prefer to aviod. But there's no other way you can do it really (apart from the seperate conditional branches way)
The script is very good. basically what i designed using events! you now join kierapheonix on the crediy list!
 
I modify the script for reading if the event in the coords. have the comment "Stargate".
Use this:
Code:
class Interpreter
  def stargate(var)
    map_id = var / 100000
    x = (var / 1000 * 100 - map_id * 10000) / 100
    y = var / 10 - map_id * 10000 - x * 100
    map_infos = load_data("Data/MapInfos.rxdata")
    if map_infos[map_id].is_a?(RPG::MapInfo)
      map = load_data(sprintf( "Data/Map%03d.rxdata", map_id))
      for e in map.events.values
        if e.x == x and e.y == y
          event = Game_Event.new(map_id, e)
          return [map_id, x, y+1] if event.stargate
        end
      end
    end
    return [-1,-1,-1]
  end
end
class Game_Event
  attr_accessor :stargate
  alias stargatescript_refresh refresh
  def refresh
    @stargate = false
    stargatescript_refresh
    return if @page == nil
    for i in @page.list
      if i.code == 108 or i.code == 408
        if i.parameters[0].upcase[/STARGATE/] != nil
          @stargate = true
        end
      end
    end
  end
end
 

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