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?
 
You can, but the event will not update.
Use this:
Code:
map = load_data("Data/Map***.rxdata") # Change *** to the id of the map
event = map.events[*] # Change * to the id of your event
$game_variable[*] = event.x # Change * to the id of the variable that will store the x value
$game_variable[] = event.y # Change * to the id of the variable that will store the y value
You can call this script with the script event command.
 
Thanks, a little problem though, the mapID is stored in a variable. how do you change the loaddata part of the script to load data from the map who's ID is stored in a variable?

EDIT:
The script isn't working. This is the code i'm using
Code:
map = load_data("Data/Map003.rxdata") 
event = map.events[1] 
$game_variable[13] = event.x 
$game_variable[14] = event.y

Would it help to know i'm using this in a common event called by the "DHD"?
 
I think there's a better way, but following will work
Code:
map_id = $game_variables[[COLOR=Red]map_var_id[/COLOR]].to_s
map_id = "0" + map_id unless map_id.to_i >= 10
map_id = "0" + map_id unless map_id.to_i >= 100
map = load_data("Data/Map#{map_id}.rxdata")
replacing map_var_id for the variable with the map id
 
Still errors with:

NoMethodError occured while running script.

Undefined method '[]=' for nil:NilClass

Also, is there a way for it to stop erroring when you select a map that doesn't exist?

I'm sorry for asking so much, if you like, i'd outline the whole of the script + What i'm trying to do.
 
Code:
begin
  map_id = $game_variables[map_var_id].to_s
  map_id = "0" + map_id unless map_id.to_i >= 10
  map_id = "0" + map_id unless map_id.to_i >= 100
  map = load_data("Data/Map#{map_id}.rxdata")
  event = map.events[1]
  $game_variable[13] = event.x
  $game_variable[14] = event.y
rescue
end
 
Sorry to keep bugging you, but the script seems to big for RMXP to handle it. Is there a way to put it into the script section of the game and use a script command to call it?
Thanks for all the support you're giving.
FYI, you've all probably noticed by now, but i'm making a stargate game...

EDIT: just a quick question. What does the "Rescue" command do?
 
Wait, so are you trying to set it up like this?:

Player inputs code for Ice World (for example). If code is correct, transfer to Ice World map.

Player inputs code for Fire World. If code is correct, transfer to Fire World map.

Or did I miss something?
 
Code:
begin
map=load_data(sprintf( "Data/Map%03d.rxdata",
$game_variables[map_var_id]))
$game_variable[13] = map.events[1].x
$game_variable[14] = map.events[1].y
rescue
end

just a quick question. What does the "Rescue" command do?
Rescues an error, it is difficult to explain
 
Oh, lemme guess. You want a stargate that if you input the right code it will open a portal to a stargate in another world whereas if you input a different code you get a totally different gate. Right? If it is, its only because my bro watches it.
 
Why not use a multiple Conditional Branchs inside each other in a Common Event and then use a direct Transfer Player? Is there a set entrance point into each world (like the other end of the gate)? I don't know how you have set up your input system, but try something like this:

If you are using Button Input Processing, with each digit storing to a different variable:

To reach the Fire World (sorry for the bad example) the variables should be:
Variable 001 = 1, Variable 002 = 5, Variable 003 = 4

Conditional Branch: Variable 001 = 1
.@ Conditional Branch: Variable 002 = 5
...@ Conditional Branch: Variable 003 = 4
.....@ Transfer Player
Else:
@ Exit Event Processing
Else:
@ Exit Event Processing
Else:
@ Exit Event Processing (or you can give the player some kind of text notice that their code is incorrect)
End Branch

End Branch

End Branch


That way you won't have to worry about scripting it.
 
