ID:1936044
 
(See the best response by Lummox JR.)
Code:
mob

monster
icon='player.dmi'
icon_state=""
pixel_step=1
width=10
height=32
iconx=12
icony=1
absx=48
absy=60
density=1
// movement_delay=0
movement_state="buku"
Click()
usr<<output("You clicked [src.name]!","battle")
src.Query_Battle(usr)
Query_Battle(mob/M)
var/map=pick("kingshouse","babaarena")
var/mob/player/P
var/list/L=battle_locate(map)
var/obj/O
// var/list/Location
if(ismob(M))
M<<output("Searching for [map]!","battle")
if(istype(M,/mob/player))
P=M
while(!SwapMaps_Load(map))
M<<output("Can't find [map]!","battle")
sleep(10)
M<<output("You are being teleported to [map]!","battle")
var/swapmap/Map=SwapMaps_Find(map)
// for(var/obj/O in L)
// Location.Add("[O.desc]"=O)
O=pick(L)
L.Remove(O,null)
P.absx=(O.x*32)
P.absy=(O.y*32)
winset(P,"mainwindow","macro=battle")
P.UpdateLocPix(P.absx, P.absy, Map.z1,TRUE)
O=pick(L)
L.Remove(O,null)
src.UpdateLocPix(src.absx, src.absy, Map.z1,TRUE)
winset(src,"mainwindow","macro=battle")
// P.loc=locate(round((Map.x1+Map.x2)/2),round((Map.y1+Map.y2)/2),Map.z1)

proc
battle_locate(map)
var/swapmap/Map=SwapMaps_Find(map)
var/list/L=list()
if(Map)
for(var/obj/battle_items/placeholder/H in placeholders)
if(Map.Contains_Obj(H))
L.Add(H)
for(var/obj/X in L)
if(isobj(X))
world<<"[X.desc]"
return L


Problem description:

First time using Lummox's SwapMaps. Having trouble getting it to work in my project.

What kind of trouble? I noticed that swapmap.Contains_Obj() isn't a library function, and that you're calling battle_locate() on a map that hasn't been loaded yet.
In response to Kaiochao
Kaiochao wrote:
What kind of trouble? I noticed that swapmap.Contains_Obj() isn't a library function, and that you're calling battle_locate() on a map that hasn't been loaded yet.

It's not wanting to load the map. And, yes. I realized that now. I moved the list initialization lower now. And, the contains_obj proc is same as contains_turf. Just specific to obj's. Something I added.

Nothing else was modified or changed other than the addition of that proc.
In response to Teh Governator
Are you getting any outputs or runtime errors?
No run-times. Just my output loop, indicating it's not loading the map.

M<<output("Can't find [map]!","battle")
In response to Teh Governator
Well, the only ways that SwapMaps_Load() returns nothing are when you get a runtime error (ruled out), or the file is locked (unlikely), or the file doesn't exist.
The files exist. And, no run-time.
In response to Teh Governator
From the library:
proc/SwapMaps_Load(id)
InitializeSwapMaps()
var/swapmap/M=swapmaps_byname[id]
if(!M)
var/savefile/S
var/text=0
if(swapmaps_mode==SWAPMAPS_TEXT && fexists("map_[id].txt"))
text=1
else if(fexists("map_[id].sav"))
S=new("map_[id].sav")
else if(swapmaps_mode!=SWAPMAPS_TEXT && fexists("map_[id].txt"))
text=1
else return // no file found
if(text)
S=new
S.ImportText("/",file("map_[id].txt"))
S >> M
while(M.locked) sleep(1)
M.mode=text
return M

Could you replace that return // no file found with throw EXCEPTION("File not found")?
Done. And, getting a run-time now. I think my map file may be corrupted.


BYOND Error: failed to parse savefile text at line 52 (reading '"; icon_state = "'): expecting ;expecting }expecting }expecting }expecting }
runtime error: Cannot create objects of type null.
proc name: Read (/swapmap/Read)
source file: swapmaps.dm,276
usr: /swapmap (/swapmap)
src: /swapmap (/swapmap)
call stack:
/swapmap (/swapmap): Read(C:\\Users\\Charles\\Documents\... (/savefile), null, null)
SwapMaps Load("kingshouse.dmm")
the monster (/mob/monster): Query Battle(Teh Governator (/mob/player))
the monster (/mob/monster): Click(the grass (3,6,1) (/turf/grass), "mappane.map", "icon-x=17;icon-y=18;left=1;scr...")
In response to Teh Governator
Well, adding the "throw" in there shouldn't have caused that error to appear, but it's good to see. Yeah, the savefile is corrupted.
Odd. I remade the maps using the "Convert" verb and it's still not wanting to properly save. Not sure what the deal is here.
Perhaps Lummox could shed some light on this? I have nothing odd in the maps. Just turf and a few objs.
Offhand I can't see anything amiss, but it's been a while since I did anything with SwapMaps. I do wonder if your text file has indentation issues.
In response to Lummox JR
Lummox JR wrote:
Offhand I can't see anything amiss, but it's been a while since I did anything with SwapMaps. I do wonder if your text file has indentation issues.

Can I private message you?
Best response
Sure. I'm not sure I'll see anything new but it's worth a look.
In response to Lummox JR
Lummox JR wrote:
Sure. I'm not sure I'll see anything new but it's worth a look.

Messaged you. Sorry for the delay. Work. Haha. Just would like to solve this so I can continue. Swap Maps will be a great addition and large part of my game. =D