ID:144679
 
Code:
datum
verb
Cut_Battle_Area(mob/M)
var/list/Pasting_Turfs = new()
var/list/PTLocx = new()
var/list/PTLocy = new()
var/Mx
var/My


for(var/turf/T in block(locate(M.x-5,M.y-5,M.z),locate(M.x+5, M.y+5,M.z)))
Pasting_Turfs += T.type
PTLocx += T.x
PTLocy += T.y
Mx = M.x
My = M.y




Paste_Battle_Area(M,Pasting_Turfs, PTLocx, PTLocy, Mx, My)

Paste_Battle_Area(var/mob/M as mob, var/list/PT as anything, var/list/PTx as anything,
var/list/PTy as anything, var/Mx as num, var/My as num)
world << "----output"
for(var/area/Battlefield/A in world)
if(A.In_use) continue
else
M.loc = locate(A.tag)
A.In_use = 1
for(var/i = 1 , i < PT.len, i++)
var/turf/A
var/X
var/Y
world << PT[1]
X = PTx[i] - Mx
Y = PTy[i] - My
var/T = text2path(PT[i])
world << X
world << Y
world << "-----end output"
if(X < 0 && Y < 0)
new T(Mx-abs(X), My-abs(Y), M.z) // bottom left

else if(X > 0 && Y < 0)
new T(Mx+X, My-abs(Y), M.z) // bottom right
else if(X > 0 && Y > 0)
new T(Mx+X, My+Y, M.z) // top right
else
new T(Mx-abs(X), My+Y, M.z)// top left
A = A


Problem description:


runtime error: Cannot create objects of type null.
verb name: Paste Battle Area (/datum/verb/Paste_Battle_Area)
source file: Tactics - Battle System.dm,63
usr: Mechanios (/mob)
src: Mechanios (/mob)
call stack:
Mechanios (/mob): Paste Battle Area(Mechanios (/mob), /list (/list), /list (/list), /list (/list), 29, 37)
Mechanios (/mob): Cut Battle Area(Mechanios (/mob))
----output
/turf/World/Base_Turfs/Grass
-5
-5
-----end output

