mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-08-10 17:55:44 +00:00
more MSES crap
This commit is contained in:
parent
85a15f1bbd
commit
24ed4224a8
@ -111,6 +111,17 @@ public class ParseMSES1 implements IParse {
|
|||||||
return EnumStatementReturn.OK;
|
return EnumStatementReturn.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// runs the calculation from the buffer, allows string substitution, saves result to buffer
|
||||||
|
if(lower.equals("eval")) {
|
||||||
|
if(ctx.readBuffer().isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||||
|
String statement = substitute(ctx, ctx.readBuffer(), true);
|
||||||
|
try {
|
||||||
|
double result = Calculator.evaluateExpression(statement);
|
||||||
|
ctx.writeBuffer("" + result);
|
||||||
|
} catch(Throwable ex) { return EnumStatementReturn.PARAMETER_ERROR; }
|
||||||
|
return EnumStatementReturn.OK;
|
||||||
|
}
|
||||||
|
|
||||||
// runs the calculation, allows string substitution, rounds, saves result to buffer,
|
// runs the calculation, allows string substitution, rounds, saves result to buffer,
|
||||||
if(lower.startsWith("evalr ")) {
|
if(lower.startsWith("evalr ")) {
|
||||||
if(line.length() <= 6) return EnumStatementReturn.PARAMETER_ERROR;
|
if(line.length() <= 6) return EnumStatementReturn.PARAMETER_ERROR;
|
||||||
@ -122,7 +133,7 @@ public class ParseMSES1 implements IParse {
|
|||||||
return EnumStatementReturn.OK;
|
return EnumStatementReturn.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// runs the calculation from the buffer, allows string substitution, saves result to buffer
|
// runs the calculation from the buffer, allows string substitution, saves rounded result to buffer
|
||||||
if(lower.equals("evalr")) {
|
if(lower.equals("evalr")) {
|
||||||
if(ctx.readBuffer().isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
if(ctx.readBuffer().isEmpty()) return EnumStatementReturn.PARAMETER_ERROR;
|
||||||
String statement = substitute(ctx, ctx.readBuffer(), true);
|
String statement = substitute(ctx, ctx.readBuffer(), true);
|
||||||
|
|||||||
@ -3,6 +3,9 @@ package com.hbm.module;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.hbm.tileentity.network.RTTYSystem;
|
||||||
|
import com.hbm.tileentity.network.RTTYSystem.RTTYChannel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MSES1-FEIS: Machine Script, Equestrian Standard - First Extended Instruction Set (v1.1)
|
* MSES1-FEIS: Machine Script, Equestrian Standard - First Extended Instruction Set (v1.1)
|
||||||
*
|
*
|
||||||
@ -10,6 +13,7 @@ import java.util.regex.Pattern;
|
|||||||
* * Support for splitter chars, splitting and split count
|
* * Support for splitter chars, splitting and split count
|
||||||
* * Support for the stack, a secondary buffer that can push, pop and peek
|
* * Support for the stack, a secondary buffer that can push, pop and peek
|
||||||
* * Support for getting string length and substring using first and last
|
* * Support for getting string length and substring using first and last
|
||||||
|
* * Support for listening only to recent RoR signals using poll
|
||||||
*
|
*
|
||||||
* @author hbm
|
* @author hbm
|
||||||
*/
|
*/
|
||||||
@ -108,6 +112,14 @@ public class ParseMSES1Ext1 extends ParseMSES1 {
|
|||||||
} catch(Exception x) { return EnumStatementReturn.PARAMETER_ERROR; }
|
} catch(Exception x) { return EnumStatementReturn.PARAMETER_ERROR; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// listens to an RoR signal using the supplied channel name and saves it to the buffer
|
||||||
|
if(lower.startsWith("poll ")) {
|
||||||
|
if(line.length() <= 5) return EnumStatementReturn.PARAMETER_ERROR;
|
||||||
|
RTTYChannel chan = RTTYSystem.listen(ctx.world, substitute(ctx, line.substring(5), false));
|
||||||
|
if(chan != null && chan.timeStamp >= ctx.world.getTotalWorldTime() - 1) ctx.writeBuffer(chan.signal + "");
|
||||||
|
return EnumStatementReturn.OK;
|
||||||
|
}
|
||||||
|
|
||||||
return super.eval(ctx, line);
|
return super.eval(ctx, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user