Log In  


function sel_layer(name)
	local m = fetch("map/0.map")
	local map_no = 0
	for i in pairs(m) do
		if m[i].name == name then
			map_no = i
			break
		end
	end
	if map_no != 0 then
		memmap(m[map_no].bmp, 0x100000)
	else
		error("There is no map data named '" .. name .. "'")
	end
end

I have saved the aforementioned code as a file named 'layer.lua'.
By utilizing this code, we can load specific map layers based on their assigned names.

To illustrate, imagine a map with a layer configuration as depicted in the following image.

include "layer.lua"

function _draw()
	sel_layer("sky")
	map(0, 0)

	sel_layer("house")
	map(0, 0)

	sel_layer("tree")
	map(0, 0)
end
1



[Please log in to post a comment]