-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cosmetic changes for phase drill partial import bus implementation beginnings of container proxy
- Loading branch information
Showing
20 changed files
with
388 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] ] | ||
|
||
// | ||
} |
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.