fixed scarpet error msgs

This commit is contained in:
gnembon committed 2019-10-19 22:17:41 -03:00
1 parent 88d2ad75ad
commit 0226965ba0
13 files changed
+105 -106

No files matched your search

@@ -171,7 +171,7 @@ public class CarpetExpression
CarpetContext cc = (CarpetContext) c;
if (params.size() == 0)
{
throw new InternalExpressionException(name + " requires at least one parameter");
throw new InternalExpressionException("'" + name + "' requires at least one parameter");
}
Value v0 = params.get(0).evalValue(c);
if (v0 instanceof BlockValue)
@@ -194,7 +194,7 @@ public class CarpetExpression
CarpetContext cc = (CarpetContext) c;
if (params.size() == 0)
{
throw new InternalExpressionException(name + " requires at least one parameter");
throw new InternalExpressionException("'" + name + "' requires at least one parameter");
}
Value v0 = params.get(0).evalValue(c);
@@ -218,7 +218,7 @@ public class CarpetExpression
CarpetContext cc = (CarpetContext) c;
if (params.size() == 0)
{
throw new InternalExpressionException(name + " requires at least one parameter");
throw new InternalExpressionException("'" + name + "' requires at least one parameter");
}
Value v0 = params.get(0).evalValue(c);
if (v0 instanceof BlockValue)
@@ -230,7 +230,7 @@ public class CarpetExpression
}
catch (NullPointerException ignored)
{
throw new InternalExpressionException(name + " function requires a block that is positioned in the world");
throw new InternalExpressionException("'" + name + "' function requires a block that is positioned in the world");
}
}
BlockValue block = BlockValue.fromParams(cc, params, 0).block;
@@ -691,7 +691,7 @@ public class CarpetExpression
}
else
{
throw new InternalExpressionException("pos works only with a block or an entity type");
throw new InternalExpressionException("'pos' works only with a block or an entity type");
}
});
@@ -700,7 +700,7 @@ public class CarpetExpression
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext)c, lv, 0);
BlockPos pos = locator.block.getPos();
if (lv.size() <= locator.offset)
throw new InternalExpressionException("block_offset needs at least position, and direction");
throw new InternalExpressionException("'pos_offset' needs at least position, and direction");
String directionString = lv.get(locator.offset).evalValue(c).getString();
Direction dir = Direction.byName(directionString);
if (dir == null)
@@ -831,7 +831,7 @@ public class CarpetExpression
CarpetContext cc = (CarpetContext)c;
ServerWorld world = cc.s.getWorld();
if (lv.size() < 2 || lv.size() % 2 == 1)
throw new InternalExpressionException("set block should have at least 2 params and odd attributes");
throw new InternalExpressionException("'set' should have at least 2 params and odd attributes");
BlockValue.LocatorResult targetLocator = BlockValue.fromParams(cc, lv, 0);
BlockValue.LocatorResult sourceLocator = BlockValue.fromParams(cc, lv, targetLocator.offset, true);
BlockState sourceBlockState = sourceLocator.block.getBlockState();
@@ -844,7 +844,7 @@ public class CarpetExpression
String paramString = lv.get(i).evalValue(c).getString();
Property<?> property = states.getProperty(paramString);
if (property == null)
throw new InternalExpressionException("property " + paramString + " doesn't apply to " + sourceLocator.block.getString());
throw new InternalExpressionException("Property " + paramString + " doesn't apply to " + sourceLocator.block.getString());
String paramValue = lv.get(i + 1).evalValue(c).getString();
sourceBlockState = setProperty(property, paramString, paramValue, sourceBlockState);
}
@@ -919,7 +919,7 @@ public class CarpetExpression
this.expr.addLazyFunction("harvest", -1, (c, t, lv) ->
{
if (lv.size()<2)
throw new InternalExpressionException("harvest takes at least 2 parameters: entity and block, or position, to harvest");
throw new InternalExpressionException("'harvest' takes at least 2 parameters: entity and block, or position, to harvest");
CarpetContext cc = (CarpetContext)c;
World world = cc.s.getWorld();
Value entityValue = lv.get(0).evalValue(cc);
@@ -944,7 +944,7 @@ public class CarpetExpression
this.expr.addLazyFunction("place_item", -1, (c, t, lv) ->
{
if (lv.size()<2)
throw new InternalExpressionException("place_item takes at least 2 parameters: item and block, or position, to place onto");
throw new InternalExpressionException("'place_item' takes at least 2 parameters: item and block, or position, to place onto");
CarpetContext cc = (CarpetContext) c;
String itemString = lv.get(0).evalValue(c).getString();
BlockValue.VectorLocator locator = BlockValue.locateVec(cc, lv, 1);
@@ -1008,7 +1008,7 @@ public class CarpetExpression
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext) c, lv, 0);
BlockState state = locator.block.getBlockState();
if (lv.size() <= locator.offset)
throw new InternalExpressionException("property requires to specify a property to query");
throw new InternalExpressionException("'property' requires to specify a property to query");
String tag = lv.get(locator.offset).evalValue(c).getString();
StateFactory<Block, BlockState> states = state.getBlock().getStateFactory();
Property<?> property = states.getProperty(tag);
@@ -1043,7 +1043,7 @@ public class CarpetExpression
CarpetContext cc = (CarpetContext)c;
BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0);
if (lv.size() == locator.offset)
throw new InternalExpressionException("set_biome needs a biome name as an argument");
throw new InternalExpressionException("'set_biome' needs a biome name as an argument");
String biomeName = lv.get(locator.offset+0).evalValue(c).getString();
Biome biome = Registry.BIOME.get(new Identifier(biomeName));
if (biome == null)
@@ -1223,7 +1223,7 @@ public class CarpetExpression
if (inventoryLocator == null)
return (_c, _t) -> Value.NULL;
if (lv.size() < inventoryLocator.offset+2)
throw new InternalExpressionException("inventory_set requires at least slot number and new stack size, and optional new item");
throw new InternalExpressionException("'inventory_set' requires at least slot number and new stack size, and optional new item");
int slot = (int) NumericValue.asNumber(lv.get(inventoryLocator.offset+0).evalValue(c)).getLong();
slot = NBTSerializableValue.validateSlot(slot, inventoryLocator.inventory);
if (slot == inventoryLocator.inventory.getInvSize())
@@ -1317,7 +1317,7 @@ public class CarpetExpression
if (inventoryLocator == null)
return (_c, _t) -> Value.NULL;
if (lv.size() <= inventoryLocator.offset)
throw new InternalExpressionException("inventory_remove requires at least an item to be removed");
throw new InternalExpressionException("'inventory_remove' requires at least an item to be removed");
ItemStackArgument searchItem = NBTSerializableValue.parseItem(lv.get(inventoryLocator.offset).evalValue(c).getString());
int amount = 1;
if (lv.size() > inventoryLocator.offset+1)
@@ -1365,7 +1365,7 @@ public class CarpetExpression
if (inventoryLocator == null)
return (_c, _t) -> Value.NULL;
if (lv.size() == inventoryLocator.offset)
throw new InternalExpressionException("slot number is required for inventory_drop");
throw new InternalExpressionException("Slot number is required for inventory_drop");
int slot = (int)NumericValue.asNumber(lv.get(inventoryLocator.offset).evalValue(c)).getLong();
slot = NBTSerializableValue.validateSlot(slot, inventoryLocator.inventory);
if (slot == inventoryLocator.inventory.getInvSize())
@@ -1780,7 +1780,7 @@ public class CarpetExpression
this.expr.addLazyFunction("spawn", -1, (c, t, lv) -> {
CarpetContext cc = (CarpetContext)c;
if (lv.size() < 2)
throw new InternalExpressionException("spawn function takes mob name, and position to spawn");
throw new InternalExpressionException("'spawn' function takes mob name, and position to spawn");
String entityString = lv.get(0).evalValue(c).getString();
Identifier entityId;
try
@@ -1901,11 +1901,11 @@ public class CarpetExpression
this.expr.addLazyFunction("query", -1, (c, t, lv) -> {
if (lv.size()<2)
{
throw new InternalExpressionException("query_entity takes entity as a first argument, and queried feature as a second");
throw new InternalExpressionException("'query' takes entity as a first argument, and queried feature as a second");
}
Value v = lv.get(0).evalValue(c);
if (!(v instanceof EntityValue))
throw new InternalExpressionException("First argument to query_entity should be an entity");
throw new InternalExpressionException("First argument to query should be an entity");
String what = lv.get(1).evalValue(c).getString();
Value retval;
if (lv.size()==2)
@@ -1921,11 +1921,11 @@ public class CarpetExpression
this.expr.addLazyFunction("modify", -1, (c, t, lv) -> {
if (lv.size()<2)
{
throw new InternalExpressionException("modify_entity takes entity as a first argument, and queried feature as a second");
throw new InternalExpressionException("'modify' takes entity as a first argument, and queried feature as a second");
}
Value v = lv.get(0).evalValue(c);
if (!(v instanceof EntityValue))
throw new InternalExpressionException("First argument to get should be an entity");
throw new InternalExpressionException("First argument to modify should be an entity");
String what = lv.get(1).evalValue(c).getString();
if (lv.size()==2)
((EntityValue) v).set(what, null);
@@ -1940,10 +1940,10 @@ public class CarpetExpression
this.expr.addLazyFunction("entity_event", -1, (c, t, lv) ->
{
if (lv.size()<3)
throw new InternalExpressionException("entity_event requires at least 3 arguments, entity, event to be handled, and function name, with optional arguments");
throw new InternalExpressionException("'entity_event' requires at least 3 arguments, entity, event to be handled, and function name, with optional arguments");
Value v = lv.get(0).evalValue(c);
if (!(v instanceof EntityValue))
throw new InternalExpressionException("First argument to get should be an entity");
throw new InternalExpressionException("First argument to entity_event should be an entity");
String what = lv.get(1).evalValue(c).getString();
Value functionValue = lv.get(2).evalValue(c);
String function = null;
@@ -2000,7 +2000,7 @@ public class CarpetExpression
{
int lvsise = lv.size();
if (lvsise != 7 && lvsise != 10)
throw new InternalExpressionException("scan takes 2, or 3 triples of coords, and the expression");
throw new InternalExpressionException("'scan' takes 2, or 3 triples of coords, and the expression");
int cx = (int) NumericValue.asNumber(lv.get(0).evalValue(c)).getLong();
int cy = (int) NumericValue.asNumber(lv.get(1).evalValue(c)).getLong();
int cz = (int) NumericValue.asNumber(lv.get(2).evalValue(c)).getLong();
@@ -2133,7 +2133,7 @@ public class CarpetExpression
{
if (lv.size() != 3 && lv.size() != 6 && lv.size() != 9)
{
throw new InternalExpressionException("rectangular region should be specified with 3, 6, or 9 coordinates");
throw new InternalExpressionException("Rectangular region should be specified with 3, 6, or 9 coordinates");
}
int cx;
int cy;
@@ -2251,7 +2251,7 @@ public class CarpetExpression
CarpetContext cc = (CarpetContext)c;
if (lv.size() != 3 && lv.size() != 4 && lv.size() != 5)
{
throw new InternalExpressionException("diamond region should be specified with 3 to 5 coordinates");
throw new InternalExpressionException("'diamond' region should be specified with 3 to 5 coordinates");
}
int cx;
@@ -2726,7 +2726,7 @@ public class CarpetExpression
}
catch (IndexOutOfBoundsException e)
{
throw new InternalExpressionException("create_marker requires a name and three coordinates, with optional direction, and optional block on its head");
throw new InternalExpressionException("'create_marker' requires a name and three coordinates, with optional direction, and optional block on its head");
}
ArmorStandEntity armorstand = new ArmorStandEntity(EntityType.ARMOR_STAND, cc.s.getWorld());
@@ -2872,7 +2872,7 @@ public class CarpetExpression
}
else
{
throw new InternalExpressionException("in_dimension accepts only world-localized block arguments");
throw new InternalExpressionException("'in_dimension' accepts only world-localized block arguments");
}
}
else
@@ -2905,7 +2905,7 @@ public class CarpetExpression
this.expr.addLazyFunction("plop", 4, (c, t, lv) ->{
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext)c, lv, 0);
if (lv.size() <= locator.offset)
throw new InternalExpressionException("plop needs extra argument indicating what to plop");
throw new InternalExpressionException("'plop' needs extra argument indicating what to plop");
String what = lv.get(locator.offset).evalValue(c).getString();
Boolean res = FeatureGenerator.spawn(what, ((CarpetContext)c).s.getWorld(), locator.block.getPos());
if (res == null)
@@ -2917,12 +2917,12 @@ public class CarpetExpression
this.expr.addLazyFunction("schedule", -1, (c, t, lv) -> {
if (lv.size()<2)
throw new InternalExpressionException("schedule should have at least 2 arguments, delay and call name");
throw new InternalExpressionException("'schedule' should have at least 2 arguments, delay and call name");
Long delay = NumericValue.asNumber(lv.get(0).evalValue(c)).getLong();
String funname = lv.get(1).evalValue(c).getString();
CarpetContext cc = (CarpetContext)c;
if (!cc.host.globalFunctions.containsKey(funname))
throw new InternalExpressionException("function "+funname+" is not defined");
throw new InternalExpressionException("Function "+funname+" is not defined");
List<LazyValue> args = new ArrayList<>();
for (int i=2; i < lv.size(); i++)
{
@@ -2930,7 +2930,7 @@ public class CarpetExpression
args.add( (_c, _t) -> arg);
}
if (cc.host.globalFunctions.get(funname).getArguments().size() != args.size())
throw new InternalExpressionException("function "+funname+" takes "+
throw new InternalExpressionException("Function "+funname+" takes "+
cc.host.globalFunctions.get(funname).getArguments().size()+" arguments, "+args.size()+" provided.");
CarpetServer.scriptServer.events.scheduleCall(cc, funname, args, delay);
return (c_, t_) -> Value.TRUE;
@@ -2958,7 +2958,7 @@ public class CarpetExpression
this.expr.addLazyFunction("store_app_data", -1, (c, t, lv) ->
{
if (lv.size() == 0)
throw new InternalExpressionException("store_app_data needs nbt tag and optional file");
throw new InternalExpressionException("'store_app_data' needs nbt tag and optional file");
Value val = lv.get(0).evalValue(c);
String file = null;
if (lv.size()>1)
@@ -3071,7 +3071,7 @@ public class CarpetExpression
}
catch (ArithmeticException ae)
{
throw new CarpetExpressionException("math doesn't compute... "+ae.getMessage());
throw new CarpetExpressionException("Math doesn't compute... "+ae.getMessage());
}
}
@@ -3118,7 +3118,7 @@ public class CarpetExpression
}
catch (ArithmeticException ae)
{
throw new CarpetExpressionException("math doesn't compute... "+ae.getMessage());
throw new CarpetExpressionException("Math doesn't compute... "+ae.getMessage());
}
}