mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-26 11:27:38 +00:00
Allow equipping pocket computers on the bottom
This allows equipping pocket computers on both the back (as before) and bottom of a pocket computer. The asymmetry is a little unfortunate here, but makes some sense with the crafting recipe (above goes behind, below goes on the bottom). - Move some functionality from IPocketAccess into a PocketComputer interface (and PocketComputerInternal) interface, used by the pocket API. IPocketAccess preserves the same interface as before. Unlike ITurtleAccess, we /don't/ expose the PocketSide in the public API. - Several pocket-computer methods (e.g. setUpgradeData, setColour) are now required to be called on the main thread, and when the computer is being held. This allows us to write back changes to the item immediately, rather than the next time the item is ticked. Sadly this doesn't actually remove the need for onCraftedPostProcess as I'd originally hoped, but I think does make the code a little simpler. - Rename "computercraft:pocket_computer" component to "computercraft:back_pocket_computer". - And finally, support multiple upgrades on the pocket computer. This is actually quite an easy change, just tedious — there's lots of places to update! Fixes #1406, and I think fixes #1148 — you can use a speaker to notify you now.
This commit is contained in:
@@ -7,9 +7,27 @@ if not pocket then
|
||||
return
|
||||
end
|
||||
|
||||
local ok, err = pocket.equipBack()
|
||||
if not ok then
|
||||
printError(err)
|
||||
else
|
||||
print("Item equipped")
|
||||
if select('#', ...) > 1 then
|
||||
local programName = arg[0] or fs.getName(shell.getRunningProgram())
|
||||
print("Usage: " .. programName .. " <side>")
|
||||
return
|
||||
end
|
||||
|
||||
local function equip(fn)
|
||||
local ok, err = fn()
|
||||
if not ok then
|
||||
printError(err)
|
||||
else
|
||||
print("Item equipped")
|
||||
end
|
||||
end
|
||||
|
||||
local side = ... or "back"
|
||||
if side == "back" then
|
||||
equip(pocket.equipBack)
|
||||
elseif side == "bottom" then
|
||||
equip(pocket.equipBottom)
|
||||
else
|
||||
printError("Unknown side. Expected 'back' or 'bottom'.")
|
||||
return
|
||||
end
|
||||
|
||||
@@ -7,9 +7,27 @@ if not pocket then
|
||||
return
|
||||
end
|
||||
|
||||
local ok, err = pocket.unequipBack()
|
||||
if not ok then
|
||||
printError(err)
|
||||
else
|
||||
print("Item unequipped")
|
||||
if select('#', ...) > 1 then
|
||||
local programName = arg[0] or fs.getName(shell.getRunningProgram())
|
||||
print("Usage: " .. programName .. " <side>")
|
||||
return
|
||||
end
|
||||
|
||||
local function unequip(fn)
|
||||
local ok, err = fn()
|
||||
if not ok then
|
||||
printError(err)
|
||||
else
|
||||
print("Item unequipped")
|
||||
end
|
||||
end
|
||||
|
||||
local side = ... or "back"
|
||||
if side == "back" then
|
||||
unequip(pocket.unequipBack)
|
||||
elseif side == "bottom" then
|
||||
unequip(pocket.unequipBottom)
|
||||
else
|
||||
printError("Unknown side. Expected 'back' or 'bottom'.")
|
||||
return
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user