Setting up levels in SCL
Levels are supported in SCL by assigning data or variables 'into' levels, then setting the global level variable.
Names for data and variables assigned to different levels have the same name, but different level names. Then when a value is requested by a
given name, the value for that level is used.
Example (which you can run in the develop studio scratchpad)
create data from list as charNames into Level1
set
"Sue" "Mary" "Johnny" "Casper"
end
create data from list as charNames into Level2
set
"Larry" "Steward" "Ann" "Nadine"
end
create var as BadGuy into Level1 where value="ED" end
create var as BadGuy into Level2 where value="STEVE" end
create routine as Start
set level=Level1
log(data.charNames.next) // prints "Sue"
log(BadGuy) // prints "Ed"
set level=Level2
log(data.charNames.next) // prints "Larry"
log(BadGuy) // prints "STEVE"
end
set
"Sue" "Mary" "Johnny" "Casper"
end
create data from list as charNames into Level2
set
"Larry" "Steward" "Ann" "Nadine"
end
create var as BadGuy into Level1 where value="ED" end
create var as BadGuy into Level2 where value="STEVE" end
create routine as Start
set level=Level1
log(data.charNames.next) // prints "Sue"
log(BadGuy) // prints "Ed"
set level=Level2
log(data.charNames.next) // prints "Larry"
log(BadGuy) // prints "STEVE"
end
To see the mechanism at work, you can view the SCL source code for Shear Terror which provides four different
mazes as levels. Open Shear Terror source in
a new window. In that example, the levels are simply numbered: 1, 2, 3 and 4. Search for "set level" to see how they are used.
Notice how a variable called bkimg is defined four times, but each time into a different level with a different value.