file:write ( num_to_char( number / 65536 )) -- x>>16
file:write ( num_to_char( number / 16777216 )) -- x>>24
end
function main ()
if mappy.msgBox ("Export binary file", "This example script will export the current layer as a binary file (CDXMap format) (anims are replaced with block 0)\nThis is the same as the default .map format when you save a .map file\n\nRun the script (you will be prompted for a filename to save as)?", mappy.MMB_OKCANCEL, mappy.MMB_ICONQUESTION) == mappy.MMB_OK then
local w = mappy.getValue(mappy.MAPWIDTH)
local h = mappy.getValue(mappy.MAPHEIGHT)
if (w == 0) then
mappy.msgBox ("Export binary file", "You need to load or create a map first", mappy.MMB_OK, mappy.MMB_ICONINFO)
else
local isok,asname = mappy.fileRequester (".", "CDXMap files (*.map)", "*.map", mappy.MMB_SAVE)
if isok == mappy.MMB_OK then
if (not (string.sub (string.lower (asname), -4) == ".map")) then