Added enable/disable commands for force field projector
(this includes both OC and CC)
This commit is contained in:
parent
05c2b47e1d
commit
e64b62d7dd
5 changed files with 119 additions and 6 deletions
|
@ -7,6 +7,7 @@ import cr0s.warpdrive.config.*;
|
|||
import cr0s.warpdrive.config.Dictionary;
|
||||
import cr0s.warpdrive.data.*;
|
||||
import cr0s.warpdrive.network.PacketHandler;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import li.cil.oc.api.machine.Arguments;
|
||||
|
@ -99,6 +100,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
|
|||
"state",
|
||||
"translation"
|
||||
});
|
||||
CC_scripts = Arrays.asList("enable", "disable");
|
||||
|
||||
for (EnumForceFieldUpgrade enumForceFieldUpgrade : EnumForceFieldUpgrade.values()) {
|
||||
if (enumForceFieldUpgrade.maxCountOnProjector > 0) {
|
||||
|
@ -996,13 +998,13 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
|
|||
|
||||
// OpenComputer callback methods
|
||||
@Callback
|
||||
@cpw.mods.fml.common.Optional.Method(modid = "OpenComputers")
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] state(Context context, Arguments arguments) {
|
||||
return state();
|
||||
}
|
||||
|
||||
@Callback
|
||||
@cpw.mods.fml.common.Optional.Method(modid = "OpenComputers")
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] min(Context context, Arguments arguments) {
|
||||
if (arguments.count() == 1) {
|
||||
setMin((float)arguments.checkDouble(0), (float)arguments.checkDouble(0), (float)arguments.checkDouble(0));
|
||||
|
@ -1015,7 +1017,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
|
|||
}
|
||||
|
||||
@Callback
|
||||
@cpw.mods.fml.common.Optional.Method(modid = "OpenComputers")
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] max(Context context, Arguments arguments) {
|
||||
if (arguments.count() == 1) {
|
||||
setMax((float)arguments.checkDouble(0), (float)arguments.checkDouble(0), (float)arguments.checkDouble(0));
|
||||
|
@ -1028,7 +1030,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
|
|||
}
|
||||
|
||||
@Callback
|
||||
@cpw.mods.fml.common.Optional.Method(modid = "OpenComputers")
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] rotation(Context context, Arguments arguments) {
|
||||
if (arguments.count() == 1) {
|
||||
setRotation((float)arguments.checkDouble(0), rotationPitch, rotationRoll);
|
||||
|
@ -1048,7 +1050,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
|
|||
}
|
||||
|
||||
@Callback
|
||||
@cpw.mods.fml.common.Optional.Method(modid = "OpenComputers")
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] translation(Context context, Arguments arguments) {
|
||||
if (arguments.count() == 1) {
|
||||
setTranslation((float)arguments.checkDouble(0), (float)arguments.checkDouble(0), (float)arguments.checkDouble(0));
|
||||
|
@ -1062,7 +1064,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
|
|||
|
||||
// ComputerCraft IPeripheral methods implementation
|
||||
@Override
|
||||
@cpw.mods.fml.common.Optional.Method(modid = "ComputerCraft")
|
||||
@Optional.Method(modid = "ComputerCraft")
|
||||
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) {
|
||||
String methodName = getMethodName(method);
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
if not term.isColor() then
|
||||
print("Advanced computer required")
|
||||
exit()
|
||||
end
|
||||
|
||||
Side = { "bottom", "top", "back", "left", "right" }
|
||||
for i = 1,5 do
|
||||
if peripheral.getType(Side[i]) == "warpdriveForceFieldProjector" then
|
||||
projector = peripheral.wrap(Side[i])
|
||||
break
|
||||
else
|
||||
projector = nil
|
||||
end
|
||||
end
|
||||
|
||||
if projector == nil then
|
||||
term.setBackgroundColor(colors.red)
|
||||
term.setTextColor(colors.white)
|
||||
term.write("No force field projector detected")
|
||||
else
|
||||
projector.enable(false)
|
||||
sleep(1)
|
||||
status, isEnabled, isConnected, isPowered, shape, energy = projector.state()
|
||||
term.setBackgroundColor(colors.lime)
|
||||
term.setTextColor(colors.blue)
|
||||
term.write("Projector is disabled")
|
||||
term.write(status)
|
||||
end
|
||||
term.setBackgroundColor(colors.black)
|
||||
term.setTextColor(colors.white)
|
||||
print()
|
|
@ -0,0 +1,42 @@
|
|||
if not term.isColor() then
|
||||
print("Advanced computer required")
|
||||
exit()
|
||||
end
|
||||
|
||||
Side = { "bottom", "top", "back", "left", "right" }
|
||||
for i = 1,5 do
|
||||
if peripheral.getType(Side[i]) == "warpdriveForceFieldProjector" then
|
||||
projector = peripheral.wrap(Side[i])
|
||||
break
|
||||
else
|
||||
projector = nil
|
||||
end
|
||||
end
|
||||
|
||||
if projector == nil then
|
||||
term.setBackgroundColor(colors.red)
|
||||
term.setTextColor(colors.white)
|
||||
term.write("No force field projector detected")
|
||||
else
|
||||
projector.enable(true)
|
||||
sleep(1)
|
||||
status, isEnabled, isConnected, isPowered, shape, energy = projector.state()
|
||||
if isConnected then
|
||||
if isPowered then
|
||||
term.setBackgroundColor(colors.lime)
|
||||
term.setTextColor(colors.blue)
|
||||
term.write("Projector is enabled")
|
||||
else
|
||||
term.setBackgroundColor(colors.red)
|
||||
term.setTextColor(colors.white)
|
||||
term.write("Projector is missing a shape!")
|
||||
end
|
||||
else
|
||||
term.setBackgroundColor(colors.red)
|
||||
term.setTextColor(colors.white)
|
||||
term.write("Projector is missing a beam frequency!")
|
||||
end
|
||||
end
|
||||
term.setBackgroundColor(colors.black)
|
||||
term.setTextColor(colors.white)
|
||||
print()
|
|
@ -0,0 +1,16 @@
|
|||
local component = require("component")
|
||||
local term = require("term")
|
||||
|
||||
if not component.isAvailable("warpdriveForceFieldProjector") then
|
||||
print("No force field projector detected")
|
||||
else
|
||||
local projector = component.warpdriveForceFieldProjector
|
||||
projector.enable(false)
|
||||
os.sleep(1)
|
||||
status, isEnabled, isConnected, isPowered, shape, energy = projector.state()
|
||||
print("Projector is disabled")
|
||||
print()
|
||||
print(status)
|
||||
end
|
||||
|
||||
print("")
|
|
@ -0,0 +1,22 @@
|
|||
local component = require("component")
|
||||
local term = require("term")
|
||||
|
||||
if not component.isAvailable("warpdriveForceFieldProjector") then
|
||||
print("No force field projector detected")
|
||||
else
|
||||
local projector = component.warpdriveForceFieldProjector
|
||||
projector.enable(true)
|
||||
os.sleep(1)
|
||||
status, isEnabled, isConnected, isPowered, shape, energy = projector.state()
|
||||
if isConnected then
|
||||
if isPowered then
|
||||
print("Projector is enabled")
|
||||
else
|
||||
print("Projector is missing a shape!")
|
||||
end
|
||||
else
|
||||
print("Projector is missing a beam frequency!")
|
||||
end
|
||||
end
|
||||
|
||||
print("")
|
Loading…
Add table
Reference in a new issue