Skip to content

Commit f3b054e

Browse files
committed
First usable version
1 parent a5b6184 commit f3b054e

File tree

8 files changed

+14
-3
lines changed

8 files changed

+14
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# MlogAssertions
22

33
Provides custom mlog instructions for enhanced runtime checks in Mindustry Logic.
4+
5+
The mod is still under development. The precise specification of instructions may still change.

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ jar{
7979

8080
from(projectDir){
8181
include "mod.hjson"
82+
include "icon.png"
8283
}
8384

8485
from("assets/"){

icon.pdn

54.8 KB
Binary file not shown.

icon.png

24.8 KB
Loading

mod.hjson

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ displayName: "Mlog Assertions"
44
#the internal name of your mod
55
name: "mlog-assertions"
66

7+
subtitle: "Easier debugging for mlog",
8+
79
#your name
810
author: "cardillan"
911

src/cardillan/mlogassertions/Assertions.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public static void add(LogicBuild block, String message) {
3232
}
3333
}
3434

35+
public static void remove(LogicBuild block) {
36+
remove((int) block.getX(), (int) block.getY());
37+
}
38+
3539
public static void remove(int x, int y) {
3640
blocks.remove(x, y);
3741
messages.remove(x, y);

src/cardillan/mlogassertions/logic/AssertLStatements.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public static void register() {
2222
Seq<Prov<LStatement>> seq = statements.map(prov -> prov::get);
2323
LogicIO.allStatements.addAll(seq);
2424

25-
// Customized LStatements will register customized reader automatically.
2625
for (Prov<AssertStatement> prov : statements) {
2726
AssertStatement statement = prov.get();
2827
LAssembler.customParsers.put(opcode, statement::read);
@@ -36,7 +35,7 @@ private static class AssertStatement extends LStatement {
3635
public String value = "index";
3736
public AssertOp opMax = AssertOp.lessThanEq;
3837
public String max = "10";
39-
public String message = "\"Array index out of bounds (0 to 10).\"";
38+
public String message = "\"Index out of bounds (0 to 10).\"";
4039

4140
@Override
4241
public LCategory category() {

src/cardillan/mlogassertions/logic/AssertsLInstructions.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,22 @@ public AssertI() {
3232

3333
@Override
3434
public final void run(LExecutor exec) {
35+
Building building = exec.building( LExecutor.varThis);
36+
3537
Var vaVal = var(exec, value);
3638
boolean typeAssert = vaVal.isobj ? type.objFunction.get(vaVal.objval) : type.function.get(vaVal.numval);
3739
boolean minAssert = opMin.function.get(num(exec,min), num(exec,value));
3840
boolean maxAssert = opMax.function.get(num(exec,value), num(exec,max));
3941

4042
if (!typeAssert || !minAssert || !maxAssert) {
41-
Building building = exec.building( LExecutor.varThis);
4243
Var message = var(exec, this.message);
4344
Assertions.add((LogicBlock.LogicBuild) building, LExecutor.PrintI.toString(message.objval));
4445

4546
//skip back to self.
4647
exec.counter.numval--;
4748
//exec.yield = true;
49+
} else {
50+
Assertions.remove((LogicBlock.LogicBuild) building);
4851
}
4952
}
5053

0 commit comments

Comments
 (0)