Posted 02 April 2015 - 12:39 AM
Currently I am working on a redstone API integrating more logic controls into the existing system currently it will support two implementations of the code. I would appreciate if people could read code examples of both and tell me what they think of it so far and how I could improve the structure/make it easier if need be for end users.
the first usage is standard lua style functions
circuit.inputs = {"left","right","pseudo"} –#sets the inputs the code takes pseudo is a placeholder for code side
xorPart=circuit.xor(1,2) –#adds a xor logic part using inputs 1 and 2 (left and right)
–#xor will output high if it's two inputs are different
latchPart=circuit.latch(xorPart.output[1],3) –#creates a basic latch using the output of our xor and the pseudo input
–#this latch will lock it's output if the second input is high
circuit.output = "front" –#setting a single output for our redstone to go
circuit.run() –# starts the circuit running as a daemon(background)
sleep(3)
circuit.pseudo[1]=true –#makes pseudo input highin this example redstone signal will output from the front if left and right inputs are different and continue this for 3 seconds after which it will lock whatever output it is currently sending.
The following code does the same thing but in a more advanced style using it's own scripting language built from lua.
circuit.IO = {"left","right","front"}
circuit.script = "60(ab^Rc)"
circuit.run()
broken down:
60() means repeat for 3 seconds(60 ticks)
ab creates a table that functions similar to a stack pushing the values of a and b
^ pops the top two values in the current stack and pushes the xor value of the two
Rc pops the top value of the stacks and returns it to the IO defined after in this case c or "front"
Colored cables and analog will both be supported but for now I was just curious how people felt about the current structure I'm going with for this API
the first usage is standard lua style functions
Spoiler
circuit = redScript.solder() –#loads codecircuit.inputs = {"left","right","pseudo"} –#sets the inputs the code takes pseudo is a placeholder for code side
xorPart=circuit.xor(1,2) –#adds a xor logic part using inputs 1 and 2 (left and right)
–#xor will output high if it's two inputs are different
latchPart=circuit.latch(xorPart.output[1],3) –#creates a basic latch using the output of our xor and the pseudo input
–#this latch will lock it's output if the second input is high
circuit.output = "front" –#setting a single output for our redstone to go
circuit.run() –# starts the circuit running as a daemon(background)
sleep(3)
circuit.pseudo[1]=true –#makes pseudo input high
The following code does the same thing but in a more advanced style using it's own scripting language built from lua.
Spoiler
circuit = redScript.solder()circuit.IO = {"left","right","front"}
circuit.script = "60(ab^Rc)"
circuit.run()
broken down:
60() means repeat for 3 seconds(60 ticks)
ab creates a table that functions similar to a stack pushing the values of a and b
^ pops the top two values in the current stack and pushes the xor value of the two
Rc pops the top value of the stacks and returns it to the IO defined after in this case c or "front"
Colored cables and analog will both be supported but for now I was just curious how people felt about the current structure I'm going with for this API
Edited on 02 April 2015 - 08:25 PM