Save-Point

Full Version: Save-Point
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Board Message
Sorry, you do not have permission to access this resource.
Save-Point - Random map selection script which does not use the same map twice

Save-Point

Full Version: Random map selection script which does not use the same map twice
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hello everyone does anyone know of a way to have multiple maps picked at random when you use a door entity and then make sure you do not select a map which you have been on before I have been trying to program that all morning here is what i have so far
http://i229.photobucket.com/albums/ee233...cbdefc.jpg

the idea is it randomly chooses a number which picks a map but if that maps has already been used it will call the random map common event which the exact same event as this one but saved in the common event that way it will pick another number and you will go to another map well in theory I used the common event because I could not figure out another way to reset the event apologize if there is a really easy way to do that I am very VERY new to this
This problem is actually two problems! The first one is visiting rooms in a certain order from a door, but never the same room twice. The second one is the actual randomizing.

The first can be solved like this; Take a number of variables equal to the number of rooms you want to visit, say, Variable 2 to 5. The first time you use the door, it checks with a conditional branch if Variable 2 is bigger than 0. If so it teleports the player to the Map Id stored in stored in Variable 2 AND (here's the important part) sets Variable 2 to 0 so we know the player has been there before.

The next time you try to open the door, it will check that Variable 2 is zero, and go to check Variable 3 next. If it is not 0, it will teleport the player to the Mapid stored in Variable 3 and set it to 0. And so on until you've worked through all of the possible maps.

the second problem is randomizing which variables lead to which map ids. we can do that with the 'Script' event! Put this into the box that comes up when you click on "Script...";
Code:
rooms = [12, 24, 78, 36] #map IDs
rooms.sort_by { rand }

$game_variables[2] = rooms[0]
$game_variables[3] = rooms[1]
$game_variables[4] = rooms[2]
$game_variables[4] = rooms[3]
If you want to know what this Ruby code is doing I'd be happy to explain.
a thousand apologies for the delayed response I had a bit of a personal crisis to attend to anyway I am back now and thank you so much for taking the time to respond but I got to admit my understanding of scripts is pretty much nothing
now when I write the script do i replace the numbers with the map names?

right I just tried entering the script and replacing the numbers with the names of my maps but when you go to use the variable in the transfer player box how can you choose were on the map the player start for player x and y you can only choose variables also when i go to use the door a get a syntax error here is a screenshot to help
http://i229.photobucket.com/albums/ee233...7d05f6.png
Almost. You need the Map IDs of the map, which is the number they are saved as, eg, map001's map ID is 1. You and find out what a map's ID is by checking the bottom middle-right of the window. For example, in that picture, you can see 033:testroom2{FPLE] so 33 is the map ID.

Like this. [Image: 288qov7.jpg]
I did everything you said but for some reason I am getting syntex errors could you post the script in the chat so i can copy and paste it in fact what would really help is if you could make a very small game exe which does the random map selection and uploading it so i can go through the game and see exactly how it works if you do that I would be forever in your debt
THANK YOU THANK YOU THANK YOU THANK YOU I just could not get my head around it until I saw it in rpgmaker you sir are a saint