ID:1716242
 
Keywords: map, names, z
Hey guys, How would I go about making z maps have a random name? I know how I would go about making the names, but how do I assign it to the z map?

Example: player enters a new planet and it gets a random name, such as Blood Planet 3, and that way they could remember the planet names and return there, rather than remembering coords.

I have the system for the return and for making names but can't figure out how to assign the names to the Z map as an entity of its own.

Thanks for any ideas :)

Bloodocean7.


An easy way of going about this is to create a list of strings, which would be your map names.

var/list/map_names = new(world.maxz)
// A gobal list of size [world.maxz] is created.


When a map is created, we can check the list for an empty index.

proc/MapNames_Find_Empty()
var/d = map_names.Find(null)
if (d)
return d
else
map_names += null
return map_names.len


The proc above will find an empty index, or simply attach a null index to the end in order to make space. To create a new Z level if it appends a new index:

proc/World_Max_Z_Update()
world.maxz = map_names.len


// helper clamp function
proc/Clamp(N,L,H)
return max(min(N,H),L)

// setting the map name appropriately.
proc/MapNames_Set(N=1,T="MapName")
N = Clamp(N,1,map_names.len)
map_names[N] = T

proc/MapNames_Add(T="MapName")
var/d = MapNames_Find_Empty()
map_names[d] = T
World_Max_Z_Update()

proc/MapNames_Remove(T="MapName")
var/d = map_names.Find(T)
if (d)
map_names[d] = null

// returns the index of the map's name, which is also the Z level.
proc/MapNames_Find(T="MapName")
return map_names.Find(T)