Skip to content

Commit

Permalink
so many changes I never checked in?
Browse files Browse the repository at this point in the history
cosmetic changes for phase drill
partial import bus implementation
beginnings of container proxy
  • Loading branch information
zetaPRIME committed Apr 22, 2019
1 parent 60cbf94 commit fd2c708
Show file tree
Hide file tree
Showing 20 changed files with 388 additions and 30 deletions.
49 changes: 49 additions & 0 deletions StarTech/startech/interface/storagenet/importbus.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{ // -*- grammar-ext: json -*-
"gui" : {
"background" : {
"type" : "background",
"mouseTransparent" : true,
"fileFooter" : "/startech/interface/storagenet/storagebus.png?scalenearest=1.0" // if we make this the footer, it's all draggable
},
"title" : {
"type" : "label",
"position" : [7, 31],
"value" : "Import Bus Settings"
},
"filter" : {
"type" : "textbox",
"position" : [7, 19],
"textAlign" : "left",
"maxWidth" : 207,
"hint" : "Filter",
"callback" : "null",
"enterKey" : "next"
},
"priority" : {
"type" : "textbox",
"position" : [7, 5],
"textAlign" : "left",
"maxWidth" : 207,
"hint" : "Priority",
"callback" : "null",
"enterKey" : "apply"
}/*,
"apply" : {
"type" : "button",
"position" : [162, 5],
"zlevel" : 100,
"base" : "/interface/button.png",
"hover" : "/interface/buttonhover.png",
"pressed" : "/interface/button.png", // no stock pressed image?
"pressedOffset" : [0, 0],
"caption" : "Apply"
}//*/
},

"scriptWidgetCallbacks" : [
"apply", "next"
],

"scripts" : ["/startech/interface/storagenet/importbus.lua"],
"scriptDelta" : 1
}
27 changes: 27 additions & 0 deletions StarTech/startech/interface/storagenet/importbus.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require "/lib/stardust/sync.lua"

function init()
sync.poll("getInfo", onRecvInfo)
widget.focus("filter")
end

function update()
sync.runQueue()
end

function onRecvInfo(rpc)
if rpc:succeeded() then
local res = rpc:result()
widget.setText("filter", res.filter)
widget.setText("priority", res.priority .. "")
end
end

function next(wid)
widget.focus("priority")
end

function apply()
sync.msg("setInfo", widget.getText("filter"), tonumber(widget.getText("priority")) or 0)
pane.dismiss() -- might as well
end
13 changes: 8 additions & 5 deletions StarTech/startech/items/active/tools/phasedrill.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ function setBeam(endPoint, width, opacity)

if chain.segmentLight then
local l = chain.segmentLight.color
l[1] = l[1] * opacity * 0.64;
l[2] = l[2] * opacity * 0.64;
l[3] = l[3] * opacity * 0.64;
local intensity = opacity^.25
l[1] = l[1] * intensity * 0.64;
l[2] = l[2] * intensity * 0.64;
l[3] = l[3] * intensity * 0.64;
end


