I just tried it but it doesn’t work:
self.preview_buf = buffer.create(MAP_WIDTH * MAP_HEIGHT,
{ { name = hash("rgb"), type = buffer.VALUE_TYPE_UINT8, count = 3 } })
local tstream = buffer.get_stream(self.preview_buf, hash("rgb"))
for x = 0, MAP_WIDTH - 1 do
for y = 0, MAP_HEIGHT - 1 do
i = 3 * (y * MAP_WIDTH + x) + 1
tstream[i + 0] = 0x33
tstream[i + 1] = 0x33
tstream[i + 2] = 0x33
end
end
-- Dot
tstream[1] = 0xFF
local tparams = {
width = MAP_WIDTH,
height = MAP_HEIGHT,
type = graphics.TEXTURE_TYPE_2D,
format = graphics.TEXTURE_FORMAT_RGB,
}
self.preview_tex = resource.create_texture("/preview.texturec", tparams, self.preview_buf)
local aparams = {
texture = "/preview.texturec",
animations = {
id = "preview",
width = MAP_WIDTH,
height = MAP_HEIGHT,
frame_start = 1,
frame_end = 1,
},
geometries = {
{
id = 'preview',
vertices = {
0, 0,
0, MAP_HEIGHT,
MAP_WIDTH, MAP_HEIGHT,
MAP_WIDTH, 0
},
uvs = {
0, 0,
0, MAP_HEIGHT,
MAP_WIDTH, MAP_HEIGHT,
MAP_WIDTH, 0
},
indices = { 0, 1, 2, 0, 2, 3 }
}
}
}
self.preview_atlas = resource.create_atlas("/preview.texturesetc", aparams)
gui.set_texture(self.preview, self.preview_atlas)
I got the error:
ERROR:SCRIPT: generator/generator_menu.gui_script:67: bad argument #7 to 'create_atlas' (table expected, got number)
There’s no argument #7, I think?