This commit is contained in:
Aria 2025-03-21 22:23:30 +11:00
commit 9c94d113d3
Signed by untrusted user who does not match committer: aria
GPG key ID: 19AB7AA462B8AB3B
10260 changed files with 1237388 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

View file

@ -0,0 +1,40 @@
{
"gui" : {
"background" : {
"zlevel" : 0,
"type" : "background",
"fileHeader" : "/testconsole1/consoleheader.png",
"fileBody" : "/testconsole1/consolebody.png"
},
"scriptCanvas" : {
"zlevel" : 1,
"type" : "canvas",
"rect" : [40, 45, 434, 254],
"captureMouseEvents" : true,
"captureKeyboardEvents" : true
},
"close" : {
"zlevel" : 2,
"type" : "button",
"base" : "/interface/x.png",
"hover" : "/interface/xhover.png",
"pressed" : "/interface/xpress.png",
"pressedOffset" : [0, 0],
"callback" : "close",
"position" : [419, 263]
}
},
"scripts" : ["/testconsole1/testconsole1gui.lua"],
"scriptDelta" : 5,
"canvasClickCallbacks" : {
"scriptCanvas" : "canvasClickEvent"
},
"canvasKeyCallbacks" : {
"scriptCanvas" : "canvasKeyEvent"
},
"scriptWidgetCallbacks" : [
]
}

View file

@ -0,0 +1,102 @@
lightGridSize = 9
lightSize = 16
lightShrink = 2
lightXStart = 120
lightYStart = 30
function lightPosition(light)
return {(light[1] - 1) * lightSize + lightXStart, (light[2] - 1) * lightSize + lightYStart}
end
function lightFor(pos)
return {math.floor((pos[1] - lightXStart) / lightSize) + 1, math.floor((pos[2] - lightYStart) / lightSize) + 1}
end
function lightWithinRange(light)
return light[1] >= 1 and light[1] <= lightGridSize and light[2] >= 1 and light[2] <= lightGridSize
end
function lightValue(light)
if lightWithinRange(light) then
return self.lights[light[1]..":"..light[2]]
else
return false
end
end
function setLightValue(light, val)
if lightWithinRange then
self.lights[light[1]..":"..light[2]] = val
end
end
function toggleLightValue(light)
setLightValue(light, not lightValue(light))
end
function init()
self.lights = {}
for x = 1, lightGridSize do
for y = 1, lightGridSize do
setLightValue({x, y}, true)
end
end
self.canvas = widget.bindCanvas("scriptCanvas")
widget.focus("scriptCanvas")
end
function update()
self.canvas:clear()
for x = 1, lightGridSize do
for y = 1, lightGridSize do
if lightValue({x, y}) then
local pos = lightPosition({x, y})
self.canvas:drawRect(
{pos[1] + lightShrink, pos[2] + lightShrink, pos[1] + lightSize - lightShrink, pos[2] + lightSize - lightShrink},
{255, 255, 255}
)
local gridMin = {lightXStart, lightYStart}
local gridMax = {lightXStart + lightSize * lightGridSize, lightYStart + lightSize * lightGridSize}
self.canvas:drawPoly(
{{gridMin[1], gridMin[2]}, {gridMax[1], gridMin[2]}, {gridMax[1], gridMax[2]}, {gridMin[1], gridMax[2]}},
{255, 255, 255}
)
end
end
end
local allGone = true
for x = 1, lightGridSize do
for y = 1, lightGridSize do
if lightValue({x, y}) then
allGone = false
end
end
end
if allGone then
world.sendEntityMessage(pane.sourceEntity(), "youwin")
pane.dismiss()
end
end
function canvasClickEvent(position, button, buttonDown)
if buttonDown then
local light = lightFor(position)
if lightWithinRange(light) then
if button == 1 then
pane.playSound("/sfx/interface/keypad_press.ogg", 0, 1.0)
toggleLightValue({light[1], light[2]})
toggleLightValue({light[1] - 1, light[2]})
toggleLightValue({light[1], light[2] - 1})
toggleLightValue({light[1] + 1, light[2]})
toggleLightValue({light[1], light[2] + 1})
end
end
end
end

View file

@ -0,0 +1,5 @@
function init()
message.setHandler("youwin", function()
world.spawnItem(config.getParameter("winningItem"), vec2.add(objecct.position(), {0, 3}))
end)
end

View file

@ -0,0 +1,35 @@
{
"objectName" : "testconsole1",
"colonyTags" : [],
"rarity" : "Common",
"category" : "decorative",
"price" : 400,
"lightColor" : [150, 215, 235],
"description" : "This machine runs a game called 'Lights Off!'.",
"shortdescription" : "Arcade Game",
"race" : "generic",
"inventoryIcon" : "testconsole1objecticon.png",
"orientations" : [
{
"leftImage" : "testconsole1objectleft.png:<color>.<frame>",
"rightImage" : "testconsole1objectright.png:<color>.<frame>",
"imagePosition" : [-8, 0],
"frames" : 2,
"animationCycle" : 0.6,
"spaceScan" : 0.1,
"anchors" : [ "bottom" ]
}
],
"scripts" : [ "/scripts/vec2.lua", "testconsole1object.lua" ],
"scriptDelta" : 5,
"interactAction" : "ScriptPane",
"interactData" : "/testconsole1/testconsole1gui.config",
"winningItem" : ["money", 100]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 B

View file

@ -0,0 +1,14 @@
{
"frameGrid" : {
"size" : [24, 40],
"dimensions" : [3, 1],
"names" : [
[ "default.off", "default.0", "default.1" ]
]
},
"aliases" : {
"default.default" : "default.off"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -0,0 +1,14 @@
{
"frameGrid" : {
"size" : [24, 40],
"dimensions" : [3, 1],
"names" : [
[ "default.off", "default.0", "default.1" ]
]
},
"aliases" : {
"default.default" : "default.off"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB