mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-10-25 21:40:08 +00:00
remove decimal on whole numbers (keeps parity with old scripts)
This commit is contained in:
1 parent
8c9afc4592
commit
e5fa4fd1f1
1 file changed
+12
-3
+12
-3
@@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
|
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||||
@@ -27,6 +25,17 @@ public class ConcatenationOperation extends BinaryOperation<Object, Object> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object apply(ImplementationArguments implementationArguments, Scope scope) {
|
public Object apply(ImplementationArguments implementationArguments, Scope scope) {
|
||||||
return left.apply(implementationArguments, scope).toString() + right.apply(implementationArguments, scope).toString();
|
return toString(left.apply(implementationArguments, scope)) + toString(right.apply(implementationArguments, scope));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String toString(Object object) {
|
||||||
|
String s = object.toString();
|
||||||
|
if(object instanceof Double) {
|
||||||
|
int l = s.length();
|
||||||
|
if(s.charAt(l - 2) == '.' && s.charAt(l - 1) == '0') {
|
||||||
|
s = s.substring(0, s.length() - 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user