当前位置: 首页>>代码示例>>Java>>正文


Java LuaException类代码示例

本文整理汇总了Java中dan200.computercraft.api.lua.LuaException的典型用法代码示例。如果您正苦于以下问题:Java LuaException类的具体用法?Java LuaException怎么用?Java LuaException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LuaException类属于dan200.computercraft.api.lua包,在下文中一共展示了LuaException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkConnected

import dan200.computercraft.api.lua.LuaException; //导入依赖的package包/类
@Override
protected boolean checkConnected() throws LuaException, InterruptedException {
	if (!super.checkConnected()) return false;

	if (!channelFuture.isDone()) return false;
	if (!channelFuture.isSuccess()) {
		throw LuaHelpers.rewriteException(channelFuture.cause(), "Cannot open socket");
	}

	if (!channelFuture.channel().isOpen()) return false;

	ChannelFuture handshakeFuture = clientListener.handshakeFuture();
	if (handshakeFuture == null || !handshakeFuture.isDone()) return false;
	if (!handshakeFuture.isSuccess()) {
		throw LuaHelpers.rewriteException(handshakeFuture.cause(), "Cannot open socket");
	}

	return true;
}
 
开发者ID:SquidDev-CC,项目名称:CCTweaks-Lua,代码行数:20,代码来源:WebSocketConnection.java

示例2: read

import dan200.computercraft.api.lua.LuaException; //导入依赖的package包/类
@Override
protected byte[] read(int count) throws LuaException, InterruptedException {
	if (checkConnected()) {
		ByteBuf stream;
		synchronized (streams) {
			stream = streams.peek();
		}
		if (stream == null) return null;

		int toRead = Math.min(count, stream.capacity() - stream.readerIndex());
		byte[] result = new byte[toRead];
		stream.readBytes(result);

		if (stream.readerIndex() >= stream.capacity()) {
			synchronized (streams) {
				streams.remove();
			}
		}
		return result;
	} else {
		return new byte[0];
	}
}
 
开发者ID:SquidDev-CC,项目名称:CCTweaks-Lua,代码行数:24,代码来源:WebSocketConnection.java

示例3: executeMainThreadTask

import dan200.computercraft.api.lua.LuaException; //导入依赖的package包/类
@Override
public final Object[] executeMainThreadTask(@Nonnull final ILuaTask task) throws LuaException, InterruptedException {
	long taskID = issueMainThreadTask(task);

	Object[] response;
	do {
		do {
			response = this.pullEvent("task_complete");
		} while (response.length < 3);
	}
	while (!(response[1] instanceof Number) || !(response[2] instanceof Boolean) || (long) ((Number) response[1]).intValue() != taskID);

	if (!(Boolean) response[2]) {
		if (response.length >= 4 && response[3] instanceof String) {
			throw new LuaException((String) response[3]);
		} else {
			throw new LuaException();
		}
	} else {
		Object[] returnValues = new Object[response.length - 3];
		System.arraycopy(response, 3, returnValues, 0, returnValues.length);
		return returnValues;
	}
}
 
开发者ID:SquidDev-CC,项目名称:CCTweaks-Lua,代码行数:25,代码来源:AbstractLuaContext.java

示例4: callMethod

import dan200.computercraft.api.lua.LuaException; //导入依赖的package包/类
@Override
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException {
	if (method == 0) {
		return new Object[]{this.energyPushedLast};
	} else if (method == 1) {
		return new Object[]{MathHelper.floor(Math.pow(10, this.energyRate))};
	} else if (method == 2) {
		return new Object[]{this.comparator};
	} else if (method == 3) {
		return new Object[]{this.energyRate};
	} else if (method == 4) {
		if (arguments[0] instanceof Double) {
			this.energyRate = MathHelper.floor((Double) arguments[0]);
			return new Object[]{true};
		} else {
			throw new LuaException("Bad argument #1 number excepted");
		}
	}
	return null;
}
 
开发者ID:tom5454,项目名称:Toms-Mod,代码行数:21,代码来源:TileEntityEnergySensor.java

示例5: callMethod

