Problem with Saving/Recalling Map-IDs

Status
Not open for further replies.

Tiregs

Villager
Member
Joined
Jan 19, 2020
Messages
24
Reaction score
2
First Language
german
Primarily Uses
RMVXA
Hello,

sorry but I think this is a rather complicated problem. I am trying to build a "Bindings of Isaac"-like game, but you can only go from left to right. If I go right, I teleport into a random map.
It is basicly the same map everytime, they just look a little different and have different monsters, but the events are all the same, so that always the same eventing processes will run when entering a new room.
I just copy and paste the initial map and then change the others ever so slightly. There is a common event that sets the "random room" variable to 27...29, cause these are rooms I am using atm.
Going to a random Map everytime works fine, but I want the program to remember the rooms I already have been in, so that I can return back for whatever reason.
When I then go right again, it should bring me back to the rooms I have already been. UNLESS there is no room anymore where I have already been in, then it should throw me into a random room again.

Here is a flawless image trying to explain this method:
rooms.png

After visiting 5 random rooms with monsters n stuff I should teleport into a bossroom.
But this is a problem I was able to handle by setting a variable, that increases +1 whenever I go right but doesnt decrease when going left, and another one that does decrease when going left and so the game knows, that whenever these two are equal, I go into a random map.
If not, it should bring me into a specific map, depending on the amount of rooms I have visited before.

I've been working for a long time on a way to remember the ID's of the rooms in variables and then setting up my teleport fields, so that the player goes to the room he should go.

First, a screenshot of the event-placements and everything that could be useful:

bandicam 2020-01-29 09-22-48-939.jpg

The events top right are just for the chests, the top left are for remembering the game-ID.
Important Note: The 4 events up left are all almost identical, just the Condition/Switch/Variable Numbers vary from 2-5, since the first room is a different, not random room! (So second left event would look like: If "room number == 3", blavariable [room3] = Map ID, etc...)

bandicam 2020-01-29 10-11-57-894.jpgbandicam 2020-01-29 09-42-10-441.jpg
(left has 2 pages and right 3 because I am constantly trying things and so I changed something while writing this... sorry. But was just a boring "if self switch a is on" page)

First page triggers only, if I enter a new room I have not been in before.
The teleport-event will check first, if the two variables mentioned earlier are equal.
If yes, it throws me into a random room and activates the switch "First visit".
Depending on the Variable "Roomcounter", like for example if it is at 2, it should store the game ID onto a variable with the name "room2". The "roomcounter"-Variable is the variable that does decrease when going left.
Second page activates, when the player goes left, then a switch will activate depending on the "Roomcounter". So, if "Roomcounter" is 2, Switch "MapID2" will activate.
This is the system I was trying to establish, that the game always knows, in which room I am in. Sooo I made 4 of those because I dont wanted to make a gigantic conditional branch tree, things were already complicated enough.

bandicam 2020-01-29 09-31-43-484.jpg

