diff --git a/libevent.lua b/libevent.lua index 79fe630..a9668a9 100644 --- a/libevent.lua +++ b/libevent.lua @@ -99,7 +99,7 @@ local function doEventTranslate(raw_event) t["targetAddress"]=c t["data"]=d t["metadata"]=e - elseif(name=="minecraft") then + elseif(name=="minecart") then t["detectorAddress"]=a t["minecartType"]=b t["minecartName"]=c @@ -151,8 +151,12 @@ function RemoveEventListener(ListenerID) end function WaitEvent(EventName) - checkstring(EventName) - return doEventTranslate(table.pack(event.pull(EventName))) + if(EventName~=nil) then + checkstring(EventName) + return doEventTranslate(table.pack(event.pull(EventName))) + else + return doEventTranslate(table.pack(event.pull())) + end end function WaitEventFor(EventName,TimeOut) diff --git a/transport_center.lua b/transport_center.lua new file mode 100644 index 0000000..6cff8c8 --- /dev/null +++ b/transport_center.lua @@ -0,0 +1,9 @@ +local component=require("component") +local event=require("event") +require("util") + + + +local function main() + +end diff --git a/transport_client.lua b/transport_client.lua new file mode 100644 index 0000000..d0a3421 --- /dev/null +++ b/transport_client.lua @@ -0,0 +1,85 @@ +local component=require("component") +local event=require("event") +require("util") + +--- Auto Configure +local digital_controller = proxy("digital_controller_box") +local digital_receiver = proxy("digital_receiver_box") +local transposer = proxy("transposer") +local routing_track = proxy("routing_track") + +--- Manually Configure +local route_in_ab = proxy("routing_switch","6") +local route_in_ba = proxy("routing_switch","a") +local route_out = proxy("routing_switch","1") + +-- Value: 1 Green 2 Blinking Yello 3 Yello 4 Blinking Red 5 Red +local green=1 +local byello=2 +local yello=3 +local bred=4 +local red=5 + +local function setSignal(name,value) + digital_controller.setAspect(name,value) +end + +local function checkDevice() + local function doCheckDevice(device) + if(device==nil) then + error("Some device is nil. Please double check your configure.") + end + end + + doCheckDevice(digital_controller) + doCheckDevice(digital_receiver) + doCheckDevice(transposer) + doCheckDevice(routing_track) + doCheckDevice(route_in_ab) + doCheckDevice(route_in_ba) + doCheckDevice(route_out) + + local t=digital_controller.getSignalNames() + + local function checkSigName(name) + local found=false + for k,v in pairs(t) do + if(v==name) then + return true + end + end + error("CheckSigName: Failed to check signal: " .. name) + end + + checkSigName("Cart_Ctrl") + checkSigName("Lamp") + checkSigName("Box_Ctrl") + + t=digital_receiver.getSignalNames() + checkSigName("Cart_Ready") + + print("Check device pass.") +end + +local function resetDevice() + digital_controller.setEveryAspect(red) + setSignal("Lamp",green) + + route_in_ab.setRoutingTable({}) + route_in_ba.setRoutingTable({}) + route_out.setRoutingTable({}) + + print("Device reset done.") +end + +local function main() + checkDevice() + resetDevice() + + while true do + print("Please put your things in the box. Then press ENTER.") + local e=event.pull(e) + end +end + +main() \ No newline at end of file diff --git a/transport_repo.lua b/transport_repo.lua new file mode 100644 index 0000000..e69de29