trying to get a little bit of... structure into image names; cleaned up some shell stuff; added pastebin downloader
@ -2,9 +2,9 @@
|
||||
oc:block.Adapter.name=Adapter
|
||||
oc:block.Cable.name=Kabel
|
||||
oc:block.Capacitor.name=Kondensator
|
||||
oc:block.CaseAdvanced.name=Hochwertiges Gehäuse
|
||||
oc:block.CaseBasic.name=Einfaches Gehäuse
|
||||
oc:block.CaseProfessional.name=Professionelles Gehäuse
|
||||
oc:block.Case0.name=Einfaches Gehäuse
|
||||
oc:block.Case1.name=Hochwertiges Gehäuse
|
||||
oc:block.Case2.name=Ausgezeichnetes Gehäuse
|
||||
oc:block.Charger.name=Ladestation
|
||||
oc:block.DiskDrive.name=Diskettenlaufwerk
|
||||
oc:block.Keyboard.name=Tastatur
|
||||
@ -13,33 +13,37 @@ oc:block.PowerDistributor.name=Stromverteiler
|
||||
oc:block.Robot.name=Roboter
|
||||
oc:block.RobotAfterimage.name=Roboter
|
||||
oc:block.Router.name=Router
|
||||
oc:block.ScreenAdvanced.name=Hochwertiger Bildschirm
|
||||
oc:block.ScreenBasic.name=Einfacher Bildschirm
|
||||
oc:block.ScreenProfessional.name=Professioneller Bildschirm
|
||||
oc:block.Screen0.name=Einfacher Bildschirm
|
||||
oc:block.Screen1.name=Hochwertiger Bildschirm
|
||||
oc:block.Screen2.name=Ausgezeichneter Bildschirm
|
||||
|
||||
# Items
|
||||
oc:item.ALU.name=Arithmetisch-logische Einheit (ALU)
|
||||
oc:item.Analyzer.name=Messgerät
|
||||
oc:item.ArithmeticLogicUnit.name=Arithmetisch-logische Einheit (ALU)
|
||||
oc:item.ArrowKeys.name=Pfeiltasten
|
||||
oc:item.ButtonGroup.name=Tastengruppe
|
||||
oc:item.CircuitBoard.name=Basis Platte
|
||||
oc:item.CardBase.name=Kartenbasis
|
||||
oc:item.CircuitBoard.name=Leiterplatte
|
||||
oc:item.ControlUnit.name=Steuerwerk (CU)
|
||||
oc:item.CPU.name=Hauptprozessor (CPU)
|
||||
oc:item.Card.name=Karte
|
||||
oc:item.Crafting.name=Crafting
|
||||
oc:item.Crafting.name=Crafting Upgrade
|
||||
oc:item.CuttingWire.name=Schneidedraht
|
||||
oc:item.FloppyDisk.name=Diskette
|
||||
oc:item.Generator.name=Generator
|
||||
oc:item.GraphicsCardAdvanced.name=Hochwertige Grafikkarte
|
||||
oc:item.GraphicsCardBasic.name=Einfache Grafikkarte
|
||||
oc:item.GraphicsCardProfessional.name=Professionelle Grafikkarte
|
||||
oc:item.Disk.name=Platte
|
||||
oc:item.Floppy.name=Diskette
|
||||
oc:item.Generator.name=Generator Upgrade
|
||||
oc:item.GraphicsCard0.name=Einfache Grafikkarte
|
||||
oc:item.GraphicsCard1.name=Hochwertige Grafikkarte
|
||||
oc:item.GraphicsCard2.name=Ausgezeichnete Grafikkarte
|
||||
oc:item.HardDiskDrive.name=Festplatte
|
||||
oc:item.IronNugget.name=Eisennugget
|
||||
oc:item.Memory.name=Speicher
|
||||
oc:item.Microchip0.name=Einfacher Microchip
|
||||
oc:item.Microchip1.name=Hochwertiger Microchip
|
||||
oc:item.Microchip2.name=Ausgezeichneter Microchip
|
||||
oc:item.NetworkCard.name=Netzwerkkarte
|
||||
oc:item.NumPad.name=Ziffernblock
|
||||
oc:item.PrintedCircuitBoard.name=Leiterplatte (PCB)
|
||||
oc:item.RawCircuitBoard.name=Rohe Basis Platte
|
||||
oc:item.PrintedCircuitBoard.name=Gedruckte Leiterplatte (PCB)
|
||||
oc:item.RawCircuitBoard.name=Leiterplattenrohling
|
||||
oc:item.RedstoneCard.name=Redstonekarte
|
||||
oc:item.Transistor.name=Transistor
|
||||
oc:item.WirelessNetworkCard.name=Drahtlosnetzwerkkarte
|
||||
@ -52,6 +56,7 @@ oc:gui.Analyzer.RobotName=Name
|
||||
oc:gui.Analyzer.RobotOwner=Besitzer
|
||||
oc:gui.Analyzer.StoredEnergy=Gespeicherte Energie
|
||||
oc:gui.Analyzer.TotalEnergy=Insgesamt gespeicherte Energie
|
||||
oc:gui.Analyzer.Users=Benutzer
|
||||
oc:gui.Robot.Power=Energie
|
||||
oc:gui.Robot.TurnOff=Ausschalten
|
||||
oc:gui.Robot.TurnOn=Einschalten
|
||||
|
@ -6,9 +6,9 @@
|
||||
oc:block.Adapter.name=Adapter
|
||||
oc:block.Cable.name=Cable
|
||||
oc:block.Capacitor.name=Capacitor
|
||||
oc:block.CaseAdvanced.name=Advanced Case
|
||||
oc:block.CaseBasic.name=Basic Case
|
||||
oc:block.CaseProfessional.name=Professional Case
|
||||
oc:block.Case0.name=Basic Case
|
||||
oc:block.Case1.name=Advanced Case
|
||||
oc:block.Case2.name=Superior Case
|
||||
oc:block.Charger.name=Charger
|
||||
oc:block.DiskDrive.name=Disk Drive
|
||||
oc:block.Keyboard.name=Keyboard
|
||||
@ -17,29 +17,33 @@ oc:block.PowerDistributor.name=Power Distributor
|
||||
oc:block.Robot.name=Robot
|
||||
oc:block.RobotAfterimage.name=Robot
|
||||
oc:block.Router.name=Router
|
||||
oc:block.ScreenAdvanced.name=Advanced Screen
|
||||
oc:block.ScreenBasic.name=Basic Screen
|
||||
oc:block.ScreenProfessional.name=Professional Screen
|
||||
oc:block.Screen0.name=Basic Screen
|
||||
oc:block.Screen1.name=Advanced Screen
|
||||
oc:block.Screen2.name=Superior Screen
|
||||
|
||||
# Items
|
||||
oc:item.ALU.name=Arithmetic Logic Unit (ALU)
|
||||
oc:item.Analyzer.name=Analyzer
|
||||
oc:item.ArithmeticLogicUnit.name=Arithmetic Logic Unit (ALU)
|
||||
oc:item.ArrowKeys.name=Arrow Keys
|
||||
oc:item.ButtonGroup.name=Button Group
|
||||
oc:item.CardBase.name=Card Base
|
||||
oc:item.CircuitBoard.name=Circuit Board
|
||||
oc:item.ControlUnit.name=Control Unit (CU)
|
||||
oc:item.CPU.name=Central Processing Unit (CPU)
|
||||
oc:item.Card.name=Card
|
||||
oc:item.Crafting.name=Crafting
|
||||
oc:item.Crafting.name=Crafting Upgrade
|
||||
oc:item.CuttingWire.name=Cutting Wire
|
||||
oc:item.Disk.name=Disk Platter
|
||||
oc:item.FloppyDisk.name=Floppy Disk
|
||||
oc:item.Generator.name=Generator
|
||||
oc:item.GraphicsCardAdvanced.name=Advanced Graphics Card
|
||||
oc:item.GraphicsCardBasic.name=Basic Graphics Card
|
||||
oc:item.GraphicsCardProfessional.name=Professional Graphics Card
|
||||
oc:item.Generator.name=Generator Upgrade
|
||||
oc:item.GraphicsCard0.name=Basic Graphics Card
|
||||
oc:item.GraphicsCard1.name=Advanced Graphics Card
|
||||
oc:item.GraphicsCard2.name=Superior Graphics Card
|
||||
oc:item.HardDiskDrive.name=Hard Disk Drive
|
||||
oc:item.IronNugget.name=Iron Nugget
|
||||
oc:item.Memory.name=Memory
|
||||
oc:item.Microchip0.name=Simple Microchip
|
||||
oc:item.Microchip1.name=Advanced Microchip
|
||||
oc:item.Microchip2.name=Superior Microchip
|
||||
oc:item.NetworkCard.name=Network Card
|
||||
oc:item.NumPad.name=Numeric Keypad
|
||||
oc:item.PrintedCircuitBoard.name=Printed Circuit Board (PCB)
|
||||
|
@ -16,7 +16,7 @@ while term.isAvailable() do
|
||||
local expression = load("return " .. command, "=stdin", "t", env)
|
||||
local code = expression or statement
|
||||
if code then
|
||||
local result = table.pack(shell.execute(code))
|
||||
local result = table.pack(pcall(code))
|
||||
if not result[1] or result.n > 1 then
|
||||
print(table.unpack(result, 2, result.n))
|
||||
end
|
||||
|
57
assets/opencomputers/lua/rom/bin/pastebin.lua
Normal file
@ -0,0 +1,57 @@
|
||||
local args, options = shell.parse(...)
|
||||
if #args < 2 then
|
||||
print("Usage: pastebin [-f] <id> <file>")
|
||||
print(" -f: Force overwriting existing files.")
|
||||
return
|
||||
end
|
||||
|
||||
local m = component.modem
|
||||
if not m or not m.isWireless() then
|
||||
print("no primary wireless modem found")
|
||||
return
|
||||
end
|
||||
|
||||
if not m.isHttpEnabled() then
|
||||
print("http support is not enabled")
|
||||
return
|
||||
end
|
||||
|
||||
local id = args[1]
|
||||
local filename = shell.resolve(args[2])
|
||||
|
||||
if fs.exists(filename) then
|
||||
if not options.f or not os.remove(filename) then
|
||||
print("file already exists")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local url = "http://pastebin.com/raw.php?i=" .. id
|
||||
local result, reason = m.send(url)
|
||||
if not result then
|
||||
print("failed sending request: " .. reason)
|
||||
return
|
||||
end
|
||||
|
||||
local f, reason = io.open(filename, "w")
|
||||
if not f then
|
||||
print("failed opening file for writing: " .. reason)
|
||||
return
|
||||
end
|
||||
|
||||
repeat
|
||||
local _, responseUrl, result, reason = event.pull("http_response")
|
||||
if responseUrl == url then
|
||||
if not result and reason then
|
||||
print("failed fetching data: " .. reason)
|
||||
f:close()
|
||||
return
|
||||
end
|
||||
if result then
|
||||
f:write(result)
|
||||
end
|
||||
end
|
||||
until not result
|
||||
|
||||
f:close()
|
||||
print("saved data to " .. filename)
|
@ -1,4 +1,5 @@
|
||||
local event, listeners, timers = {}, {}, {}
|
||||
local lastInterrupt = -math.huge
|
||||
|
||||
local function matches(signal, name, filter)
|
||||
if name and not (type(signal[1]) == "string" and signal[1]:match(name))
|
||||
@ -144,6 +145,7 @@ function event.pull(...)
|
||||
end
|
||||
tick()
|
||||
if event.shouldInterrupt() then
|
||||
lastInterrupt = os.uptime()
|
||||
error("interrupted", 0)
|
||||
end
|
||||
if not (seconds or hasFilter) or matches(signal, name, filter) then
|
||||
@ -153,7 +155,8 @@ function event.pull(...)
|
||||
end
|
||||
|
||||
function event.shouldInterrupt()
|
||||
return keyboard.isControlDown() and
|
||||
return os.uptime() - lastInterrupt > 1 and
|
||||
keyboard.isControlDown() and
|
||||
keyboard.isAltDown() and
|
||||
keyboard.isKeyDown(keyboard.keys.c)
|
||||
end
|
||||
|
@ -153,6 +153,11 @@ function filesystem.mount(fs, path)
|
||||
end
|
||||
end
|
||||
|
||||
function filesystem.path(path)
|
||||
local parts = segments(path)
|
||||
return table.concat(parts, "/", 1, #parts - 1) .. "/"
|
||||
end
|
||||
|
||||
function filesystem.name(path)
|
||||
local parts = segments(path)
|
||||
return parts[#parts]
|
||||
@ -410,7 +415,7 @@ local function onComponentAdded(_, address, componentType)
|
||||
name = filesystem.concat("/mnt", name)
|
||||
filesystem.mount(proxy, name)
|
||||
if isAutorunEnabled then
|
||||
shell.execute(filesystem.concat(name, "autorun"), proxy)
|
||||
os.execute(filesystem.concat(name, "autorun"), proxy)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -18,15 +18,11 @@ os.execute = function(command)
|
||||
for part in tail:gmatch("%S+") do
|
||||
table.insert(args, part)
|
||||
end
|
||||
return shell.execute(head, table.unpack(args))
|
||||
return shell.execute(head, _ENV, table.unpack(args))
|
||||
end
|
||||
|
||||
function os.exit()
|
||||
local result, reason = shell.kill(coroutine.running())
|
||||
if result then
|
||||
coroutine.yield() -- never returns
|
||||
end
|
||||
error(reason, 2)
|
||||
error("terminated", 0)
|
||||
end
|
||||
|
||||
os.remove = fs.remove
|
||||
|
@ -1,8 +1,8 @@
|
||||
local shell = {}
|
||||
local cwd = "/"
|
||||
local path = {"/bin/", "/usr/bin/", "/home/bin/"}
|
||||
local aliases = {dir="ls", move="mv", rename="mv", copy="cp", del="rm",
|
||||
md="mkdir", cls="clear", more="less", rs="redstone",
|
||||
local aliases = {dir="ls", list="ls", move="mv", rename="mv", copy="cp",
|
||||
del="rm", md="mkdir", cls="clear", more="less", rs="redstone",
|
||||
view="edit -r"}
|
||||
local running = {}
|
||||
|
||||
@ -77,65 +77,6 @@ function shell.setWorkingDirectory(dir)
|
||||
end
|
||||
end
|
||||
|
||||
function shell.execute(program, ...)
|
||||
if type(program) ~= "function" then
|
||||
local where, reason = shell.resolve(program, "lua")
|
||||
if not where then
|
||||
return nil, reason
|
||||
end
|
||||
local code, reason = loadfile(where, "t", setmetatable({}, {__index=_ENV}))
|
||||
if not code then
|
||||
return nil, reason
|
||||
end
|
||||
program = code
|
||||
end
|
||||
local co, args, result = coroutine.create(program), table.pack(true, ...), nil
|
||||
running[co] = true
|
||||
while running[co] and args[1] do
|
||||
result = table.pack(coroutine.resume(co, table.unpack(args, 2, args.n)))
|
||||
if coroutine.status(co) ~= "dead" then
|
||||
-- Emulate CC behavior by making yields a filtered event.wait.
|
||||
if type(result[2]) == "string" then
|
||||
args = table.pack(pcall(event.pull, table.unpack(result, 2, result.n)))
|
||||
else
|
||||
args = {true, n=1}
|
||||
end
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
running[co] = nil
|
||||
if not args[1] then
|
||||
return false, "interrupted"
|
||||
end
|
||||
return table.unpack(result, 1, result.n)
|
||||
end
|
||||
|
||||
function shell.kill(co)
|
||||
if running[co] ~= nil then
|
||||
running[co] = nil
|
||||
return true
|
||||
end
|
||||
return nil, "not a program thread"
|
||||
end
|
||||
|
||||
function shell.parse(...)
|
||||
local params = table.pack(...)
|
||||
local args = {}
|
||||
local options = {}
|
||||
for i = 1, params.n do
|
||||
local param = params[i]
|
||||
if unicode.sub(param, 1, 1) == "-" then
|
||||
for j = 2, unicode.len(param) do
|
||||
options[unicode.sub(param, j, j)] = true
|
||||
end
|
||||
else
|
||||
table.insert(args, param)
|
||||
end
|
||||
end
|
||||
return args, options
|
||||
end
|
||||
|
||||
function shell.getPath()
|
||||
return table.concat(path, ":")
|
||||
end
|
||||
@ -170,6 +111,59 @@ function shell.resolve(path, ext)
|
||||
end
|
||||
end
|
||||
|
||||
function shell.execute(program, env, ...)
|
||||
checkArg(1, program, "string")
|
||||
local filename, reason = shell.resolve(program, "lua")
|
||||
if not filename then
|
||||
return nil, reason
|
||||
end
|
||||
local code, reason = loadfile(filename, "t", setmetatable({}, {__index=env}))
|
||||
if not code then
|
||||
return nil, reason
|
||||
end
|
||||
local co, args, result = coroutine.create(code), table.pack(true, ...), nil
|
||||
table.insert(running, filename)
|
||||
-- Emulate CC behavior by making yields a filtered event.pull()
|
||||
repeat
|
||||
result = table.pack(coroutine.resume(co, table.unpack(args, 2, args.n)))
|
||||
if coroutine.status(co) == "dead" then
|
||||
break
|
||||
end
|
||||
if type(result[2]) == "string" then
|
||||
args = table.pack(pcall(event.pull, table.unpack(result, 2, result.n)))
|
||||
else
|
||||
args = {true, n=1}
|
||||
end
|
||||
until not args[1]
|
||||
table.remove(running)
|
||||
if not args[1] then
|
||||
return false, args[2]
|
||||
end
|
||||
return table.unpack(result, 1, result.n)
|
||||
end
|
||||
|
||||
function shell.parse(...)
|
||||
local params = table.pack(...)
|
||||
local args = {}
|
||||
local options = {}
|
||||
for i = 1, params.n do
|
||||
local param = params[i]
|
||||
if unicode.sub(param, 1, 1) == "-" then
|
||||
for j = 2, unicode.len(param) do
|
||||
options[unicode.sub(param, j, j)] = true
|
||||
end
|
||||
else
|
||||
table.insert(args, param)
|
||||
end
|
||||
end
|
||||
return args, options
|
||||
end
|
||||
|
||||
function shell.running(level)
|
||||
level = level or 1
|
||||
return running[1 + (#running - level)]
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
_G.shell = shell
|
||||
|
Before Width: | Height: | Size: 301 B After Width: | Height: | Size: 301 B |
Before Width: | Height: | Size: 301 B After Width: | Height: | Size: 301 B |
Before Width: | Height: | Size: 301 B After Width: | Height: | Size: 301 B |
Before Width: | Height: | Size: 268 B After Width: | Height: | Size: 268 B |
Before Width: | Height: | Size: 293 B After Width: | Height: | Size: 293 B |
Before Width: | Height: | Size: 313 B After Width: | Height: | Size: 313 B |
Before Width: | Height: | Size: 330 B After Width: | Height: | Size: 330 B |
Before Width: | Height: | Size: 520 B After Width: | Height: | Size: 520 B |
Before Width: | Height: | Size: 208 B |
Before Width: | Height: | Size: 508 B After Width: | Height: | Size: 208 B |
BIN
assets/opencomputers/textures/items/disk_floppy.png
Normal file
After Width: | Height: | Size: 508 B |
Before Width: | Height: | Size: 346 B After Width: | Height: | Size: 346 B |
Before Width: | Height: | Size: 350 B After Width: | Height: | Size: 350 B |
Before Width: | Height: | Size: 345 B After Width: | Height: | Size: 345 B |
Before Width: | Height: | Size: 287 B After Width: | Height: | Size: 287 B |
Before Width: | Height: | Size: 292 B After Width: | Height: | Size: 292 B |
Before Width: | Height: | Size: 294 B After Width: | Height: | Size: 294 B |
Before Width: | Height: | Size: 303 B After Width: | Height: | Size: 303 B |
Before Width: | Height: | Size: 301 B After Width: | Height: | Size: 301 B |
Before Width: | Height: | Size: 398 B After Width: | Height: | Size: 398 B |
Before Width: | Height: | Size: 215 B After Width: | Height: | Size: 215 B |
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 236 B |
Before Width: | Height: | Size: 247 B After Width: | Height: | Size: 247 B |
Before Width: | Height: | Size: 372 B After Width: | Height: | Size: 372 B |
Before Width: | Height: | Size: 313 B After Width: | Height: | Size: 313 B |
@ -4,7 +4,7 @@ import cpw.mods.fml.common.registry.GameRegistry
|
||||
import li.cil.oc.common.item
|
||||
import net.minecraft.item.{Item, ItemStack}
|
||||
import net.minecraftforge.oredict.OreDictionary
|
||||
import li.cil.oc.common.item.Disc
|
||||
import li.cil.oc.common.item.Disk
|
||||
|
||||
object Items {
|
||||
var multi: item.Delegator = null
|
||||
@ -36,11 +36,11 @@ object Items {
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
// Crafting
|
||||
var card: item.Card = null
|
||||
var card: item.CardBase = null
|
||||
var circuitBoardBody: item.CircuitBoard = null
|
||||
var printedCircuitBoard: item.PrintedCircuitBoard = null
|
||||
var ironCutter: item.CuttingWire = null
|
||||
var chip1, chip2, chip3: item.Chip = null
|
||||
var chip1, chip2, chip3: item.Microchip = null
|
||||
var numPad: item.NumPad = null
|
||||
var arrowKeys: item.ArrowKeys = null
|
||||
var buttonGroup: item.ButtonGroup = null
|
||||
@ -51,7 +51,7 @@ object Items {
|
||||
|
||||
var ironNugget: item.IronNugget = null
|
||||
var rawCircuitBoard: item.RawCircuitBoard = null
|
||||
var disc: item.Disc = null
|
||||
var disc: item.Disk = null
|
||||
|
||||
|
||||
def init() {
|
||||
@ -76,15 +76,15 @@ object Items {
|
||||
wlan = new item.WirelessNetworkCard(multi)
|
||||
crafting = new item.Crafting(multi)
|
||||
|
||||
card = new item.Card(multi)
|
||||
card = new item.CardBase(multi)
|
||||
circuitBoardBody = new item.CircuitBoard(multi)
|
||||
printedCircuitBoard = new item.PrintedCircuitBoard(multi)
|
||||
ironCutter = new item.CuttingWire(multi)
|
||||
|
||||
|
||||
chip1 = new item.Chip(multi, 0)
|
||||
chip2 = new item.Chip(multi, 1)
|
||||
chip3 = new item.Chip(multi, 2)
|
||||
chip1 = new item.Microchip(multi, 0)
|
||||
chip2 = new item.Microchip(multi, 1)
|
||||
chip3 = new item.Microchip(multi, 2)
|
||||
|
||||
numPad = new item.NumPad(multi)
|
||||
arrowKeys = new item.ArrowKeys(multi)
|
||||
@ -105,6 +105,6 @@ object Items {
|
||||
OreDictionary.registerOre("potionPoison", new ItemStack(Item.potion, 1, 16452))
|
||||
|
||||
rawCircuitBoard = new item.RawCircuitBoard(multi)
|
||||
disc = new item.Disc(multi)
|
||||
disc = new item.Disk(multi)
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ import net.minecraft.world.World
|
||||
import net.minecraftforge.common.ForgeDirection
|
||||
|
||||
abstract class Case(val parent: SimpleDelegator) extends Computer with SimpleDelegate {
|
||||
val unlocalizedName = "Case" + tier
|
||||
|
||||
def tier: Int
|
||||
|
||||
@ -88,24 +89,18 @@ abstract class Case(val parent: SimpleDelegator) extends Computer with SimpleDel
|
||||
object Case {
|
||||
|
||||
class Tier1(parent: SimpleDelegator) extends Case(parent) {
|
||||
val unlocalizedName = "CaseBasic"
|
||||
|
||||
def tier = 0
|
||||
|
||||
override def color = 0x7F7F7F
|
||||
}
|
||||
|
||||
class Tier2(parent: SimpleDelegator) extends Case(parent) {
|
||||
val unlocalizedName = "CaseAdvanced"
|
||||
|
||||
def tier = 1
|
||||
|
||||
override def color = 0xFFFF66
|
||||
}
|
||||
|
||||
class Tier3(parent: SimpleDelegator) extends Case(parent) {
|
||||
val unlocalizedName = "CaseProfessional"
|
||||
|
||||
def tier = 2
|
||||
|
||||
override def color = 0x66FFFF
|
||||
|
@ -14,6 +14,7 @@ import net.minecraft.world.World
|
||||
import net.minecraftforge.common.ForgeDirection
|
||||
|
||||
abstract class Screen(val parent: SimpleDelegator) extends SimpleDelegate {
|
||||
val unlocalizedName = "Screen" + tier
|
||||
|
||||
def tier: Int
|
||||
|
||||
@ -297,24 +298,18 @@ abstract class Screen(val parent: SimpleDelegator) extends SimpleDelegate {
|
||||
object Screen {
|
||||
|
||||
class Tier1(parent: SimpleDelegator) extends Screen(parent) {
|
||||
val unlocalizedName = "ScreenBasic"
|
||||
|
||||
def tier = 0
|
||||
|
||||
override def color = 0x7F7F7F
|
||||
}
|
||||
|
||||
class Tier2(parent: SimpleDelegator) extends Screen(parent) {
|
||||
val unlocalizedName = "ScreenAdvanced"
|
||||
|
||||
def tier = 1
|
||||
|
||||
override def color = 0xFFFF66
|
||||
}
|
||||
|
||||
class Tier3(parent: SimpleDelegator) extends Screen(parent) {
|
||||
val unlocalizedName = "ScreenProfessional"
|
||||
|
||||
def tier = 2
|
||||
|
||||
override def color = 0x66FFFF
|
||||
|
@ -4,7 +4,7 @@ import li.cil.oc.Settings
|
||||
import net.minecraft.client.renderer.texture.IconRegister
|
||||
|
||||
class ALU(val parent: Delegator) extends Delegate {
|
||||
val unlocalizedName = "ArithmeticLogicUnit"
|
||||
val unlocalizedName = "ALU"
|
||||
|
||||
override def registerIcons(iconRegister: IconRegister) {
|
||||
super.registerIcons(iconRegister)
|
||||
|
@ -9,6 +9,6 @@ class ArrowKeys(val parent: Delegator) extends Delegate {
|
||||
override def registerIcons(iconRegister: IconRegister) {
|
||||
super.registerIcons(iconRegister)
|
||||
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":arrow_keys")
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":keys_arrow")
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ class ButtonGroup(val parent: Delegator) extends Delegate {
|
||||
override def registerIcons(iconRegister: IconRegister) {
|
||||
super.registerIcons(iconRegister)
|
||||
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":button_group")
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":keys_group")
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ package li.cil.oc.common.item
|
||||
import li.cil.oc.Settings
|
||||
import net.minecraft.client.renderer.texture.IconRegister
|
||||
|
||||
class Card(val parent: Delegator) extends Delegate {
|
||||
val unlocalizedName = "Card"
|
||||
class CardBase(val parent: Delegator) extends Delegate {
|
||||
val unlocalizedName = "CardBase"
|
||||
|
||||
override def registerIcons(iconRegister: IconRegister) {
|
||||
super.registerIcons(iconRegister)
|
@ -18,6 +18,6 @@ class Crafting(val parent: Delegator) extends Delegate {
|
||||
override def registerIcons(iconRegister: IconRegister) = {
|
||||
super.registerIcons(iconRegister)
|
||||
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":crafting")
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":upgrade_crafting")
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,12 @@ package li.cil.oc.common.item
|
||||
import li.cil.oc.Settings
|
||||
import net.minecraft.client.renderer.texture.IconRegister
|
||||
|
||||
class Disc(val parent: Delegator) extends Delegate {
|
||||
val unlocalizedName = "Disc"
|
||||
class Disk(val parent: Delegator) extends Delegate {
|
||||
val unlocalizedName = "Disk"
|
||||
|
||||
override def registerIcons(iconRegister: IconRegister) {
|
||||
super.registerIcons(iconRegister)
|
||||
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":disc")
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":disk")
|
||||
}
|
||||
}
|
@ -22,6 +22,6 @@ class FloppyDisk(val parent: Delegator) extends Delegate {
|
||||
override def registerIcons(iconRegister: IconRegister) {
|
||||
super.registerIcons(iconRegister)
|
||||
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":disk")
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":disk_floppy")
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,6 @@ class Generator(val parent: Delegator) extends Delegate {
|
||||
override def registerIcons(iconRegister: IconRegister) = {
|
||||
super.registerIcons(iconRegister)
|
||||
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":generator")
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":upgrade_generator")
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import net.minecraft.item.ItemStack
|
||||
|
||||
class GraphicsCard(val parent: Delegator, val tier: Int) extends Delegate {
|
||||
val baseName = "GraphicsCard"
|
||||
val unlocalizedName = baseName + Array("Basic", "Advanced", "Professional").apply(tier)
|
||||
val unlocalizedName = baseName + tier
|
||||
|
||||
override def tooltipLines(stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) {
|
||||
val (w, h) = Settings.screenResolutionsByTier(tier)
|
||||
@ -27,6 +27,6 @@ class GraphicsCard(val parent: Delegator, val tier: Int) extends Delegate {
|
||||
override def registerIcons(iconRegister: IconRegister) {
|
||||
super.registerIcons(iconRegister)
|
||||
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":gpu" + tier)
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":card_graphics" + tier)
|
||||
}
|
||||
}
|
@ -44,6 +44,6 @@ class HardDiskDrive(val parent: Delegator, val tier: Int) extends Delegate {
|
||||
override def registerIcons(iconRegister: IconRegister) {
|
||||
super.registerIcons(iconRegister)
|
||||
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":hdd" + tier)
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":disk_harddrive" + tier)
|
||||
}
|
||||
}
|
@ -15,6 +15,6 @@ class Memory(val parent: Delegator, val tier: Int) extends Delegate {
|
||||
override def registerIcons(iconRegister: IconRegister) {
|
||||
super.registerIcons(iconRegister)
|
||||
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":ram" + tier)
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":memory" + tier)
|
||||
}
|
||||
}
|
||||
|
@ -3,13 +3,13 @@ package li.cil.oc.common.item
|
||||
import li.cil.oc.Settings
|
||||
import net.minecraft.client.renderer.texture.IconRegister
|
||||
|
||||
class Chip(val parent: Delegator, val tier: Int) extends Delegate {
|
||||
val baseName = "Chip"
|
||||
val unlocalizedName = baseName + Array("Basic", "Advanced", "Professional").apply(tier)
|
||||
class Microchip(val parent: Delegator, val tier: Int) extends Delegate {
|
||||
val baseName = "Microchip"
|
||||
val unlocalizedName = baseName + tier
|
||||
|
||||
override def registerIcons(iconRegister: IconRegister) = {
|
||||
super.registerIcons(iconRegister)
|
||||
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":chipset" + tier)
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":microchip" + tier)
|
||||
}
|
||||
}
|
@ -9,6 +9,6 @@ class NetworkCard(val parent: Delegator) extends Delegate {
|
||||
override def registerIcons(iconRegister: IconRegister) = {
|
||||
super.registerIcons(iconRegister)
|
||||
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":lancard")
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":card_lan")
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ class NumPad(val parent: Delegator) extends Delegate {
|
||||
override def registerIcons(iconRegister: IconRegister) {
|
||||
super.registerIcons(iconRegister)
|
||||
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":numpad")
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":keys_numpad")
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ class PrintedCircuitBoard(val parent: Delegator) extends Delegate {
|
||||
override def registerIcons(iconRegister: IconRegister) {
|
||||
super.registerIcons(iconRegister)
|
||||
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":pcb")
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":circuit_board_printed")
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ class RawCircuitBoard(val parent: Delegator) extends Delegate {
|
||||
override def registerIcons(iconRegister: IconRegister) {
|
||||
super.registerIcons(iconRegister)
|
||||
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":raw_circuit_board")
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":circuit_board_raw")
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,6 @@ class RedstoneCard(val parent: Delegator) extends Delegate {
|
||||
override def registerIcons(iconRegister: IconRegister) {
|
||||
super.registerIcons(iconRegister)
|
||||
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":rscard")
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":card_redstone")
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,6 @@ class WirelessNetworkCard(val parent: Delegator) extends Delegate {
|
||||
override def registerIcons(iconRegister: IconRegister) = {
|
||||
super.registerIcons(iconRegister)
|
||||
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":wlancard")
|
||||
icon = iconRegister.registerIcon(Settings.resourceDomain + ":card_wlan")
|
||||
}
|
||||
}
|
||||
|
@ -36,9 +36,13 @@ class WirelessNetworkCard(val owner: TileEntity) extends NetworkCard {
|
||||
|
||||
override def isWireless(context: Context, args: Arguments): Array[AnyRef] = result(true)
|
||||
|
||||
@LuaCallback(value = "isHttpEnabled", direct = true)
|
||||
def isHttpEnabled(context: Context, args: Arguments): Array[AnyRef] = result(Settings.get.httpEnabled)
|
||||
|
||||
override def send(context: Context, args: Arguments) = {
|
||||
val address = args.checkString(0)
|
||||
if (Settings.get.httpEnabled && isValidInternetRequest(address)) {
|
||||
if (isHttpRequest(address)) {
|
||||
checkAddress(address)
|
||||
val post = if (args.isString(1)) Option(args.checkString(1)) else None
|
||||
WirelessNetworkCard.threadPool.submit(new Runnable {
|
||||
def run() = try {
|
||||
@ -59,7 +63,20 @@ class WirelessNetworkCard(val owner: TileEntity) extends NetworkCard {
|
||||
http.setRequestMethod("GET")
|
||||
http.setDoOutput(false)
|
||||
}
|
||||
context.signal("http_response", address, scala.io.Source.fromInputStream(http.getInputStream).getLines().mkString("\n"))
|
||||
var part: Option[String] = None
|
||||
for (line <- scala.io.Source.fromInputStream(http.getInputStream).getLines()) {
|
||||
if ((part + line).length <= Settings.get.maxNetworkPacketSize) {
|
||||
part = Some(part.getOrElse("") + line + "\n")
|
||||
}
|
||||
else {
|
||||
context.signal("http_response", address, part.get)
|
||||
part = None
|
||||
}
|
||||
}
|
||||
context.signal("http_response", address, part.orNull)
|
||||
if (part.isDefined) {
|
||||
context.signal("http_response", address)
|
||||
}
|
||||
}
|
||||
finally {
|
||||
http.disconnect()
|
||||
@ -68,7 +85,10 @@ class WirelessNetworkCard(val owner: TileEntity) extends NetworkCard {
|
||||
}
|
||||
}
|
||||
catch {
|
||||
case e: Throwable => context.signal("http_response", address, Unit, Option(e.getMessage).getOrElse(e.toString))
|
||||
case e: FileNotFoundException =>
|
||||
context.signal("http_response", address, Unit, "not found: " + Option(e.getMessage).getOrElse(e.toString))
|
||||
case e: Throwable =>
|
||||
context.signal("http_response", address, Unit, Option(e.getMessage).getOrElse(e.toString))
|
||||
}
|
||||
})
|
||||
result(true)
|
||||
@ -111,20 +131,9 @@ class WirelessNetworkCard(val owner: TileEntity) extends NetworkCard {
|
||||
}
|
||||
}
|
||||
|
||||
private def isValidInternetRequest(address: String) = {
|
||||
private def isHttpRequest(address: String) = {
|
||||
try {
|
||||
val url = new URL(address)
|
||||
val protocol = url.getProtocol
|
||||
if (!protocol.matches("^https?$")) {
|
||||
throw new Exception()
|
||||
}
|
||||
val host = Matcher.quoteReplacement(url.getHost)
|
||||
if (Settings.get.httpHostWhitelist.length > 0 && !Settings.get.httpHostWhitelist.exists(host.matches)) {
|
||||
throw new Exception()
|
||||
}
|
||||
if (Settings.get.httpHostBlacklist.exists(host.matches)) {
|
||||
throw new Exception()
|
||||
}
|
||||
new URL(address)
|
||||
true
|
||||
}
|
||||
catch {
|
||||
@ -132,6 +141,21 @@ class WirelessNetworkCard(val owner: TileEntity) extends NetworkCard {
|
||||
}
|
||||
}
|
||||
|
||||
private def checkAddress(address: String) {
|
||||
val url = new URL(address)
|
||||
val protocol = url.getProtocol
|
||||
if (!protocol.matches("^https?$")) {
|
||||
throw new FileNotFoundException("unsupported protocol")
|
||||
}
|
||||
val host = Matcher.quoteReplacement(url.getHost)
|
||||
if (Settings.get.httpHostWhitelist.length > 0 && !Settings.get.httpHostWhitelist.exists(host.matches)) {
|
||||
throw new FileNotFoundException("domain is not whitelisted")
|
||||
}
|
||||
if (Settings.get.httpHostBlacklist.exists(host.matches)) {
|
||||
throw new FileNotFoundException("domain is blacklisted")
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def update() {
|
||||
|
@ -428,9 +428,9 @@ opencomputers {
|
||||
# All entries are regular expression patterns, but they will only be
|
||||
# applied to the host name (domain) of a given URL.
|
||||
blacklist: [
|
||||
"127\\.0\\.0\\.1"
|
||||
"10\\.\\d+\\.\\d+\\.\\d+"
|
||||
"192\\.\\d+\\.\\d+\\.\\d+"
|
||||
"^127\\.0\\.0\\.1$"
|
||||
"^10\\.\\d+\\.\\d+\\.\\d+$"
|
||||
"^192\\.\\d+\\.\\d+\\.\\d+$"
|
||||
]
|
||||
|
||||
# This is a list of whitelisted domain names. Requests may only be made to
|
||||
@ -441,8 +441,8 @@ opencomputers {
|
||||
# All entries are regular expression patterns, but they will only be
|
||||
# applied to the host name (domain) of a given URL.
|
||||
whitelist: [
|
||||
"gist\\.github\\.com"
|
||||
"pastebin\\.com"
|
||||
"^gist\\.github\\.com$"
|
||||
"^(:?www\\.)?pastebin\\.com$"
|
||||
]
|
||||
}
|
||||
|
||||
|