diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 8efc8fb63b..d1948a4c99 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -796,6 +796,7 @@ setting.shadows.name = Shadows setting.blockreplace.name = Automatic Block Suggestions setting.linear.name = Linear Filtering setting.hints.name = Hints +setting.logichints.name = Logic Hints setting.flow.name = Display Resource Flow Rate setting.backgroundpause.name = Pause In Background setting.buildautopause.name = Auto-Pause Building @@ -1513,3 +1514,102 @@ unit.omura.description = Fires a long-range piercing railgun bolt at enemies. Co unit.alpha.description = Defends the Shard core from enemies. Builds structures. unit.beta.description = Defends the Foundation core from enemies. Builds structures. unit.gamma.description = Defends the Nucleus core from enemies. Builds structures. + +lst.read = Read a number from a linked memory cell. +lst.write = Write a number to a linked memory cell. +lst.print = Add text to the print buffer.\nDoes not display anything until [accent]Print Flush[] is used. +lst.draw = Add an operation to the drawing buffer.\nDoes not display anything until [accent]Draw Flush[] is used. +lst.drawflush = Flush queued [accent]Draw[] operations to a display. +lst.printflush = Flush queued [accent]Print[] operations to a message block. +lst.getlink = Get a processor link by index. Starts at 0. +lst.control = Control a building. +lst.radar = Locate units around a building with range. +lst.sensor = Get data from a building or unit. +lst.set = Set a variable. +lst.operation = Perform an operation on 1-2 variables. +lst.end = Jump to the top of the instruction stack. +lst.jump = Conditionally jump to another statement. +lst.unitbind = Bind to the next unit of a type, and store it in [accent]@unit[]. +lst.unitcontrol = Control the currently bound unit. +lst.unitradar = Locate units around the currently bound unit. +lst.unitlocate = Locate a specific type of position/building anywhere on the map.\nRequires a bound unit. + +lenum.type = Type of building/unit.\ne.g. for any router, this will return [accent]@router[].\nNot a string. +lenum.shoot = Shoot at a position. +lenum.shootp = Shoot at a unit/building with velocity prediction. +lenum.configure = Building configuration, e.g. sorter item. +lenum.enabled = Whether the block is enabled. +lenum.color = Illuminator color. + +lenum.always = Always true. +lenum.idiv = Integer division. +lenum.div = Division.\nReturns [accent]null[] on divide-by-zero. +lenum.mod = Modulo. +lenum.equal = Equal. Coerces types.\nNon-null objects compared with numbers become 1, otherwise 0. +lenum.notequal = Not equal. Coerces types. +lenum.strictequal = Strict equality. Does not coerce types.\nCan be used to check for [accent]null[]. +lenum.shl = Bit-shift left. +lenum.shr = Bit-shift right. +lenum.or = Bitwise OR. +lenum.land = Logical AND. +lenum.and = Bitwise AND. +lenum.not = Bitwise flip. +lenum.xor = Bitwise XOR. + +lenum.min = Minimum of two numbers. +lenum.max = Maximum of two numbers. +lenum.angle = Angle of vector in degrees. +lenum.len = Length of vector. +lenum.sin = Sine, in degrees. +lenum.cos = Cosine, in degrees. +lenum.tan = Tangent, in degrees. +lenum.rand = Random number in range [0, value). +lenum.log = Natural logarithm (ln). +lenum.log10 = Base 10 logarithm. +lenum.noise = 2D simplex noise. +lenum.abs = Absolute value. +lenum.sqrt = Square root. + +lenum.any = Any unit. +lenum.ally = Ally unit. +lenum.attacker = Unit with a weapon. +lenum.enemy = Enemy unit. +lenum.boss = Guardian unit. +lenum.flying = Flying unit. +lenum.ground = Ground unit. +lenum.player = Unit controlled by a player. + +lenum.ore = Ore deposit. +lenum.damaged = Damaged ally building. +lenum.spawn = Enemy spawn point.\nMay be a core or a position. +lenum.building = Building in a specific group. + +lenum.core = Any core. +lenum.storage = Storage building, e.g. Vault. + +sensor.in = The building/unit to sense. + +radar.from = Building to sense from.\nSensor range is limited by building range. +radar.target = Filter for units to sense. +radar.and = Additional filters. +radar.order = Sorting order. 0 to reverse. +radar.sort = Metric to sort results by. +radar.output = Variable to write output unit to. + +unitradar.target = Filter for units to sense. +unitradar.and = Additional filters. +unitradar.order = Sorting order. 0 to reverse. +unitradar.sort = Metric to sort results by. +unitradar.output = Variable to write output unit to. + +control.of = Building to control. +control.unit = Unit/building to aim at. +control.shoot = Whether to shoot. + +unitlocate.enemy = Whether to locate enemy buildings. +unitlocate.found = Whether the object was found. +unitlocate.building = Output variable for located building. +unitlocate.outx = Output X coordinate. +unitlocate.outy = Output Y coordinate. +unitlocate.group = Building group to look for. + diff --git a/core/src/mindustry/core/UI.java b/core/src/mindustry/core/UI.java index 28b283fc7b..82e7973dcd 100644 --- a/core/src/mindustry/core/UI.java +++ b/core/src/mindustry/core/UI.java @@ -108,7 +108,7 @@ public class UI implements ApplicationListener, Loadable{ Dialog.setHideAction(() -> sequence(fadeOut(0.1f))); Tooltips.getInstance().animations = false; - Tooltips.getInstance().textProvider = text -> new Tooltip(t -> t.background(Styles.black5).margin(4f).add(text)); + Tooltips.getInstance().textProvider = text -> new Tooltip(t -> t.background(Styles.black6).margin(4f).add(text)); Core.settings.setErrorHandler(e -> { Log.err(e); diff --git a/core/src/mindustry/logic/ConditionOp.java b/core/src/mindustry/logic/ConditionOp.java index 0954567c06..54a88f4d29 100644 --- a/core/src/mindustry/logic/ConditionOp.java +++ b/core/src/mindustry/logic/ConditionOp.java @@ -7,6 +7,7 @@ public enum ConditionOp{ lessThanEq("<=", (a, b) -> a <= b), greaterThan(">", (a, b) -> a > b), greaterThanEq(">=", (a, b) -> a >= b), + strictEqual("===", (a, b) -> false), always("always", (a, b) -> true); public static final ConditionOp[] all = values(); diff --git a/core/src/mindustry/logic/LCanvas.java b/core/src/mindustry/logic/LCanvas.java index 1beab892cd..e401b3079f 100644 --- a/core/src/mindustry/logic/LCanvas.java +++ b/core/src/mindustry/logic/LCanvas.java @@ -41,6 +41,13 @@ public class LCanvas extends Table{ return Core.graphics.getWidth() < Scl.scl(900f) * 1.2f; } + public static void tooltip(Cell cell, String key){ + String lkey = key.toLowerCase().replace(" ", ""); + if(Core.settings.getBool("logichints", true) && Core.bundle.has(lkey)){ + cell.get().addListener(new Tooltip(t -> t.background(Styles.black8).margin(4f).add("[lightgray]" + Core.bundle.get(lkey)).style(Styles.outlineLabel))); + } + } + public void rebuild(){ targetWidth = useRows() ? 400f : 900f; float s = pane != null ? pane.getScrollPercentY() : 0f; diff --git a/core/src/mindustry/logic/LExecutor.java b/core/src/mindustry/logic/LExecutor.java index e0bb01ac7e..f6e953d2f7 100644 --- a/core/src/mindustry/logic/LExecutor.java +++ b/core/src/mindustry/logic/LExecutor.java @@ -966,7 +966,9 @@ public class LExecutor{ Var vb = exec.var(compare); boolean cmp; - if(op.objFunction != null && va.isobj && vb.isobj){ + if(op == ConditionOp.strictEqual){ + cmp = va.isobj == vb.isobj && ((va.isobj && va.objval == vb.objval) || (!va.isobj && va.numval == vb.numval)); + }else if(op.objFunction != null && va.isobj && vb.isobj){ //use object function if both are objects cmp = op.objFunction.get(exec.obj(value), exec.obj(compare)); }else{ diff --git a/core/src/mindustry/logic/LStatement.java b/core/src/mindustry/logic/LStatement.java index 42d9915414..cd707f1819 100644 --- a/core/src/mindustry/logic/LStatement.java +++ b/core/src/mindustry/logic/LStatement.java @@ -15,6 +15,8 @@ import mindustry.logic.LCanvas.*; import mindustry.logic.LExecutor.*; import mindustry.ui.*; +import static mindustry.logic.LCanvas.*; + /** * A statement is an intermediate representation of an instruction, to be used mostly in UI. * Contains all relevant variable information. */ @@ -38,13 +40,18 @@ public abstract class LStatement{ //protected methods are only for internal UI layout utilities + protected void param(Cell