Expand Down Expand Up @@ -224,7 +225,7 @@ states.fire = {
end
end
processLiquidAccumulation()
bw = bw * 0.8
bw = bw * 0.64
collectItems(pt, rad * 1.25 * 1.25)
elseif fireMode == "primary" then
if world.damageTileArea(pt, rad, "foreground", origin, "beamish", 1, 99999) then aec = aec + pwr.hitTilesPrimary end
Expand All @@ -238,7 +239,9 @@ states.fire = {
end
else enterState("release") end

setBeam(pt, bw, 1.0)
--if (state.time/.05) % 1 >= 0.5 then bw = bw * 0.25 end
local mul = ({1, 1, .825, 1, .75, .825})[1+math.floor((state.time/.015)% 6 )]
setBeam(pt, bw*mul, mul)
if aec > 0 then
power.drawEquipEnergy(aec)
end
Expand Down
4 changes: 4 additions & 0 deletions StarTech/startech/items/active/tools/wrench.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ function update(dt, fireMode, shiftHeld, moves)
self.previousFireMode = fireMode
end

function uninit()
--status.setResource("energy", 0)
end

function xfire(moves, shiftHeld)
-- test
--world.damageTileArea(activeItem.ownerAimPosition(), 10, "background", activeItem.ownerAimPosition(), "beamish", 1000000, 1000000)
Expand Down
Binary file added StarTech/startech/objects/storagenet/exportbus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
145 changes: 145 additions & 0 deletions StarTech/startech/objects/storagenet/importbus.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
require "/scripts/util.lua"
require "/scripts/vec2.lua"

require "/lib/stardust/network.lua"
require "/lib/stardust/itemutil.lua"

orientations = {
{ 0, -1 },
{ -1, 0 },
{ 0, 1 },
{ 1, 0 }
}
orientName = { "down", "left", "up", "right" }

maxSpeedUpgrades = 5
rates = {
30, 15, 8, 4, 2, 1
}
function updateRates()
idleRate = 60
drawRate = rates[1+cfg.speedUpgrades]
end

function init()
if not storage.orientation then storage.orientation = 1 end
storage.cfg = storage.cfg or { } ; cfg = storage.cfg
cfg.speedUpgrades = cfg.speedUpgrades or 0
updateRates()
script.setUpdateDelta(drawRate)

object.setInteractive(false)
message.setHandler("wrenchInteract", onWrench)

message.setHandler("uiUpdate", uiUpdate)

object.setAnimationParameter("orientation", storage.orientation)
end

function onWrench(msg, isLocal, player, shiftHeld)
if shiftHeld then
return {
interact = {
id = entity.id(),
type = config.getParameter("interactAction"),
config = config.getParameter("interactData")
}
}
else
local dl = {"v","<","^",">"}
storage.orientation = (storage.orientation % 4) + 1
object.setAnimationParameter("orientation", storage.orientation)
object.say(dl[storage.orientation])
end
end

function uiGetInfo() return { filter = storage.filter or "", priority = storage.priority } end
function uiSetInfo(msg, isLocal, filter, priority)
storage.priority = priority
local pr = "Priority set: " .. storage.priority .. "\n"
if filter == "" then
storage.filter = nil
object.say(pr .. "Filter cleared")
else
storage.filter = filter
object.say(pr .. "Filter set: " .. filter)
end
end

function uiUpdate(msg, isLocal, t)
t = t or { } -- safety
-- merge sent config
for k,v in pairs(t.cfg or { }) do cfg[k] = v end

-- special commands (item-sync security etc.)
for cmd, param in pairs(t.cmd or { }) do

end

updateRates()
return cfg
end

function match(item)
if not cfg.matchItem then return true end -- success if no match set
if item.name ~= cfg.matchItem.name then return false end -- fail if not the same item
return cfg.matchFuzzy or itemutil.canStack(item, cfg.matchItem)
end

function update(dt)
script.setUpdateDelta(idleRate) -- set delta to idle delay, then set back to configured delta if successful
if not shared.controller then return end -- abort if not connected
local numDraw = cfg.stackUpgrade and 99999 or 1

local spos = vec2.add(entity.position(), orientations[storage.orientation])
local sid = world.objectAt(spos) or entity.id()

local slots = world.containerSize(sid) or 0
if slots < 1 then return end

local idle = true
local contents = world.containerItems(sid)
for i=1,slots do
local itm = contents[i]
if itm and match(itm) then
local iitm = { name = itm.name, count = math.min(numDraw, itm.count), parameters = itm.parameters }
local bcount = iitm.count
shared.controller:tryPutItem(iitm)
if iitm.count < bcount then
idle = false
world.containerTakeNumItemsAt(sid, i-1, bcount - iitm.count)
break
end
end
end

if idle then return end
script.setUpdateDelta(drawRate) -- reset delta
end

function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end

function containerCallback(...)
--
end

function sendItems()
if not shared.controller then return {} end
return shared.controller:listItems()
end

function onStorageNetUpdate()
-- save memory by sharing a single cache among all things that have touched since last unload!
itemutil.mergeConfigCache(shared.controller.id)
end
50 changes: 50 additions & 0 deletions StarTech/startech/objects/storagenet/importbus.object
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{ // -*- grammar-ext: json -*-
"objectName" : "startech:storagenet.importbus",
"colonyTags" : ["wired"],
"printable" : false,
"rarity" : "Common",
"description" : "An import bus. Draws items from external inventories into a transmatter storage network.",
"shortdescription" : "Transmatter Import Bus",
"race" : "human",

"category" : "storagenet",
"price" : 500,

//"inventoryIcon" : "importbus.png?blendadd=/startech/objects/storagenet/exportbus.png;-4;0",
"inventoryIcon" : "importbus.png",
"orientations" : [
{
"image" : "importbus.png",
"imagePosition" : [0, 0],
"renderLayer" : "object+100",

"spaceScan" : 0.1,
"anchors" : [ "background" ]
}
],
"zlevel" : 10000,

"scripts" : [ "importbus.lua" ],
"scriptDelta" : 60,

//"animation" : "storagebus.animation",
"animationScripts" : [ "storagebus.render.lua" ],

"interactAction" : "ScriptPane",
"interactData" : "/startech/interface/storagenet/importbus.config",

/*"animation" : "/objects/wired/logic/logic.animation",

"animationParts" : {
"switch" : "/objects/wired/logic/bulb.png"
},
"animationPosition" : [-8, -8], */

"networkTags" : {
"storageNet" : true
},

"inputNodes" : [ [0, 0] ]

//
}
Binary file added StarTech/startech/objects/storagenet/importbus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
9 changes: 0 additions & 9 deletions StarTech/startech/objects/storagenet/storagebus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ function onWrench(msg, isLocal, player, shiftHeld)
local dl = {"v","<","^",">"}
storage.orientation = (storage.orientation % 4) + 1
object.setAnimationParameter("orientation", storage.orientation)
--animator.setAnimationState("orientation", orientName[storage.orientation])
object.say(dl[storage.orientation])
end
end
Expand All @@ -62,10 +61,6 @@ function uiSetInfo(msg, isLocal, filter, priority)
end
end

function update(dt)
--
end

function dump(o)
if type(o) == 'table' then
local s = '{ '
Expand All @@ -79,10 +74,6 @@ function dump(o)
end
end

function containerCallback(...)
--
end

function sendItems()
if not shared.controller then return {} end
return shared.controller:listItems()
Expand Down
3 changes: 1 addition & 2 deletions StarTech/startech/objects/storagenet/storagebus.object
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
"zlevel" : 10000,

"scripts" : [ "storagebus.lua" ],
"scriptDelta" : 1,
"scriptDelta" : 0,

"animation" : "storagebus.animation",
"animationScripts" : [ "storagebus.render.lua" ],

"interactAction" : "ScriptPane",
Expand Down
4 changes: 0 additions & 4 deletions StarTech/startech/objects/storagenet/storagebus.render.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,11 @@ function update()
localAnimator.clearLightSources()

local pos = vec2.add(objectAnimator.position(), {0.5, 0.5})
--pos[1] = pos[1] - 1
--local gpos = { pos[1], pos[2] + -3 + (self.glowPos / 8.0) }

-- glow
localAnimator.addDrawable({
--image = table.concat({self.dGlow, "?addmask=", self.dMask}),
image = self.dGlow,
position = pos,
--rotation = rot[animator.animationState("orientation")],
rotation = rot[animationConfig.animationParameter("orientation", 1)],
fullbright = true,
centered = true,
Expand Down
4 changes: 2 additions & 2 deletions StarTech/startech/objects/testing/stardusttest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function update(dt)
blah2 = blah2 + 1
end

function onInteraction(args)
function AonInteraction(args)
--object.setConfigParameter("slotCount", math.random(9))
local items = world.containerTakeAll(entity.id())
items[1].count = 9999
Expand Down Expand Up @@ -123,7 +123,7 @@ function containerCallback(...)
_ccdis = false
end]]

function containerCallback()
function nope_containerCallback()
for k,v in pairs(world.objectQuery(object.position(), 10)) do
interop.hack(v).object.smash()
end
Expand Down
Loading

0 comments on commit fd2c708

Please sign in to comment.