This is the left Teleporter. If MapID2 (That's just the name of the switches, not the actual MapID) is activated, it does a direct teleport back to the first map, because map 1 isnt random, so thats easy.
If MapID 3 is active, teleport location is set to the Variable, where the Map ID (this time the real Map ID) of Room 2 is stored (Variable "room2".
It also flips on a switch, that I just went back. If this switch ("Went back") is on, it should lead the upper left events to detect the room number and switch on the fitting "MapID". Then it switches itself off (Don't know if that's allowed..)
The common event is for the chests, it just sets a bunch of different variables and switches but this wont be the cause for any error here, so please ignore that.

bandicam 2020-01-29 10-10-28-021.jpg

And this is the last one, the right teleporter. Just as explained, by going left and activating the switch "Went back", the upper left event group's second page should activate, flipping a MapID switch on, depending on the number of my roomcounter.
(I have a variable-counter script. The counter works fine, I can see that.)
So for example if switch "Went back" is on and Variable "Room Number" is 3, it should activate the switch "MapID3".
Both teleporters have an event page, that if "MapID3", they do something. Going Left TPs to room 2, Going Left to Room 4 or a random room. After this, they turn the switch "MapIDx" (depending which map you are), off.

Then the difficult part: When going left, the game has to remember where you have been before, so if you go right again, you should go back to the room you just came from.
I have tried so many things and never got to that result. Sometimes I was able to build it, so that I could go all the way back in the right order, but when going right again either the teleport command didnt tp, sometimes even after doing it successfully ONCE, but then it disappeared in the next room, or it suddenly teleports me into the same room over and over again.

I am on an emotional roalercoaster, I have been so close sometimes, even thinking I did it. The disappointment hits even harder, when it lets you think your thingy is working for the first 4-5 rooms, just to stop working somewhere. I need help, with this setup and emotionally as well :(
 

Attachments

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
4,693
Reaction score
5,364
First Language
Indonesian
Primarily Uses
RMVXA
I'll bookmark this bcz i sort of have a solution if you dont mind playing around with scripts. Sorry for not reading it through or give you a comprehensive answer bcz im on mobile. Do you want that if you go right > always random map and if you go left > always the previous map id?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
29,209
Reaction score
6,762
First Language
German
Primarily Uses
RMMV
I suggest you search for PK8' self data suite, it should be available in the "lost script recovery" topic.

That will allow you to assign self-variables to your transfer events, storing what map they'll go to after they have been used.
 

Tiregs

Villager
Member
Joined
Jan 19, 2020
Messages
24
Reaction score
2
First Language
german
Primarily Uses
RMVXA
@TheoAllen , No I don't mind playing around with scripts, I am honestly not using any scripts for this problem is because I have abilities with ruby are pretty limited. And in the game: If I go back 3 times I should be able to go forward 3 times, and then teleport to a random map. Saving and Loading MapID's with each teleport is the difficult part.

@Andar , Thanks, I think I found it and will look into it, it is just a huge folder of .txt files, need to figure that out first
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
29,209
Reaction score
6,762
First Language
German
Primarily Uses
RMMV
it is just a huge folder of .txt files, need to figure that out first
follow the link "how to use a script" in my signature then.
that tutorial has been a bit of damaged (lost formats) due to changes in the forum software, but it should still be readable
 

fizzly

Veteran
Veteran
Joined
Mar 23, 2012
Messages
460
Reaction score
312
First Language
Polish
Primarily Uses
RMMV
Hmmm, I think you can do this by using two variables? (Or I am wrong maybe, but you can try)
First tracks your actual room you're in: 1-left, 2-middle, 3-right.
2nd track room id that you was before, so if you leave map left, then assign 2(middle), if you leave map from left room to right, then assign 1 (left), etc.
Then you can check via conditional branch, for example:
If actual room is = 1 and room before = 2, then teleport to room id 2 (middle).
Buuuuut.... I'm pretty sure you generate some events in the room, so if you want to go back to the same room as it was, it's not possible, because rpg maker does not keeps events outside maps I think.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
4,693
Reaction score
5,364
First Language
Indonesian
Primarily Uses
RMVXA
Ok, now I'm back to the desktop mode, I'll try to explain this comprehensively. But first, you will have to enable the console by clicking the Game > Show Console shown in the image below. And you don't need PK8 Self Data Suite at all.

Screenshot_95.jpg

First, what you gonna do is to records all the map id in a single array. An array is basically an object that can hold multiple values. You can do it by writing a script call like this. Let's say, you want to reserve variable ID 1 for this array and you want to hold 15 maps
Code:
$game_variables[1] = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
The next line, try to show it in the console by putting this line of code
Code:
p $game_variables[1]
The command p is to inspect the value of $game_variables[1], and when you playtest, you will see this printed to the console window.

Screenshot_96.jpg

Looks normal, right? But here is the magic that happens.
In the next line, try to put
Code:
$game_variables[1].shuffle!
p $game_variables[1]
And what you will see is a scrambled order of number like this (and your result will be different as well)

Screenshot_97.jpg

And by this, congratz! you have done randomize the map order as well as save it in the save contents! You don't have to worry about your original question anymore.

Now how to actually use this? You need a second variable as a pointer which map you're in. Say, you're in the first map, that would be in 13, let's assume you have variable ID 2 to store the pointer, and it starts at 0 because array index starts at 0. And you will need the third variable (and let's assume you use variable ID 3 for this) to store the current map ID

In Control Variables, you do it like this (this is probably confusing but hear me out)
Screenshot_98.jpg
And when you want to go right (to the next map) all you need to do is this.
Screenshot_100.jpg
And if you want to go left, reduce the pointer
Screenshot_101.jpg

Further explanation of what is happening
You can try to look at the console after try to put this script call
Code:
$game_variables[1] = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
$game_variables[1].shuffle!
p $game_variables[1]
p $game_variables[1][0]
p $game_variables[1][1]
p $game_variables[1][2]
p $game_variables[1][3]
p $game_variables[1][4]
Output:
Screenshot_104.jpg
The line p $game_variables[1][0] means to get the value in index 0, which in this case it is 7.
The next line p $game_variables[1][1] means to get the value in index 1, which in this case, it's 10.
Now imagine if the index number 0, 1 is substituted with another game variable. Which in this case, it's $game_variables[1][$game_variables[2]]
When the value of variable ID 2 is 0, then it fetch the value in index 0 which is 7.

I hope you get the idea. Probably someone could explain this better though.
 

Tiregs

Villager
Member
Joined
Jan 19, 2020
Messages
24
Reaction score
2
First Language
german
Primarily Uses
RMVXA
Hm thank you this looks like it really might solve my problem!

I just need one last bit of help. I did everything you said, turned on the console and called the script. Honestly I don't know if there is a correct way to run this script, I just called a common event that runs the lines and then turns itself off again with the data for my game (Variable = 21 and the Map IDs 27..29)

bandicam 2020-01-29 15-14-16-984.jpg

But when I start a testplay it does show the numbers in the console but I also get following error report:

bandicam 2020-01-29 15-17-22-643.jpg

I tried to delete every event that uses Variable 1 and I've been careful that there is no script using it. I am using Parallaxes and have a parallax lock in my map properties, but otherwise my maps are also not touched by anything else in any form. Do you know what could it be that causes this error?
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
4,693
Reaction score
5,364
First Language
Indonesian
Primarily Uses
RMVXA
You use "u" instead of "p"
 

Tiregs

Villager
Member
Joined
Jan 19, 2020
Messages
24
Reaction score
2
First Language
german
Primarily Uses
RMVXA
Oh... that was quite stupid... Sorry for that.

Now I got it to work!! Thanks a Ton, thats amazing!!
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
6,023
Reaction score
4,250
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

i watched the sonic movie it was pretty good i hope they make a sequel
tomorrow I'ma go on a cruise for the first time ever... lets hope I'll survive the experience!
Omg! 8 years in this forum :o
Ksi
Streaming the last of the RMN Valentiny event games so feel free to drop on by and watch me cry (whether that's from laughter, rage or sheer pain, who knows?)
Today I went to sleep without setting an alarm, so I could sleep more than 2 hours. I woke up after 2 hours.

Forum statistics

Threads
94,307
Messages
919,814
Members
124,056
Latest member
ZidaneX
Top