Within Pasting_Turfs (PT) list is all of the turfs types. I've understood that the New() handles the placing so I haven't overwritten it or anything. what I don't understand is the "type null" part, as it has the type. do I need to define somewhere that its a turf?
Hn, try debugging yuour code (both '#define DEBUG' and adding... let's say...
world<<"Checking: [list2params(PT)]"
where world << "----output" is... it seems like the turfs were not added into the PT list, but you know.. juyst to make sure my assumption is correct.

Reason for debugging: To give us a better idea of what exactly the problem could be and how we can help you (or you help yourself).

- GhostAnime
In response to GhostAnime
The output. I have no idea how to make any sense of this:

list contains: %2fturf%2fWorld%2fBase_Turfs%2fGrass&%2fturf%2fWorld%2fBase_T urfs%2fGrass&%2fturf%2fWorld%2fBase_Turfs%2fOrientation%2fH& %2fturf%2fWorld%2fBase_Turfs%2fUnder%2fD&%2fturf%2fWorld%2fBa se_Turfs%2fUnder%2fC&%2fturf%2fdense&%2fturf%2fdense&%2fturf %2fWorld%2fBuildings%2fFloors%2fTile%2fReeds%2fA&%2fturf%2fWo rld%2fBuildings%2fFloors%2fTile%2fReeds%2fA&%2fturf%2fWorld% 2fBuildings%2fFloors%2fTile%2fReeds%2fA&%2fturf%2fWorld%2fBu ildings%2fFloors%2fTile%2fReeds%2fA&%2fturf%2fWorld%2fBase_T urfs%2fGrass&%2fturf%2fWorld%2fBase_Turfs%2fOrientation%2fH& %2fturf%2fWorld%2fBase_Turfs%2fGrass%2fH_1%2fD&%2fturf%2fWorl d%2fBase_Turfs%2fUnder%2fC&%2fturf%2fdense&%2fturf%2fdense&% 2fturf%2fWorld%2fBuildings%2fObjects%2fBarrels%2fType1%2fB&% 2fturf%2fWorld%2fBuildings%2fFloors%2fTile%2fReeds%2fA&%2ftu rf%2fWorld%2fBuildings%2fFloors%2fTile%2fReeds%2fA&%2fturf%2 fWorld%2fBuildings%2fFloors%2fTile%2fReeds%2fA&%2fturf%2fWor ld%2fBuildings%2fFloors%2fTile%2fReeds%2fA&%2fturf%2fWorld%2 fBase_Turfs%2fOrientation%2fH&%2fturf%2fWorld%2fBase_Turfs%2 fGrass%2fH_1%2fD&%2fturf%2fWorld%2fBase_Turfs%2fUnder%2fC&%2 fturf%2fWorld%2fBase_Turfs%2fGrass&%2fturf%2fdense&%2fturf%2 fdense&%2fturf%2fWorld%2fBuildings%2fObjects%2fBarrels%2fTyp e1%2fB&%2fturf%2fWorld%2fBuildings%2fFloors%2fTile%2fReeds%2 fA&%2fturf%2fWorld%2fBuildings%2fFloors%2fTile%2fReeds%2fA&% 2fturf%2fWorld%2fBuildings%2fFloors%2fTile%2fReeds%2fA&%2ftu rf%2fWorld%2fBuildings%2fFloors%2fTile%2fReeds%2fA&%2fturf%2 fWorld%2fBase_Turfs%2fGrass%2fH_1%2fD&%2fturf%2fWorld%2fBase _Turfs%2fUnder%2fC&%2fturf%2fWorld%2fBase_Turfs%2fGrass&%2ft urf%2fWorld%2fBase_Turfs%2fGrass&%2fturf%2fWorld%2fBase_Turf s%2fGrass&%2fturf%2fWorld%2fBase_Turfs%2fOrientation%2fG&%2f turf%2fWorld%2fBase_Turfs%2fGrass&%2fturf%2fWorld%2fBuilding s%2fFloors%2fTile%2fReeds%2fA&%2fturf%2fWorld%2fBuildings%2f Floors%2fTile%2fReeds%2fA&%2fturf%2fWorld%2fBuildings%2fFloo rs%2fTile%2fReeds%2fA&%2fturf%2fWorld%2fBuildings%2fObjects% 2fBarrels%2fType1%2fB&%2fturf%2fWorld%2fBase_Turfs%2fUnder%2 fC&%2fturf%2fWorld%2fBase_Turfs%2fGrass&%2fturf%2fWorld%2fBa se_Turfs%2fGrass&%2fturf%2fWorld%2fBase_Turfs%2fGrass&%2ftur f%2fWorld%2fBase_Turfs%2fGrass&%2fturf%2fWorld%2fBase_Turfs% 2fGrass&%2fturf%2fWorld%2fBase_Turfs%2fGrass&%2fturf%2fWorld %2fBase_Turfs%2fOrientation%2fE&%2fturf%2fWorld%2fBuildings%2 fEgde%2fB&%2fturf%2fWorld%2fBuildings%2fObjects%2fBarrels%2f Type1%2fB&%2fturf%2fdense&%2fturf%2fdense&%2fturf%2fWorld%2f Areas%2fRife%2fBarriers%2fBarrier1B&%2fturf%2fWorld%2fBase_T urfs%2fGrass&%2fturf%2fWorld%2fBase_Turfs%2fGrass&%2fturf%2f World%2fBase_Turfs%2fGrass&%2fturf%2fWorld%2fBase_Turfs%2fGr ass&%2fturf%2fWorld%2fBase_Turfs%2fGrass&%2fturf%2fWorld%2fB ase_Turfs%2fOrientation%2fD&%2fturf%2fdense&%2fturf%2fdense& %2fturf%2fdense&%2fturf%2fdense&%2fturf%2fdense&%2fturf%2fWor ld%2fAreas%2fRife%2fBarriers%2fBarrier1B&%2fturf%2fWorld%2fB ase_Turfs%2fGrass&%2fturf%2fWorld%2fBase_Turfs%2fGrass&%2ftu rf%2fWorld%2fBase_Turfs%2fGrass&%2fturf%2fWorld%2fBase_Turfs %2fGrass&%2fturf%2fWorld%2fBase_Turfs%2fGrass&%2fturf%2fdense &%2fturf%2fdense&%2fturf%2fWorld%2fBase_Turfs%2fGrass%2fH_1%2f A&%2fturf%2fWorld%2fBase_Turfs%2fGrass%2fH_1&%2fturf%2fdense &%2fturf%2fdense&%2fturf%2fWorld%2fAreas%2fRife%2fBarriers%2fB arrier1B&%2fturf%2fWorld%2fBase_Turfs%2fGrass&%2fturf%2fWorl d%2fBase_Turfs%2fGrass&%2fturf%2fWorld%2fBase_Turfs%2fGrass& %2fturf%2fWorld%2fBase_Turfs%2fGrass&%2fturf%2fWorld%2fBase_T urfs%2fGrass&%2fturf%2fdense&%2fturf%2fWorld%2fBase_Turfs%2f Grass%2fH_1&%2fturf%2fWorld%2fBase_Turfs%2fGrass%2fH_1&%2ftu rf%2fWorld%2fBase_Turfs%2fGrass%2fH_1&%2fturf%2fdense&%2ftur f%2fdense&%2fturf%2fWorld%2fAreas%2fRife%2fBarriers%2fBarrie r1B&%2fturf%2fWorld%2fBase_Turfs%2fGrass&%2fturf%2fWorld%2fB ase_Turfs%2fGrass&%2fturf%2fWorld%2fBase_Turfs%2fGrass&%2ftu rf%2fdense&%2fturf%2fWorld%2fBase_Turfs%2fGrass%2fH_1&%2ftur f%2fWorld%2fAreas%2fRife%2fNature%2fBushs&%2fturf%2fWorld%2f Base_Turfs%2fGrass%2fH_1&%2fturf%2fWorld%2fBase_Turfs%2fGras s%2fH_1&%2fturf%2fWorld%2fBase_Turfs%2fGrass%2fH_1&%2fturf%2 fdense&%2fturf%2fdense&%2fturf%2fWorld%2fAreas%2fRife%2fBarr iers%2fBarrier1B&%2fturf%2fWorld%2fBase_Turfs%2fGrass&%2ftur f%2fdense&%2fturf%2fWorld%2fBase_Turfs%2fGrass%2fH_1&%2fturf %2fWorld%2fBase_Turfs%2fGrass%2fH_1&%2fturf%2fWorld%2fAreas%2 fRife%2fNature%2fBushs&%2fturf%2fWorld%2fBase_Turfs%2fGrass% 2fH_1&%2fturf%2fWorld%2fBase_Turfs%2fGrass%2fH_1&%2fturf%2fW orld%2fBase_Turfs%2fGrass%2fH_1&%2fturf%2fWorld%2fBase_Turfs %2fGrass%2fH_1&%2fturf%2fdense&%2fturf%2fdense&%2fturf%2fWorl d%2fAreas%2fRife%2fBarriers%2fBarrier1B&%2fturf%2fWorld%2fBa se_Turfs%2fUnder%2fA&%2fturf%2fWorld%2fBase_Turfs%2fUnder%2f B&%2fturf%2fWorld%2fBase_Turfs%2fGrass%2fH_1&%2fturf%2fWorld %2fAreas%2fRife%2fNature%2fBushs
-5
-5
-----
In response to Mechanios
Hn, seems like the file is alright (list2params gives a sort of html_encoded string.. eg: list("Hi"," bye") will be "Hi&%20bye" where %20=> spac, &=seperator)

I honestly have no clue o.o' Than again, I am tired... when you but #define DEBUG, did two more lines in the error showed? (it showed of showed the source's line number)

