Skip to content

Commit

Permalink
Merge branch 'master-MC1.7.10' of github.com:MightyPirates/OpenComput…
Browse files Browse the repository at this point in the history
…ers into OC1.6-MC1.7.10
  • Loading branch information
fnuecke committed Jun 6, 2016
2 parents 027ea3e + 2874f47 commit 61ad3b4
Show file tree
Hide file tree
Showing 384 changed files with 2,223 additions and 698 deletions.
21 changes: 20 additions & 1 deletion src/main/java/li/cil/oc/api/IMC.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,17 @@ public static void registerAssemblerTemplate(String name, String select, String
* Signature of callbacks must be:
* <pre>
* boolean select(ItemStack stack)
* ItemStack[] disassemble(ItemStack stack, ItemStack[] ingredients)
* Object disassemble(ItemStack stack, ItemStack[] ingredients)
* </pre>
* <p/>
* Where the <code>Object</code> returned from the <code>disassemble</code>
* method must be one of the following:
* <ul>
* <li><code>ItemStack[]</code>: list of resulting items, subject to random failure.</li>
* <li><code>Object[]{ItemStack[],ItemStack[]}</code>: two lists of resulting items, the first being subject to
* random failure, the second being guaranteed drops (e.g. for item inventory contents).</li>
* </ul>
* <p/>
* Callbacks must be declared as <tt>packagePath.className.methodName</tt>.
* For example: <tt>com.example.Integration.callbackMethod</tt>.
*
Expand Down Expand Up @@ -353,6 +361,17 @@ public static void blacklistHost(String name, Class host, ItemStack stack) {
FMLInterModComms.sendMessage(MOD_ID, "blacklistHost", nbt);
}

/**
* Notifies OpenComputers that there is some 3rd-party power system present
* that adds integration on its side.
* <p/>
* This will suppress the "no power system found" message on start up, and
* avoid auto-disabling power use.
*/
public static void registerCustomPowerSystem() {
FMLInterModComms.sendMessage(MOD_ID, "registerCustomPowerSystem", "true");
}

// ----------------------------------------------------------------------- //

private static final String MOD_ID = "OpenComputers";
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/li/cil/oc/api/component/RackMountable.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;

/**
* Use this interface on environments provided by drivers for items that can
Expand Down Expand Up @@ -63,11 +62,9 @@ public interface RackMountable extends ManagedEnvironment, StateAware {
* pointlessly compressed fashion (because MC is a dummy like that).
*
* @param player the player activating the mountable.
* @param side the side (in global coordinate space) of the rack that was activated.
* @param hitX the relative x coordinate of the activation.
* @param hitY the relative y coordinate of the activation.
* @param hitZ the relative z coordinate of the activation.
* @param hitX the relative x coordinate of the activation on the mountable.
* @param hitY the relative y coordinate of the activation on the mountable.
* @return whether the activation was handled (e.g. GUI opened).
*/
boolean onActivate(EntityPlayer player, ForgeDirection side, float hitX, float hitY, float hitZ);
boolean onActivate(EntityPlayer player, float hitX, float hitY);
}
106 changes: 106 additions & 0 deletions src/main/java/li/cil/oc/api/driver/DeviceInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package li.cil.oc.api.driver;

import java.util.Map;

/**
* Implement this on {@link li.cil.oc.api.network.Environment}s if you wish to
* expose some (typically static) information about the device represented by
* that environment to a {@link li.cil.oc.api.Machine} connected to it.
* <p/>
* You may also implement this on a {@link li.cil.oc.api.machine.MachineHost}
* in which case the <code>Machine</code> will forward that information as
* its own (since <code>MachineHost</code>s usually use the machine's node as
* their own, this avoids a dummy environment used solely for device info).
* <p/>
* This is intended to permit programs to reflect on the hardware they are
* running on, typically for purely informational purposes, but possibly to
* toggle certain hardware specific features.
* <p/>
* For example, graphics cards may expose their timings via this interface, so
* that programs may determine at what speed they can redraw, and optimize
* execution order.
* <p/>
* While the format of the returned table of information is entirely up to you,
* it is recommended to orient yourself on the key values and names that
* <code>lshw</code> uses (http://www.ezix.org/project/wiki/HardwareLiSter),
* where applicable.
*/
public interface DeviceInfo {
/**
* Compile a list of device information strings as key-value pairs.
* <p/>
* For example, this may list the type of the device, a vendor (for example
* your mod name, or something more creative if you like), specifications
* of the device (speeds, capacities).
* <p/>
* For example, OC's tier one memory module returns the following:
* <table>
* <tr><td>class</td><td>memory</td></tr>
* <tr><td>description</td><td>Memory bank</td></tr>
* <tr><td>vendor</td><td>MightyPirates GmbH & Co. KG</td></tr>
* <tr><td>product</td><td>Multipurpose RAM Type</td></tr>
* <tr><td>clock</td><td>500</td></tr>
* </table>
*
* @return the table of information on this device, or <code>null</code>.
*/
Map<String, String> getDeviceInfo();

/**
* Recommended list of key values for the device info table.
* <p/>
* You are strongly encouraged to at least define <code>class</code>, <code>description</code>,
* <code>vendor</code> and <code>product</code>, to allow a more homogenous experience for the
* end-user reading this information via a script.
* <p/>
* Feel free to be somewhat... flexible with the designated uses of these fields. For example,
* the capacity and size fields have differing meaning depending on the device in OpenComputers
* itself (e.g. they're used for maximum number of characters for graphics cards, width is
* used for bit depth on graphics cards, etc.), just try to stick with what's somewhat logical.
*/
final class DeviceAttribute {
public static final String Class = "class"; // device's class (see below), e.g. "processor"
public static final String Description = "description"; // human-readable description of the hardware node, e.g. "Ethernet interface"
public static final String Vendor = "vendor"; // vendor/manufacturer of the device, e.g. "Minecorp Inc."
public static final String Product = "product"; // product name of the device, e.g. "ATY Raderps 4200X"
public static final String Version = "version"; // version/release of the device, e.g. "2.1.0"
public static final String Serial = "serial"; // serial number of the device
public static final String Capacity = "capacity"; // maximum capacity reported by the device, e.g. unformatted size of a disk
public static final String Size = "size"; // actual size of the device, e.g. actual usable space on a disk
public static final String Clock = "clock"; // bus clock (in Hz) of the device, e.g. call speed(s) of a component
public static final String Width = "width"; // address width of the device, in the broadest sense

private DeviceAttribute() {
}
}

/**
* Recommended list of values for the <code>class</code> attribute (see above).
* <p/>
* Again, feel free to be somewhat creative with those. When in doubt, use <code>generic</code>.
*/
final class DeviceClass {
public static final String System = "system"; // used to refer to the whole machine, e.g. "Computer", "Server", "Robot"
public static final String Bridge = "bridge"; // internal bus converter, maybe useful for some low-level archs?
public static final String Memory = "memory"; // memory bank that can contain data, executable code, e.g. RAM, EEPROM
public static final String Processor = "processor"; // execution processor, e.g. CPU, cryptography support
public static final String Address = "address"; // memory address range, e.g. video memory (again, low-level archs maybe?)
public static final String Storage = "storage"; // storage controller, e.g. IDE controller (low-level...)
public static final String Disk = "disk"; // random-access storage device, e.g. floppies
public static final String Tape = "tape"; // sequential-access storage device, e.g. cassette tapes
public static final String Bus = "bus"; // device-connecting bus, e.g. USB
public static final String Network = "network"; // network interface, e.g. ethernet, wlan
public static final String Display = "display"; // display adapter, e.g. graphics cards
public static final String Input = "input"; // user input device, e.g. keyboard, mouse
public static final String Printer = "printer"; // printing device, e.g. printer, 3D-printer
public static final String Multimedia = "multimedia"; // audio/video device, e.g. sound cards
public static final String Communication = "communication"; // line communication device, e.g. modem, serial ports
public static final String Power = "power"; // energy source, e.g. battery, power supply
public static final String Volume = "volume"; // disk volume, e.g. file system
public static final String Generic = "generic"; // generic device (used when no other class is suitable)

private DeviceClass() {
}
}

}
3 changes: 3 additions & 0 deletions src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,9 @@ opencomputers {
# is decided in an extra roll of the dice.
lootProbability: 5

# Whether to allow loot disk cycling by crafting them with a wrench.
lootRecrafting: true

# The range, in blocks, in which the Geolyzer can scan blocks. Note that
# it uses the maximum-distance, not the euclidean one, i.e. it can scan
# in a cube surrounding it with twice this value as its edge length.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Nanomachines react to a simple, proprietary protocol: each packet must consist o
- `getInput(index:number)` - Request the current state of the input with the specified index.
- `setInput(index:number, value:boolean)` - Set the state of the input with the specified index to the specified value.
- `getActiveEffects()` - Request a list of active effects. Note that some effects may not show up in this list.
- `saveConfiguration()` - Requires a set of nanomachines in the players inventory, will store the current configuration to it.

For example, in OpenOS:
- `component.modem.broadcast(1, "nanomachines", "setInput", 1, true)` will enable the first input.
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/opencomputers/loot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ To add a disk, create a folder and put the files the disk should contain into th

You are invited to submit your own programs as pull requests! The more the merrier :-)

For example, say you have a program named "chat.lua". You'd create a folder, say `NetChat` or whatever the program likes to call itself, and put the `chat.lua` file into that folder. You then add the line `NetChat=chat` to the `loot.properties` file. And that's it. Make a pull request and your program is in OpenComputers - unless it fails the arbitrary quality check, of course. Feel free to submit pull requests for fixes to your submitted programs (or of others) at any time!
For example, say you have a program named "chat.lua". You'd create a folder, say `netchat` or whatever the program likes to call itself, and put the `chat.lua` file into that folder. You then add the line `netchat=NetChat` to the `loot.properties` file. And that's it. Make a pull request and your program is in OpenComputers - unless it fails the arbitrary quality check, of course. Feel free to submit pull requests for fixes to your submitted programs (or of others) at any time!
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
local shell = require("shell")
local data = require("data")

local args = shell.parse(...)
if #args == 0 then
local read = ""
repeat
local current = io.read("*a")
read = read .. current
until current ~= ""
io.write(data.toHex(data.md5(read)))
else
for i = 1, #args do
local read = ""
local file, reason = io.open(shell.resolve(args[i]))
if not file then
io.stderr:write(tostring(reason) .. "\n")
os.exit(false)
end
repeat
local current = file:read("*a")
read = read .. current
until current ~= ""
file:close()
io.write(data.toHex(data.md5(read)) .. "\t".. args[i] .. "\n")
end
end
local shell = require("shell")
local data = require("data")

local args = shell.parse(...)
if #args == 0 then
local read = ""
repeat
local current = io.read("*a")
read = read .. current
until current ~= ""
io.write(data.toHex(data.md5(read)))
else
for i = 1, #args do
local read = ""
local file, reason = io.open(shell.resolve(args[i]))
if not file then
io.stderr:write(tostring(reason) .. "\n")
os.exit(false)
end
repeat
local current = file:read("*a")
read = read .. current
until current ~= ""
file:close()
io.write(data.toHex(data.md5(read)) .. "\t".. args[i] .. "\n")
end
end
30 changes: 18 additions & 12 deletions src/main/resources/assets/opencomputers/loot/loot.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@
# weight 2 is two times as likely to be generated than an item with
# weight 1. Weight 0 means it will not spawn at all.
#The color defaults to gray. It must be a dye's ore-dict name.
Builder=build:1:dyeYellow
MazeGen=maze:1:dyeOrange
Network=network:1:dyeLime
Plan9k=plan9k:1:dyeRed
OpenIRC=irc:1:dyeLightBlue
OpenLoader=openloader:1:dyeMagenta
OpenOS=openOS:0:dyeGreen
OPPM=oppm:0:dyeCyan
# Higher chance to find the dig program, because it has the most immediate
# use - OpenOS is craftable and IRC can be downloaded once an internet card
# is available - which one needs anyway, to use the program...
TheDig=dig:2:dyeBrown

# General purpose.
network=Network (Network Stack):1:dyeLime
plan9k=Plan9k (Operating System):1:dyeRed
irc=OpenIRC (IRC Client):1:dyeLightBlue
openloader=OpenLoader (Boot Loader):1:dyeMagenta
openos=OpenOS (Operating System):0:dyeGreen
oppm=OPPM (Package Manager):0:dyeCyan

# Robot utilities.
builder=Builder:1:dyeYellow
dig=Digger:2:dyeBrown
maze=Mazer:1:dyeOrange

# Drivers for components.
data=Data Card Software:0:dyePink
generator=Generator Upgrade Software:0:dyePurple
internet=Internet Card Software:0:dyeBlue
42 changes: 42 additions & 0 deletions src/main/resources/assets/opencomputers/loot/openos/bin/lshw.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
local computer = require("computer")
local shell = require("shell")
local text = require("text")

local args, options = shell.parse(...)

local devices = computer.getDeviceInfo()
local columns = {}

if not next(options, nil) then
options.t = true
options.d = true
options.p = true
end
if options.t then table.insert(columns, "Class") end
if options.d then table.insert(columns, "Description") end
if options.p then table.insert(columns, "Product") end
if options.v then table.insert(columns, "Vendor") end
if options.c then table.insert(columns, "Capacity") end
if options.w then table.insert(columns, "Width") end
if options.s then table.insert(columns, "Clock") end

local m = {}
for address, info in pairs(devices) do
for col, name in ipairs(columns) do
m[col] = math.max(m[col] or 1, (info[name:lower()] or ""):len())
end
end

io.write(text.padRight("Address", 10))
for col, name in ipairs(columns) do
io.write(text.padRight(name, m[col] + 2))
end
io.write("\n")

for address, info in pairs(devices) do
io.write(text.padRight(address:sub(1, 5).."...", 10))
for col, name in ipairs(columns) do
io.write(text.padRight(info[name:lower()] or "", m[col] + 2))
end
io.write("\n")
end
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ if #args == 0 or options.i then
end
end
local function hint(line, index)
line = (line or ""):sub(1, index - 1)
line = (line or "")
local tail = line:sub(index)
line = line:sub(1, index - 1)
local path = string.match(line, "[a-zA-Z_][a-zA-Z0-9_.]*$")
if not path then return nil end
local suffix = string.match(path, "[^.]+$") or ""
Expand All @@ -95,18 +97,19 @@ if #args == 0 or options.i then
local r1, r2 = {}, {}
findKeys(t, r1, string.sub(line, 1, #line - #suffix), suffix)
for k in pairs(r1) do
table.insert(r2, k)
table.insert(r2, k .. tail)
end
table.sort(r2)
if #r2 == 1 then
setmetatable(r2, {
__index=function(tbl, key)
if key==2 then
local prev=tbl[1]
tbl[1]=nil
local next = hint(prev,#prev+1)
for i,v in ipairs(next) do
tbl[i] = v
if next then
for i,v in ipairs(next) do
tbl[i] = v
end
end
setmetatable(tbl,getmetatable(next))
return tbl[1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,19 @@ function stdoutStream:write(str)
end

function stderrStream:write(str)
local component = require("component")
if component.isAvailable("gpu") and component.gpu.getDepth() and component.gpu.getDepth() > 1 then
local foreground = component.gpu.setForeground(0xFF0000)
term.write(str, true)
component.gpu.setForeground(foreground)
else
term.write(str, true)
local gpu = term.gpu()
local set_depth = gpu and gpu.getDepth() and gpu.getDepth() > 1

if set_depth then
set_depth = gpu.setForeground(0xFF0000)
end

term.drawText(str, true)

if set_depth then
gpu.setForeground(set_depth)
end

return self
end

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require("filesystem").mount(
setmetatable({
isReadOnly = function()return false end
},
{
__index=function(tbl,key)return require("devfs")[key]end
}), "/dev")
Loading

0 comments on commit 61ad3b4

Please sign in to comment.