dmm_suite/load_map(var/dmm_file as file, var/z_offset as num) if(!z_offset) z_offset = world.maxz+1 var/quote = ascii2text(34) var/tfile = file2text(dmm_file) var/tfile_len = length(tfile) var/list/grid_models[0] var/key_len = length(copytext(tfile,2,findtext(tfile,quote,2,0))) for(var/lpos=1;lposlength(zgrid)) break sleep(-1) if(findtext(tfile,quote+"}",zpos,0)+2==tfile_len) break sleep(-1) dmm_suite/proc/parse_grid(var/model as text,var/xcrd as num,var/ycrd as num,var/zcrd as num) set background = 1 /*Method parse_grid() - Accepts a text string containing a comma separated list of type paths of the same construction as those contained in a .dmm file, and instantiates them. */ var/list/text_strings[0] for(var/index=1;findtext(model,quote);index++) /*Loop: Stores quoted portions of text in text_strings, and replaces them with an index to that list. - Each iteration represents one quoted section of text. */ text_strings.len=index text_strings[index] = copytext(model,findtext(model,quote)+1,findtext(model,quote,findtext(model,quote)+1,0)) model = copytext(model,1,findtext(model,quote))+"~[index]"+copytext(model,findtext(model,quote,findtext(model,quote)+1,0)+1,0) sleep(-1) for(var/dpos=1;dpos!=0;dpos=findtext(model,",",dpos,0)+1) /*Loop: Identifies each object's data, instantiates it, and reconstitues it's fields. - Each iteration represents one object's data, including type path and field values. */ var/full_def = copytext(model,dpos,findtext(model,",",dpos,0)) var/atom_def = text2path(copytext(full_def,1,findtext(full_def,"{"))) if(ispath(atom_def, /turf/space)) continue var/list/attributes[0] if(findtext(full_def,"{")) full_def = copytext(full_def,1,length(full_def)) for(var/apos=findtext(full_def,"{")+1;apos!=0;apos=findtext(full_def,";",apos,0)+1) //Loop: Identifies each attribute/value pair, and stores it in attributes[]. attributes.Add(copytext(full_def,apos,findtext(full_def,";",apos,0))) if(!findtext(copytext(full_def,apos,0),";")) break sleep(-1) //Construct attributes associative list var/list/fields = new(0) for(var/index=1;index<=attributes.len;index++) var/trim_left = trim_text(copytext(attributes[index],1,findtext(attributes[index],"="))) var/trim_right = trim_text(copytext(attributes[index],findtext(attributes[index],"=")+1,0)) //Check for string if(findtext(trim_right,"~")) var/reference_index = copytext(trim_right,findtext(trim_right,"~")+1,0) trim_right=text_strings[text2num(reference_index)] //Check for number else if(isnum(text2num(trim_right))) trim_right = text2num(trim_right) //Check for file else if(copytext(trim_right,1,2) == "'") trim_right = file(copytext(trim_right,2,length(trim_right))) fields[trim_left] = trim_right //End construction //Begin Instanciation var/atom/instance var/dmm_suite/preloader/_preloader = new(fields) if(ispath(atom_def,/area)) var/turf/A = locate(xcrd,ycrd,zcrd) if(A.loc.name == "Space") instance = locate(atom_def) if(instance) instance.contents.Add(locate(xcrd,ycrd,zcrd)) else //global.current_preloader = _preloader instance = new atom_def(locate(xcrd,ycrd,zcrd)) if(_preloader) _preloader.load(instance) //End Instanciation if(!findtext(copytext(model,dpos,0),",")) break dmm_suite/proc/trim_text(var/what as text) while(length(what) && findtext(what," ",1,2)) what=copytext(what,2,0) while(length(what) && findtext(what," ",length(what),0)) what=copytext(what,1,length(what)) return what /* var/global/dmm_suite/preloader/current_preloader = null atom/New() if(global.current_preloader) global.current_preloader.load(src) ..() */ dmm_suite/preloader parent_type = /datum var/list/attributes New(list/the_attributes) ..() if(!the_attributes.len) Del() attributes = the_attributes proc/load(atom/what) for(var/attribute in attributes) what.vars[attribute] = attributes[attribute] Del() /client/proc/mapload(var/dmm_map as file) set category = "Debug" set name = "LoadMap" set desc = "Loads a map" set hidden = 1 if(src.holder) if(!src.mob) return if(src.holder.rank in list("Game Admin", "Game Master")) var/file_name = "[dmm_map]" var/file_extension = copytext(file_name,length(file_name)-2,0) if(file_extension != "dmm") usr << "Supplied file must be a .dmm file." return var/map_z = input(usr,"Enter variable value:" ,"Value", 123) as num if(map_z > (world.maxz+1)) map_z = (world.maxz+1) var/dmm_suite/new_reader = new() new_reader.load_map(dmm_map, map_z) log_admin("[key_name(src.mob)] loaded a map on z:[map_z]") else alert("No") return return