- GhostAnime - Tired
In response to GhostAnime
I'll keep fiddling with it. Maybe I'll look at some of my old projects with such things.

Hopefully someone comes up with a solution for this, I'm completely stumped right now.

In response to Mechanios
I could be mistaken, as I haven't taken a terribly long amount of time to check out the code, but I've noticed you're going through and adding turf types to a list, then using text2path() on the already-existant typepaths. Is that really necessary? Try just 'new PT[i]' instead of 'new T'.

Also, for future reference, whenever using var/T=text2path(text), make sure there is a T, otherwise you will indeed get nasty errors about a null type to create from.
In response to Detnom
I tried new PT[i], but having the ()s after it gave me an error.
In response to Mechanios
Okay, then just do T=PT[i], then new T(). It should work fine. The whole text2path(PT[i]) returns nothing when processing what's already a path, I tested it.
In response to Detnom
Hmn. Now I'm having problems with the locating. :(
                if(X < 0  && Y < 0)
world <<"[M.x-abs(X)], [M.y-abs(Y)], [M.z]"
new T(M.x-abs(X), M.y-abs(Y), M.z) // bottom left line 62
else if(X > 0 && Y < 0)
world <<"[M.x-abs(X)], [M.y-abs(Y)], [M.z]"
new T(M.x+X, M.y-abs(Y), M.z) // bottom right
else if(X > 0 && Y > 0)
world <<"[M.x-abs(X)], [M.y-abs(Y)], [M.z]"
new T(M.x+X, M.y+Y, M.z) // top right
else
world <<"[M.x-abs(X)], [M.y-abs(Y)], [M.z]"
new T(M.x-abs(X), M.y+Y, M.z)// top left

runtime error: bad loc
verb name: Paste Battle Area (/datum/verb/Paste_Battle_Area)
source file: Tactics - Battle System.dm,62
usr: Mechanios (/mob)
src: Mechanios (/mob)
call stack:
Mechanios (/mob): Paste Battle Area(Mechanios (/mob), /list (/list), /list (/list), /list (/list), 29, 37)
Mechanios (/mob): Cut Battle Area(Mechanios (/mob))
/turf/World/Base_Turfs/Grass // type
list contains: /turf/World/Base_Turfs/Grass // whats in PT[1]
-5 // x
-5 // y
-----
13, 99, 4 location to be created.

I've checked the map the Battlefields are on. The player is ported there fine and all. Does the "loc" argument in New() have to be passed as one argument? Last I checked, it didn't.
And the abs() gives an absolute value, meaning -5 would = 5
In response to Mechanios
I'm not too sure if you can pass it individually like that, try doing a locate() instead of passing the x,y,z directly.
In response to Detnom
ugh I'm failng tonite.
I a set a locate up right at the new, it says expected ene of statement. If I try doing ti a line atfer like A.loc = locate(), it says cannot change constate value.

if I altered new, then would having it like so:
turf/New(l, loc)
if(!l) ..()
else loc = locate(loc)

thens sending it like so:
new T {1,  x, y, z)

Then i don't think it would treat the x,y,z as one loc, then. I'll try it and see what happens.
In response to Mechanios
*cough*

locate(X,Y,Z)


meaning:

new T(M.x-abs(X), M.y+Y, M.z)
should be
new T(locate(M.x-abs(X), M.y+Y, M.z))



---

My beautifying way of compressing that location snippet from [link]


                if(X < 0  && Y < 0)
world <<"[M.x-abs(X)], [M.y-abs(Y)], [M.z]"
new T(M.x-abs(X), M.y-abs(Y), M.z) // bottom left line 62
else if(X > 0 && Y < 0)
world <<"[M.x-abs(X)], [M.y-abs(Y)], [M.z]"
new T(M.x+X, M.y-abs(Y), M.z) // bottom right
else if(X > 0 && Y > 0)
world <<"[M.x-abs(X)], [M.y-abs(Y)], [M.z]"
new T(M.x+X, M.y+Y, M.z) // top right
else
world <<"[M.x-abs(X)], [M.y-abs(Y)], [M.z]"
new T(M.x-abs(X), M.y+Y, M.z)// top left


to

new T(locate(M.x+X, M.y+Y, M.z))


Why did I got rid of -abs()? Simple. abs() ALWAYS makes the number positive... so it's kinda redundent of what you were doing:

var
a=1
b=2
c=-4

a+b+c = 1+2+(-4) = 3-4 = -1

//Your method
a+b-abs(c) = 1+2-abs(-4) = 1+2-(+4) = 3-4 = -1


...so yeah...


- GhostAnime - Hitting his head for not noticing that the path entered was not a text ._.