diff --git a/StarTech/startech/interface/storagenet/importbus.config b/StarTech/startech/interface/storagenet/importbus.config new file mode 100644 index 00000000..04acb0e6 --- /dev/null +++ b/StarTech/startech/interface/storagenet/importbus.config @@ -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 +} diff --git a/StarTech/startech/interface/storagenet/importbus.lua b/StarTech/startech/interface/storagenet/importbus.lua new file mode 100644 index 00000000..bc695282 --- /dev/null +++ b/StarTech/startech/interface/storagenet/importbus.lua @@ -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 diff --git a/StarTech/startech/items/active/tools/phasedrill.lua b/StarTech/startech/items/active/tools/phasedrill.lua index 10cef8a7..81e4f59b 100644 --- a/StarTech/startech/items/active/tools/phasedrill.lua +++ b/StarTech/startech/items/active/tools/phasedrill.lua @@ -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 @@ -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 @@ -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 diff --git a/StarTech/startech/items/active/tools/wrench.lua b/StarTech/startech/items/active/tools/wrench.lua index 33f92caa..e16a9ef3 100644 --- a/StarTech/startech/items/active/tools/wrench.lua +++ b/StarTech/startech/items/active/tools/wrench.lua @@ -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) diff --git a/StarTech/startech/objects/storagenet/exportbus.png b/StarTech/startech/objects/storagenet/exportbus.png new file mode 100644 index 00000000..6af6259f Binary files /dev/null and b/StarTech/startech/objects/storagenet/exportbus.png differ diff --git a/StarTech/startech/objects/storagenet/exportbus.xcf b/StarTech/startech/objects/storagenet/exportbus.xcf new file mode 100644 index 00000000..a55f30f7 Binary files /dev/null and b/StarTech/startech/objects/storagenet/exportbus.xcf differ diff --git a/StarTech/startech/objects/storagenet/importbus.lua b/StarTech/startech/objects/storagenet/importbus.lua new file mode 100644 index 00000000..6def3509 --- /dev/null +++ b/StarTech/startech/objects/storagenet/importbus.lua @@ -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 diff --git a/StarTech/startech/objects/storagenet/importbus.object b/StarTech/startech/objects/storagenet/importbus.object new file mode 100644 index 00000000..2db50891 --- /dev/null +++ b/StarTech/startech/objects/storagenet/importbus.object @@ -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] ] + + // +} diff --git a/StarTech/startech/objects/storagenet/importbus.png b/StarTech/startech/objects/storagenet/importbus.png new file mode 100644 index 00000000..356eeb29 Binary files /dev/null and b/StarTech/startech/objects/storagenet/importbus.png differ diff --git a/StarTech/startech/objects/storagenet/importbus.xcf b/StarTech/startech/objects/storagenet/importbus.xcf new file mode 100644 index 00000000..f0098e52 Binary files /dev/null and b/StarTech/startech/objects/storagenet/importbus.xcf differ diff --git a/StarTech/startech/objects/storagenet/storagebus.lua b/StarTech/startech/objects/storagenet/storagebus.lua index 83da6716..e095fac2 100644 --- a/StarTech/startech/objects/storagenet/storagebus.lua +++ b/StarTech/startech/objects/storagenet/storagebus.lua @@ -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 @@ -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 = '{ ' @@ -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() diff --git a/StarTech/startech/objects/storagenet/storagebus.object b/StarTech/startech/objects/storagenet/storagebus.object index e098f27e..57cd452c 100644 --- a/StarTech/startech/objects/storagenet/storagebus.object +++ b/StarTech/startech/objects/storagenet/storagebus.object @@ -24,9 +24,8 @@ "zlevel" : 10000, "scripts" : [ "storagebus.lua" ], - "scriptDelta" : 1, + "scriptDelta" : 0, - "animation" : "storagebus.animation", "animationScripts" : [ "storagebus.render.lua" ], "interactAction" : "ScriptPane", diff --git a/StarTech/startech/objects/storagenet/storagebus.render.lua b/StarTech/startech/objects/storagenet/storagebus.render.lua index e3704433..b10dbdf8 100644 --- a/StarTech/startech/objects/storagenet/storagebus.render.lua +++ b/StarTech/startech/objects/storagenet/storagebus.render.lua @@ -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, diff --git a/StarTech/startech/objects/testing/stardusttest.lua b/StarTech/startech/objects/testing/stardusttest.lua index 9a52e5a5..ca7e71e1 100644 --- a/StarTech/startech/objects/testing/stardusttest.lua +++ b/StarTech/startech/objects/testing/stardusttest.lua @@ -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 @@ -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 diff --git a/StarTech/startech/objects/testing/stardusttest.object b/StarTech/startech/objects/testing/stardusttest.object index 003b489c..b6172bda 100644 --- a/StarTech/startech/objects/testing/stardusttest.object +++ b/StarTech/startech/objects/testing/stardusttest.object @@ -31,7 +31,8 @@ }, "animationPosition" : [-8, -8], - "uiConfig" : "/interface/chests/chesttest.config", + //"uiConfig" : "/interface/chests/chesttest.config", + "uiConfig" : "/sys/stardust/autocontainer.config", //"interactAction" : "ScriptConsole", //"interactData" : "/objects/generic/arcadegame/arcadegamegui.config", diff --git a/StardustLib/sys/stardust/autocontainer-guest.lua b/StardustLib/sys/stardust/autocontainer-guest.lua new file mode 100644 index 00000000..7d920871 --- /dev/null +++ b/StardustLib/sys/stardust/autocontainer-guest.lua @@ -0,0 +1,11 @@ +function init() + cId = config.getParameter("containerId") +end + +function update() + if status.statusProperty("stardust.containerPaneSyncId") ~= cId then pane.dismiss() end +end + +function uninit() + if status.statusProperty("stardust.containerPaneSyncId") == cId then status.setStatusProperty("stardust.containerPaneSyncId", nil) end +end diff --git a/StardustLib/sys/stardust/autocontainer-host.lua b/StardustLib/sys/stardust/autocontainer-host.lua new file mode 100644 index 00000000..59449fa8 --- /dev/null +++ b/StardustLib/sys/stardust/autocontainer-host.lua @@ -0,0 +1,45 @@ +-- + + +function msg(txt) + world.sendEntityMessage(pane.playerEntityId(), "playerext:message", txt) +end + +function init() + -- + --world.sendEntityMessage(pane.playerEntityId(), "playerext:message", "test: " .. (world.getObjectParameter(pane.containerEntityId(), "uiConfig") or "nil")) + --[[local c = world.containerItems(pane.containerEntityId()) + local m = "items: " + for k,v in pairs(c) do + m = m .. v.name .. " " + end + msg(m)==]] + cId = pane.containerEntityId() + + local p = { gui = { } } + p.containerId = cId + --p.openWithInventory = true + p.gui.panefeature = { + type = "panefeature", + --anchor = "CenterBottom" + --offset = { 20, 0 } + } + p.gui.base = { + type = "background", + fileFooter = "/sys/stardust/nothing.png?scalenearest=128;192?replace=00000000=000000?fade=7f7fff=1" + } + p.scripts = { "/sys/stardust/autocontainer-guest.lua" } + + status.setStatusProperty("stardust.containerPaneSyncId", cId) + player.interact("ScriptPane", p) + --player.interact("Container", "/startech/interface/storagenet/terminal.config", cId) + +end + +function update() + if status.statusProperty("stardust.containerPaneSyncId") ~= cId then pane.dismiss() end +end + +function uninit() + if status.statusProperty("stardust.containerPaneSyncId") == cId then status.setStatusProperty("stardust.containerPaneSyncId", nil) end +end diff --git a/StardustLib/sys/stardust/autocontainer.config b/StardustLib/sys/stardust/autocontainer.config new file mode 100644 index 00000000..1324cceb --- /dev/null +++ b/StardustLib/sys/stardust/autocontainer.config @@ -0,0 +1,17 @@ +{ // -*- grammar-ext: json -*- + "gui" : { + "background" : { + "type" : "background", + "fileFooter" : "/interface/inventory/empty.png?scalenearest=0.0" // magic non-interface! + }, + "itemGrid" : { + "type" : "itemgrid", + "position" : [-100, 0], + "dimensions" : [0,0], + "spacing" : [22, 20], + "backingImage" : "/interface/inventory/empty.png" + } + }, + "scripts" : ["/sys/stardust/autocontainer-host.lua"], + "scriptDelta" : 1 +} diff --git a/build-release.sh b/build-release.sh index 539ef0e6..ce034818 100755 --- a/build-release.sh +++ b/build-release.sh @@ -28,6 +28,16 @@ asset_packer () { "$_asset_packer" "$@" } +confirm () { + read -p "$1 [y/n]" -n 1 -r + echo # + if [[ $REPLY =~ ^[Yy]$ ]] + then + return 0 + fi + return 1 +} + function pack { echo $1 rm -rf ./_release/$1/ diff --git a/todo.txt b/todo.txt index 418e4e84..8272dc3a 100644 --- a/todo.txt +++ b/todo.txt @@ -1,6 +1,19 @@ - -move the business end of playerext:openInterface into a library function so panes can use it directly (while keeping things clean and easily-updatable) +! TRADING SYSTEM { + basically Path of Exile's trade UI + quickbar button puts an item in cursor; clicking on a player prompts them to accept/reject trade, via playerext + right click dismisses without trading, and emits a sound effect to the player (might need UI shenanigans for local sfx?) + cursor item should make it look like a trade-icon cursor, if that's achievable + on (unexpected) uninit, spawn a stagehand at player position that lasts for ~.5sec and deletes cursor item from anywhere it can find + (consume item drops, consume from containers within reach, consume from player inventory) +} + +lib frontend for playerextender, to make things a bit more convenient (also polymorphism in case playerext needs to change) +see if activeitems can store data into themselves; if so, give phase drill its own battery? +alternative, tip-glow-only effect for phase drill when cursor is too close to player +^ actually, just add particles to beam tip and snap them to the lens if too close +- some sort of animation for the beam during phase drill hold to make it look like it's doing something and not just sitting there configurable tram stop { built-in player sensor @@ -16,7 +29,7 @@ somewhat redesign UI to make better use of now-unneeded tooltip area TERMINAL THEMABILITY? make terminal not update every tick just for animation if it's not waiting on any players -BYOS functionality as machine { +x BYOS functionality as machine { // probably incompatible with FU's version damageTileArea with ridiculously high strength and harvest level and radius big enough to cover a t8 vanilla ship from one end, in both fg and bg itemDropQuery and collect into database upgrade player ship to custom tier to get rid of bg image and collision material @@ -26,6 +39,7 @@ patch warp state matching into encounter variations of booster flames (/objects/ add distinguishing names to even/odd small booster flames lots of shiny new ship components, especially animating ones that match their state to flight { - also floor-only teleporters (implemented as part of telepads) + warp cores should count as FU ones, if possible } power stuffs { @@ -65,10 +79,6 @@ networked wire I/O ports make RCS tech obtainable; balance energy use -recipes { - (all clear!) -} - clean up tinkertable categories some major cleanup in places @@ -82,7 +92,7 @@ Extend sync library { generate responseID with makeuuid? register with an anonymous function for continuation of operation after response } -Transmatter network reimplementation { +// Transmatter network reimplementation { // not sure if it's needed or if drive bays just need further fixing up Controller { API { callable via both callScriptedEntity and sendEntityMessage