Variables don't work when using set layer?
Posted: Tue Apr 01, 2014 9:26 pm
Hello all! Korvic here. I've been racking my brain at this for a bit now. For a style of map generation that I am using (grid based generation with sprites) and the art style I'm trying to accomplish I need to set the layers of my walls to be the top, less one. (E.G. set the layer of last img to top - 1) I tried seeing if LiveCode was intuitive enough to get that done, but no luck. No big deal, I had a plan in the back of my head to use variables in a simple timer-like structure. I created a system in which it would start off at 9000, set the layer of last img to 9000 (vLayer in my case, where vLayer is 9000), then reduce it to 8999 and continue on until the map generation was done. I'm using a 30x20 grid, so at max there's 1200 items (twice as much as the entire map) with the system I'm using, so there should be no problem. I've tested the system by having it answer and/or put vLayer back to me, and it's working fine. I then tried just setting the vLayer to 9000, flat out. It worked. Is there some trick to getting variables to work with set layer? I've tried using brackets, to no avail. I'll post the actual code section itself below, thanks in advance for any aid I can get for this. I really don't want to stay at school for the next 3 hours to do nothing. 
-Korvic
I cut off the bottom, seeing as it's just player movement that I'm getting into.

-Korvic
Code: Select all
global vMap, vCharAmount, vHeightCount, f, iPerson, jPerson, iP, jP, e, spritewidth, screenwidth, vshotcount, vshotmax, vshotspeed, nbBullet, FList, DUList, DDList
local vWall, vXDir, vYDir, FirstF, vLayer, FirstDU, FirstDD, roomnumber
on opencard
send mouseup to button "Create"
end opencard
on mapgen
--Variable Reset
put 0 into nbBullet
put 1 into f
put 1 into roomnumber
put 30 into spritewidth
put 100 into vshotspeed
put 900 into screenwidth
put 9001 into vLayer
put true into FirstF
put true into FirstDD
put true into FirstDU
put the number of chars of vMap into vCharAmount
put ( vCharAmount / ( screenwidth / spritewidth ) ) into vHeightCount
--Place / Sort Map Sprites
repeat with j = 1 to vHeightCount
repeat with i = 1 to ( vCharAmount / vHeightCount )
put i + (j-1)*( vCharAmount / vHeightCount ) into n
switch (char n of vMap)
case "W"
clone img WallPNG.png
set the loc of last img to ((i*spritewidth)+49),((j*spritewidth)+62)
put false into vWall
break
case "U"
clone img DoorUpPNG.png
set the name of last img to "dudummy" & n
if FirstDU = true then
put false into FirstDU
put n into DUList
else
put DUList &","&n into DUList
end if
set the loc of last img to ((i*spritewidth)+52),((j*spritewidth)+52)
set the layer of last img to vLayer
clone img FloorPNG.png
put true into vWall
break
case "D"
clone img DoorDownPNG.png
set the name of last img to "dddummy" & n
if FirstDD = true then
put false into FirstDD
put n into DDList
else
put DDList &","&n into DDList
end if
set the loc of last img to ((i*spritewidth)+52),((j*spritewidth)+52)
set the layer of last img to vLayer
clone img FloorPNG.png
put true into vWall
break
case "B"
clone img BlanchePNG.png
put true into vWall
break
case "N"
clone img NoirPNG.png
set the loc of last img to ((i*spritewidth)+52),((j*spritewidth)+52)
put false into vWall
break
case "C"
clone img StartPNG.png
put true into vWall
break
case "S"
set the loc of img PersonPNG.png to ((i*spritewidth)+52),((j*spritewidth)+52)
clone img FloorPNG.png
put true into vWall
put i into iPerson
put j into jPerson
break
case "E"
clone img WaterGIF.gif
break
case "F"
clone img FPNG.png
set the name of last img to "fdummy" & n
if FirstF = true then
put false into FirstF
put n into FList
else
put FList &","&n into FList
end if
set the loc of last img to ((i*spritewidth)+52),((j*spritewidth)+52)
set the layer of last img to vLayer
clone img FloorPNG.png
put true into vWall
break
default
clone img FloorPNG.png
put true into vWall
break
end switch
set the name of last img to "dummy" & n
if vWall = true then
set the loc of last img to ((i*spritewidth)+52),((j*spritewidth)+52)
set the layer of last img to 0
else
set the layer of last img to vLayer
put vLayer - 1 into vLayer
end if
end repeat
end repeat
set the layer of img PersonPNG.png to top
end mapgen