Well i was going to do that, but i wanted to be a little more cannon to the series. There are 7 digits (using an input variable command)
1st digit = Map ID (1's)
2nd digit = Map ID (10's)
3rd digit = Map X (1's)
4th digit = Map X (10's)
5th digit = Map Y (1's)
6th digit = Map Y (10's)
7th digit = Home code (must know to be able to "Dial out"

So basically, as long as the total map X and map Y are equal to the map x and y of event 1 (always going to be the "stargate" event) on map referenced by the total map ID, then it transports you there, otherwise, it doesn't.

Now imagine halfway through the game, i have 20 "worlds", that'd be something like 60 conditional branches... rather than a simple bit of code
 
I've never really watched Stargate, so I must be missing something.

Can you explain a little more in-depth for someone that has never seen the series, and the equation you will be using for reaching your different worlds?

I think I might know another way around this, if I understand it correctly, but I'm not sure that I do. Sorry.
 
Right, you have 2 things, a "stargate" and a "DHD"
You input a code into the DHD (which is 7 digits long) and then, if the code you input reaches the same co-ordinates as a stargate, then you walk through it to get to the place you "dialed"
If you look above, you can see how i layed out the 7 digits.
so, if you use the code 1234567
it takes you to, map 56, x34 and y12, just ignore 7th symbol
im on my pda for tonight (uk guy) so my responses will most likely be slow and full of spelling mistakes
 
Sorry, I was away from the computer until just a few minutes ago.

The only way I can really think of to do with Events (I am terrible with scripting) is like this:

The DHD item calls a Common Event. You will have to break up the 7 digit number to input 1 at a time.

So,
@Input Number: [001], 1 digit(s)
@Input Number: [002], 1 digit(s)
@Input Number: [003], 1 digit(s)
@Input Number: [004], 1 digit(s)
@Input Number: [005], 1 digit(s)
@Input Number: [006], 1 digit(s)

Now, to combine them into workable variables. Multiply the first digit variables by 10.

@Control Variable: [001] *= 10
@Control Variable: [003] *= 10
@Control Variable: [005] *= 10

Now add the variables to make a two digit number:

@Control Variable: [002] += Variable [001]
@Control Variable: [004] += Variable [003]
@Control Variable: [006] += Variable [005]

So if you input 1, 2, 3, 4, 5, 6 it will give you 12, 34 and 56 as your Map ID, Map X and Map Y (however you want set it up).

Now comes the long part. Make a Conditional Branch for each of your Stargates, starting with Map ID.

So, if you know that you have Stargates on Map IDs 1, 5, 7 and 15, you will make Conditional Branches for each.

Conditional Branch: Variable [002] == 1
@
Else:
@
End Branch
Conditional Branch: Variable [002] == 5
@
Else:
@
End Branch

Etc. Now , under each branch you want to compare them to the Map X and Map Y of each Stargate per map.

The Stargate on Map 1 has a Map X of 12 and a Map Y of 57 (for example).

Conditional Branch: Variable [002] == 1
@Conditional Branch: Variable [004] == 12
...@Conditional Branch: Variable [006] == 57
...@Transfer Player: Variable[002][004][006]
Else:
@Text: Not a valid input code
@Exit Event Processing

Else:
@Text: Not a valid input code
@Exit Event Processing

Else:
@Text: Not a valid input code
@Exit Event Processing

End Branch

End Branch

End Branch

Not too much work, though. Even if you have 20 Stargates, you will only have to make branches for 20 of them!
 
Yeah, it just isn't exactly true to the series.
Rather than inputing each number seperatly, I designed a system where you just input a 7 digit number and then it splits it up.
I found a workaround. You just teleport the player to the map they requested, and store the variables of event one there. Still, if anyone want's to work on the script a little more, feel free XD
 
What you can do is have them input one at a time (like above) and then show them all in a text box, then ask the player to confirm.

After the player has input all 7 variables:

@Text: \v[1]\v[2]\v[3]\v[4]\v[5]\v[6]\v[7]. Is this correct?
@Show Choices: Yes, No
If Yes:
(use the variable check to see if it leads to a Stargate)
If No:
Call Common Event: (Recall the event to input a new number, or you can use Exit Event Processing)


Or, since the Number Input stores the number as a variable, why not just make conditional branches for each of the destinations in a Common Event?

Let's say that a Stargate has a Map ID of 56, a Map X of 45 and a Map Y of 88. The 'dial home' number is 5.

@Number Input: [001], 7 digit(s)
Conditional Branch: Variable [001] = 5645885
@Transfer Player (you can set up a direct transfer)
Else:
@Text: Not a valid destination

This gives the player the illusion that the code is broken up, but there is really no need to break it up if they have to input the exact destination anyway.

Then, just make a new Conditional Branch for each separate Stargate and it's coordinates.
 

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