v1.4.4
This commit is contained in:
commit
9c94d113d3
10260 changed files with 1237388 additions and 0 deletions
BIN
assets/devel/testconsole1/consolebody.png
Normal file
BIN
assets/devel/testconsole1/consolebody.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
BIN
assets/devel/testconsole1/consoleheader.png
Normal file
BIN
assets/devel/testconsole1/consoleheader.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
40
assets/devel/testconsole1/testconsole1gui.config
Normal file
40
assets/devel/testconsole1/testconsole1gui.config
Normal 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" : [
|
||||
]
|
||||
}
|
102
assets/devel/testconsole1/testconsole1gui.lua
Normal file
102
assets/devel/testconsole1/testconsole1gui.lua
Normal 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
|
5
assets/devel/testconsole1/testconsole1object.lua
Normal file
5
assets/devel/testconsole1/testconsole1object.lua
Normal file
|
@ -0,0 +1,5 @@
|
|||
function init()
|
||||
message.setHandler("youwin", function()
|
||||
world.spawnItem(config.getParameter("winningItem"), vec2.add(objecct.position(), {0, 3}))
|
||||
end)
|
||||
end
|
35
assets/devel/testconsole1/testconsole1object.object
Normal file
35
assets/devel/testconsole1/testconsole1object.object
Normal 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]
|
||||
}
|
BIN
assets/devel/testconsole1/testconsole1objecticon.png
Normal file
BIN
assets/devel/testconsole1/testconsole1objecticon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 421 B |
14
assets/devel/testconsole1/testconsole1objectleft.frames
Normal file
14
assets/devel/testconsole1/testconsole1objectleft.frames
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
|
||||
"frameGrid" : {
|
||||
"size" : [24, 40],
|
||||
"dimensions" : [3, 1],
|
||||
"names" : [
|
||||
[ "default.off", "default.0", "default.1" ]
|
||||
]
|
||||
},
|
||||
|
||||
"aliases" : {
|
||||
"default.default" : "default.off"
|
||||
}
|
||||
}
|
BIN
assets/devel/testconsole1/testconsole1objectleft.png
Normal file
BIN
assets/devel/testconsole1/testconsole1objectleft.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
14
assets/devel/testconsole1/testconsole1objectright.frames
Normal file
14
assets/devel/testconsole1/testconsole1objectright.frames
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
|
||||
"frameGrid" : {
|
||||
"size" : [24, 40],
|
||||
"dimensions" : [3, 1],
|
||||
"names" : [
|
||||
[ "default.off", "default.0", "default.1" ]
|
||||
]
|
||||
},
|
||||
|
||||
"aliases" : {
|
||||
"default.default" : "default.off"
|
||||
}
|
||||
}
|
BIN
assets/devel/testconsole1/testconsole1objectright.png
Normal file
BIN
assets/devel/testconsole1/testconsole1objectright.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Loading…
Add table
Add a link
Reference in a new issue