use of li.cil.oc.api.machine.Callback in project OpenModularTurrets by OpenModularTurretsTeam.
the class TurretBase method addTrustedPlayer.
@Optional.Method(modid = omtteam.omlib.compatability.ModCompatibility.OCModID)
@Callback(doc = "function(name:String, [canOpenGUI:boolean , canChangeTargeting:boolean , " + "admin:boolean]):string; adds Trusted player to Trustlist.")
public Object[] addTrustedPlayer(Context context, Arguments args) {
if (!computerAccessible) {
return new Object[] { "Computer access deactivated!" };
}
if (!this.addTrustedPlayer(args.checkString(0))) {
return new Object[] { "Name not valid!" };
}
TrustedPlayer trustedPlayer = this.getTrustedPlayer(args.checkString(0));
trustedPlayer.canOpenGUI = args.optBoolean(1, false);
trustedPlayer.canChangeTargeting = args.optBoolean(1, false);
trustedPlayer.admin = args.optBoolean(1, false);
trustedPlayer.uuid = getPlayerUUID(args.checkString(0));
return null;
}
use of li.cil.oc.api.machine.Callback in project Charset by CharsetMC.
the class TraitRecordPlayerOC method seek.
@Callback(doc = "function(duration:number):number -- Seeks the specified amount of seconds on the record. " + "Negative values for rewinding. Returns the number of seconds sought.")
public Object[] seek(Context context, Arguments args) {
if (hasReadyStorage()) {
int seekAmount = (int) Math.round(args.checkDouble(0) * getBytesPerSecond());
if (seekAmount == 0) {
return new Object[] { 0.0 };
} else {
IDataStorage storage = getStorage();
int oldPos = storage.getPosition();
int newPos = oldPos + seekAmount;
if (newPos < 0)
newPos = 0;
else if (newPos > storage.getSize())
newPos = storage.getSize();
storage.setPosition(newPos);
return new Object[] { (double) (newPos - oldPos) / getBytesPerSecond() };
}
} else {
return new Object[] { 0.0 };
}
}
use of li.cil.oc.api.machine.Callback in project RFTools by McJty.
the class ScreenControllerTileEntity method getTags.
@Callback(doc = "Get a table of all tags supported by all connected screens", getter = true)
@Optional.Method(modid = "opencomputers")
public Object[] getTags(Context context, Arguments args) {
List<String> tags = new ArrayList<>();
for (BlockPos screen : connectedScreens) {
TileEntity te = getWorld().getTileEntity(screen);
if (te instanceof ScreenTileEntity) {
ScreenTileEntity screenTileEntity = (ScreenTileEntity) te;
tags.addAll(screenTileEntity.getTags());
}
}
return new Object[] { tags };
}
use of li.cil.oc.api.machine.Callback in project RFTools by McJty.
the class ScreenControllerTileEntity method getScreens.
@Callback(doc = "Get a table with coordinates (every coordinate is a table indexed with 'x', 'y', and 'z') for all connected screens", getter = true)
@Optional.Method(modid = "opencomputers")
public Object[] getScreens(Context context, Arguments args) {
List<Map<String, Integer>> result = new ArrayList<>();
for (BlockPos screen : connectedScreens) {
Map<String, Integer> coordinate = new HashMap<>();
coordinate.put("x", screen.getX());
coordinate.put("y", screen.getY());
coordinate.put("z", screen.getZ());
result.add(coordinate);
}
return new Object[] { result };
}
use of li.cil.oc.api.machine.Callback in project RFTools by McJty.
the class ScreenControllerTileEntity method getScreenIndex.
@Callback(doc = "Given a screen coordinate (table indexed by 'x', 'y', and 'z') return the index of that screen", getter = true)
@Optional.Method(modid = "opencomputers")
public Object[] getScreenIndex(Context context, Arguments args) throws Exception {
Map screen = args.checkTable(0);
if (!screen.containsKey("x") || !screen.containsKey("y") || !screen.containsKey("z")) {
throw new IllegalArgumentException("Screen map doesn't contain the right x,y,z coordinate!");
}
BlockPos recC = new BlockPos(((Double) screen.get("x")).intValue(), ((Double) screen.get("y")).intValue(), ((Double) screen.get("z")).intValue());
return getScreenIndex(recC);
}
Aggregations