import dan200.computercraft.api.lua.LuaException; //导入依赖的package包/类
@Override
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException {
	if (method == 0) {
		return new Object[]{this.isValidHolotape()};
	} else if (method == 1) {
		if (!holotape.getStackInSlot(0).isEmpty()) {
			if (holotape.getStackInSlot(0).getTagCompound() == null)
				holotape.getStackInSlot(0).setTagCompound(new NBTTagCompound());
			if (holotape.getStackInSlot(0).getTagCompound().hasKey("w") && holotape.getStackInSlot(0).getTagCompound().getBoolean("w") && holotape.getStackInSlot(0).getTagCompound().hasKey("data") && holotape.getStackInSlot(0).getTagCompound().hasKey("name")) {
				String data = holotape.getStackInSlot(0).getTagCompound().getString("data");
				String name = holotape.getStackInSlot(0).getTagCompound().getString("name");
				return new Object[]{name, data};
			} else {
				throw new LuaException("This holotape hasn't written yet!");
			}
		} else {
			throw new LuaException("No Holotape in the machine!");
		}
	}
	return null;
}
 
开发者ID:tom5454,项目名称:Toms-Mod,代码行数:22,代码来源:TileEntityHolotapeReader.java

示例6: callMethod

import dan200.computercraft.api.lua.LuaException; //导入依赖的package包/类
@Override
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] a) throws LuaException, InterruptedException {
	if (method == 0) {
		Object[] o = new Object[methods.length];
		for (int i = 0;i < o.length;i++) {
			o[i] = methods[i];
		}
		return o;
	} else if (method == 1) {
		if (a.length > 1 && a[0] instanceof String) {
			String pName = (String) a[0];
			for (TileEntityAntennaBase ant : this.antennas) {
				ant.sendMsg(pName, a[1]);
			}
		}
	}
	return null;
}
 
开发者ID:tom5454,项目名称:Toms-Mod,代码行数:19,代码来源:TileEntityAntennaController.java

示例7: LuaEntry

import dan200.computercraft.api.lua.LuaException; //导入依赖的package包/类
public LuaEntry(String sIn) throws LuaException {
	String[] s = sIn.split(":");
	if (s.length < 4)
		throw new LuaException("Invalid Entry");
	else {
		try {
			this.x = Integer.parseInt(s[0]);
			this.y = Integer.parseInt(s[1]);
			this.width = Integer.parseInt(s[2]);
			this.height = Integer.parseInt(s[3]);
			this.name = s[4];
		} catch (Exception e) {
			// e.printStackTrace();
			// System.out.println(s[1]);
			throw new LuaException("Invalid Entry");
		}
	}
}
 
开发者ID:tom5454,项目名称:Toms-Mod,代码行数:19,代码来源:TileEntityTabletController.java

示例8: callMethod

import dan200.computercraft.api.lua.LuaException; //导入依赖的package包/类
@Override
public Object[] callMethod(IComputerAccess computer, ILuaContext context,int method, Object[] arguments) throws InterruptedException, LuaException
{
	super.callMethod(computer, context, method, arguments);
	method -= super.methodsNumber;
	switch (method)
	{
	case 0:
		return turtle.executeCommand(context, new DigCommand(2));//front
	case 1:
		return turtle.executeCommand(context, new DigCommand(0));//down
	case 2:
		return turtle.executeCommand(context, new DigCommand(1));//up
	case 3:
		return turtle.executeCommand(context, new AttackCommand(2));//front
	case 4:
		return turtle.executeCommand(context, new AttackCommand(0));//Down
	case 5:
		return turtle.executeCommand(context, new AttackCommand(1));//Up
	default:
		ChunkyPeripherals.logger.error("called unknown method ("+method+")");
	}
	return null;
}
 
开发者ID:c-rizz,项目名称:ChunkyPeripherals,代码行数:25,代码来源:MinyChunkyPeripheral.java

示例9: callMethod

