diff --git a/csharp_mod/Extensions.cs b/csharp_mod/Extensions.cs index 6fe9999..cefd685 100644 --- a/csharp_mod/Extensions.cs +++ b/csharp_mod/Extensions.cs @@ -134,6 +134,9 @@ public static unsafe class SlangExtensions case 7: // (punctuation) return SlangFormatter.ColorDefault; + case 8: // Comments + return SlangFormatter.ColorComment; + case 10: // (syscalls) return SlangFormatter.ColorFunction; diff --git a/rust_compiler/libs/compiler/test_files/script.slang b/rust_compiler/libs/compiler/test_files/script.slang new file mode 100644 index 0000000..8346c64 --- /dev/null +++ b/rust_compiler/libs/compiler/test_files/script.slang @@ -0,0 +1,41 @@ +// Pressure numbers are in KPa + +device self = "db"; +device emergencyRelief = "d0"; +device greenhouseSensor = "d1"; +device recycleValve = "d2"; + +const MAX_INTERIOR_PRESSURE = 80; +const MAX_INTERIOR_TEMP = 28c; +const MIN_INTERIOR_PRESSURE = 75; +const MIN_INTERIOR_TEMP = 25c; +const daylightSensor = 1076425094; +const growLight = hash("StructureGrowLight"); +const wallLight = hash("StructureLightLong"); +const lightRound = hash("StructureLightRound"); + +let shouldPurge = false; + +loop { + let interiorPress = greenhouseSensor.Pressure; + let interiorTemp = greenhouseSensor.Temperature; + + shouldPurge = ( + interiorPress > MAX_INTERIOR_PRESSURE || + interiorTemp > MAX_INTERIOR_TEMP + ) || shouldPurge; + + emergencyRelief.On = shouldPurge; + recycleValve.On = !shouldPurge; + + if (shouldPurge && (interiorPress < MIN_INTERIOR_PRESSURE && interiorTemp < MIN_INTERIOR_TEMP)) { + shouldPurge = false; + } + + let solarAngle = lb(daylightSensor, "SolarAngle", "Average"); + let isDaylight = solarAngle < 90; + + sb(growLight, "On", isDaylight); + sb(wallLight, "On", !isDaylight); + sb(lightRound, "On", !isDaylight); +} \ No newline at end of file