Skip to content

Commit

Permalink
Merge pull request #270 from PseudoKnight/enchancements
Browse files Browse the repository at this point in the history
Added optional argument to get_block_info()
  • Loading branch information
LadyCailin committed Feb 28, 2015
2 parents 5bdd8a1 + 249eadc commit 68c89d4
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/main/java/com/laytonsmith/core/functions/Environment.java
Expand Up @@ -1153,14 +1153,29 @@ public Construct exec(Target t, com.laytonsmith.core.environments.Environment en
MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer();
MCLocation l = ObjectGenerator.GetGenerator().location(args[0], p == null ? null : p.getWorld(), t);
MCBlock b = l.getBlock();
if(args.length == 2) {
switch(args[1].val()) {
case "solid":
return CBoolean.get(b.isSolid());
case "flammable":
return CBoolean.get(b.isFlammable());
case "transparent":
return CBoolean.get(b.isTransparent());
case "occluding":
return CBoolean.get(b.isOccluding());
case "burnable":
return CBoolean.get(b.isBurnable());
default:
throw new ConfigRuntimeException("Invalid argument for block info", ExceptionType.FormatException, t);
}
}
CArray array = new CArray(t);
array.set("solid", CBoolean.get(b.isSolid()), t);
array.set("flammable", CBoolean.get(b.isFlammable()), t);
array.set("transparent", CBoolean.get(b.isTransparent()), t);
array.set("occluding", CBoolean.get(b.isOccluding()), t);
array.set("burnable", CBoolean.get(b.isBurnable()), t);
return array;
//return CBoolean.get(l.getBlock().isSolid());
}

@Override
Expand All @@ -1170,12 +1185,13 @@ public String getName() {

@Override
public Integer[] numArgs() {
return new Integer[]{1};
return new Integer[]{1,2};
}

@Override
public String docs() {
return "array {locationArray} Returns an associative array with various information about a block ---- <ul>"
return "mixed {locationArray, [index]} Returns an associative array with various information about a block."
+ " If an index is specified, it will return a boolean. ---- <ul>"
+ " <li>solid: If a block is solid (i.e. dirt or stone, as opposed to a torch or water)</li>"
+ " <li>flammable: Indicates if a block can catch fire</li>"
+ " <li>transparent: Indicates if light can pass through</li>"
Expand Down

0 comments on commit 68c89d4

Please sign in to comment.