added macro to export perph

This commit is contained in:
2023-07-08 12:51:08 +02:00
parent 4084659a4a
commit 4f881117cf
2 changed files with 80 additions and 10 deletions

View File

@@ -43,6 +43,7 @@ abstract BundleMask(Int) from cc.Colors.Color to cc.Colors.Color {
}
}
@:build(macros.Exporter.buildExport())
class Redstone implements IPeripheral implements IExportable {
public static inline final TYPE_NAME:String = "redstone"; // TODO: there is technically not a type for redstone.
@@ -89,10 +90,12 @@ class Redstone implements IPeripheral implements IExportable {
cc.Redstone.setOutput(this.addr,on);
}
@export("output")
public inline function getOutput(): Bool {
return cc.Redstone.getOutput(this.addr);
}
@export("input")
public inline function getInput(): Bool {
return cc.Redstone.getInput(this.addr);
}
@@ -126,14 +129,4 @@ class Redstone implements IPeripheral implements IExportable {
public inline function testBundledInput(mask: Color): Bool {
return cc.Redstone.testBundledInput(this.addr,mask);
}
public function export():ExportConfig {
return {
getDelegates: [
"input" => (_) -> {return Bool(this.getInput());},
"analog" => (_) -> {return Number(this.getAnalogInput());}
]
};
}
}