ID:1856939
 
Code:
There's no code needed


Problem description:
Is it possible to have 10 worlds randomly selected every time the game reboots the world? I have named them in the following manner:
"world"+ 1-10 number + ".dmm"
so I have world1.dmm, world2.dmm and so on.
Can I randomly select from them every 5 hours game is restarted?
I think this will do it:
proc
getmapfiles(prefix, suffix)
var
list/files = flist("./[prefix]")
length
prefixlength = length(prefix)
suffixlength = length(suffix)
arenumbers

. = list()

for(var/f in files)
length = length(f)
if((copytext(f, 1, prefixlength + 1) == prefix) && (copytext(f, -suffixlength) == suffix))
for(var/pos in prefixlength + 1 to length - suffixlength)
switch(text2ascii(f, pos))
if(48 to 57) // a number
arenumbers++
else
arenumbers = 0
break
if(arenumbers)
. += file(f)


Then you can use it like this:
pick(getmapfiles("world", ".dmm")) // pick a random map file


I'm not sure what you plan to do with the random map file after you have it though.
I want to open it in the game for the duration of played game round.
In response to Adrian09_01
Well, BYOND doesn't have built-in map reloading at runtime, so you will have to either find a special library for that, or make your own.
Also, I have a bridge (obj), and I want it to be built on the sea (obj) to replace it temporarily until I destroy the bridge by clicking it. How I should do that? Because if I define sea as a turf, I can't walk over the bridge.
btw, I have a durability variable = 15, and the game should replace the bridge when it's = 0.