import dan200.computercraft.api.lua.LuaException; //导入依赖的package包/类
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
	switch(method)
	{
		case 0:
			return new Object[] {getEnergy()};
		case 1:
			return new Object[] {operatingTicks};
		case 2:
			return new Object[] {isActive};
		case 3:
			return new Object[] {facing};
		case 4:
			return new Object[] {canOperate(getRecipe())};
		case 5:
			return new Object[] {getMaxEnergy()};
		case 6:
			return new Object[] {getMaxEnergy()-getEnergy()};
		default:
			Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID());
			return new Object[] {"Unknown command."};
	}
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:26,代码来源:TileEntityElectricMachine.java

示例10: callMethod

import dan200.computercraft.api.lua.LuaException; //导入依赖的package包/类
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
	switch(method)
	{
		case 0:
			activeNodes.clear();
			usedNodes.clear();
			finishedCalc = false;
			
			return new Object[] {"Plenisher calculation reset."};
		default:
			return new Object[] {"Unknown command."};
	}
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:17,代码来源:TileEntityFluidicPlenisher.java

示例11: callMethod

import dan200.computercraft.api.lua.LuaException; //导入依赖的package包/类
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
	switch(method)
	{
		case 0:
			return new Object[] {getEnergy()};
		case 1:
			return new Object[] {tier.output};
		case 2:
			return new Object[] {getMaxEnergy()};
		case 3:
			return new Object[] {(getMaxEnergy()-getEnergy())};
		default:
			Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID());
			return null;
	}
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:20,代码来源:TileEntityEnergyCube.java

示例12: callMethod

import dan200.computercraft.api.lua.LuaException; //导入依赖的package包/类
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
	switch(method)
	{
		case 0:
			return new Object[] {electricityStored};
		case 1:
			return new Object[] {output};
		case 2:
			return new Object[] {BASE_MAX_ENERGY};
		case 3:
			return new Object[] {(BASE_MAX_ENERGY -electricityStored)};
		case 4:
			return new Object[] {seesSun};
		default:
			Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID());
			return null;
	}
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:22,代码来源:TileEntitySolarGenerator.java

示例13: callMethod

import dan200.computercraft.api.lua.LuaException; //导入依赖的package包/类
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
	switch(method)
	{
		case 0:
			return new Object[] {getEnergy()};
		case 1:
			return new Object[] {output};
		case 2:
			return new Object[] {getMaxEnergy()};
		case 3:
			return new Object[] {getMaxEnergy()-getEnergy()};
		case 4:
			return new Object[] {fuelTank.getStored()};
		case 5:
			return new Object[] {fuelTank.getNeeded()};
		default:
			Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID());
			return null;
	}
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:24,代码来源:TileEntityGasGenerator.java

示例14: callMethod

import dan200.computercraft.api.lua.LuaException; //导入依赖的package包/类
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
	switch(method)
	{
		case 0:
			return new Object[] {electricityStored};
		case 1:
			return new Object[] {output};
		case 2:
			return new Object[] {BASE_MAX_ENERGY};
		case 3:
			return new Object[] {(BASE_MAX_ENERGY -electricityStored)};
		case 4:
			return new Object[] {bioFuelSlot.fluidStored};
		case 5:
			return new Object[] {bioFuelSlot.MAX_FLUID-bioFuelSlot.fluidStored};
		default:
			Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID());
			return null;
	}
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:24,代码来源:TileEntityBioGenerator.java

示例15: callMethod

import dan200.computercraft.api.lua.LuaException; //导入依赖的package包/类
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
	switch(method)
	{
		case 0:
			return new Object[] {electricityStored};
		case 1:
			return new Object[] {output};
		case 2:
			return new Object[] {BASE_MAX_ENERGY};
		case 3:
			return new Object[] {(BASE_MAX_ENERGY -electricityStored)};
		case 4:
			return new Object[] {lavaTank.getFluid() != null ? lavaTank.getFluid().amount : 0};
		case 5:
			return new Object[] {lavaTank.getCapacity()-(lavaTank.getFluid() != null ? lavaTank.getFluid().amount : 0)};
		default:
			Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID());
			return null;
	}
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:24,代码来源:TileEntityHeatGenerator.java


注:本文中的dan200.computercraft.api.lua.LuaException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。