Advertisement
bobmarley12345

autoextractor

Jan 12th, 2025
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 21.47 KB | None | 0 0
  1. -- Config stuff
  2. local INTERFACE_SIDE = nil
  3. local INTERFACE_EXTRACT_DIRECTION = nil
  4. local MACHINE_COUNT = 0
  5. local REGISTRY = {}
  6. local SIDE_REGISTRY = {}
  7. local CURRENT_VERSION = "1.1"
  8.  
  9. local THE_INTERFACE = nil
  10. local ACTIVE_ASSEMBLY = nil
  11. local PRINT_ASSEMBLY_TO_TERM = true
  12.  
  13. local AppTimerId = 0
  14. local AppLastEventTime = 0
  15. local AppTimerInterval = 1
  16. local IsAppRunning = true
  17.  
  18. local COLOURS = {
  19.     white     = 1,
  20.     orange    = 2,
  21.     magenta   = 4,
  22.     lightBlue = 8,
  23.     yellow    = 16,
  24.     lime      = 32,
  25.     pink      = 64,
  26.     gray      = 128,
  27.     lightGray = 256,
  28.     cyan      = 512,
  29.     purple    = 1024,
  30.     blue      = 2048,
  31.     brown     = 4096,
  32.     green     = 8192,
  33.     red       = 16384,
  34.     black     = 32768
  35. }
  36.  
  37. function ClearTerminal()
  38.     term.clear()
  39.     term.setCursorPos(1, 1)
  40. end
  41.  
  42. function SetupTimer(delay)
  43.     AppTimerId = os.startTimer(delay)
  44. end
  45.  
  46. function CanonicaliseSide(side)
  47.     if (side == nil or #side < 3 or #side > 6) then
  48.         return nil
  49.     end
  50.  
  51.     local s = string.lower(side)
  52.     if (s == "left" or s == "top" or s == "right" or s == "bottom" or s == "front" or s == "back") then
  53.         return s
  54.     end
  55.  
  56.     return nil
  57. end
  58.  
  59. --region Utils
  60.  
  61. function Colour_Int2String(num)
  62.     if (num == colours.white)         then return "white"
  63.     elseif (num == colours.orange)    then return "orange"
  64.     elseif (num == colours.magenta)   then return "magenta"
  65.     elseif (num == colours.lightBlue) then return "lightblue"
  66.     elseif (num == colours.yellow)    then return "yellow"
  67.     elseif (num == colours.lime)      then return "lime"
  68.     elseif (num == colours.pink)      then return "pink"
  69.     elseif (num == colours.gray)      then return "gray"
  70.     elseif (num == colours.lightGray) then return "lightgray"
  71.     elseif (num == colours.cyan)      then return "cyan"
  72.     elseif (num == colours.purple)    then return "purple"
  73.     elseif (num == colours.blue)      then return "blue"
  74.     elseif (num == colours.brown)     then return "brown"
  75.     elseif (num == colours.green)     then return "green"
  76.     elseif (num == colours.red)       then return "red"
  77.     elseif (num == colours.black)     then return "black"
  78.     else return nil end
  79. end
  80.  
  81. function Colour_String2Int(str)
  82.     local s = string.lower(str)
  83.     if (s == "white")         then return colours.white
  84.     elseif (s == "orange")    then return colours.orange
  85.     elseif (s == "magenta")   then return colours.magenta
  86.     elseif (s == "lightblue") then return colours.lightBlue
  87.     elseif (s == "yellow")    then return colours.yellow
  88.     elseif (s == "lime")      then return colours.lime
  89.     elseif (s == "pink")      then return colours.pink
  90.     elseif (s == "gray")      then return colours.gray
  91.     elseif (s == "lightgray") then return colours.lightGray
  92.     elseif (s == "cyan")      then return colours.cyan
  93.     elseif (s == "purple")    then return colours.purple
  94.     elseif (s == "blue")      then return colours.blue
  95.     elseif (s == "brown")     then return colours.brown
  96.     elseif (s == "green")     then return colours.green
  97.     elseif (s == "red")       then return colours.red
  98.     elseif (s == "black")     then return colours.black
  99.     else return nil end
  100. end
  101.  
  102. function ParseColourString(input)
  103.     if (input == nil) then
  104.         print("Invalid empty input for colour")
  105.         return nil
  106.     end
  107.  
  108.     local theColour = Colour_String2Int(input)
  109.     if (theColour == nil) then
  110.         print("Invalid colour: " .. input)
  111.     end
  112.     return theColour
  113. end
  114.  
  115. function CanonicaliseNSWE(dir)
  116.     if (dir == nil or #dir < 2 or #dir > 5) then
  117.         return nil
  118.     end
  119.  
  120.     local s = string.lower(dir)
  121.     if (s == "north" or s == "east" or s == "south" or s == "west" or s == "up" or s == "down") then
  122.         return s
  123.     end
  124.  
  125.     return nil
  126. end
  127.  
  128. function SplitInputByCommaAsTable(input)
  129.     local values = {}
  130.     for word in input:gmatch("([^,]+)") do
  131.         table.insert(values, word)
  132.     end
  133.     return values
  134. end
  135.  
  136. function math.round(value)
  137.     local floored = math.floor(value)
  138.     local diff = value - floored
  139.     if (diff >= 0.5) then
  140.         return math.ceil(value)
  141.     else
  142.         return floored
  143.     end
  144. end
  145.  
  146. --endregion
  147.  
  148. function DoExtraction(id, dmg, qty)
  149.     if (THE_INTERFACE ~= nil and INTERFACE_EXTRACT_DIRECTION ~= nil) then
  150.         local stack = {
  151.             id = id,
  152.             dmg = dmg,
  153.             qty = qty
  154.         }
  155.  
  156.         local count = THE_INTERFACE.extractItem(stack, INTERFACE_EXTRACT_DIRECTION)
  157.  
  158.         if (PRINT_ASSEMBLY_TO_TERM) then
  159.             local w,h = term.getSize()
  160.             local x,y = term.getCursorPos()
  161.             term.setCursorPos(1, y)
  162.             term.write(string.rep(" ", w))
  163.             local msg = "[" .. math.floor(os.clock()) .. "] Extracted " .. count .. "/" .. qty .. " of " .. id .. ":" .. dmg
  164.             term.setCursorPos(1, y)
  165.             term.write(msg)
  166.         end
  167.  
  168.         return count
  169.     end
  170.  
  171.     return 0
  172. end
  173.  
  174. function OnAutoProcessingStarted(doNotStartTimer)
  175.     print("Auto processing started with " .. #REGISTRY ..  " total records")
  176.     print("Press ENTER to stop, and enable command inputs")
  177.  
  178.     local time = os.clock()
  179.     for i, record in pairs(REGISTRY) do
  180.         record.lastTick = nil
  181.     end
  182.  
  183.     if (ACTIVE_ASSEMBLY ~= nil and ACTIVE_ASSEMBLY.timeUntilCompleted ~= nil) then
  184.         local rec = ACTIVE_ASSEMBLY
  185.         print("Still waiting machines have finished processing " .. rec.id .. ":" .. rec.dmg .. " (" .. math.floor((rec.timeUntilCompleted - time)) .. " secs remaining)")
  186.     end
  187.  
  188.     if (doNotStartTimer ~= true) then
  189.         SetupTimer(0)
  190.     end
  191. end
  192.  
  193. function ClearRegistry()
  194.     REGISTRY = {}
  195.     SIDE_REGISTRY = {}
  196. end
  197.  
  198. ---Register an item to extract from the ME system into a chest for autoprocessing
  199. ---@param theSide string The rednet cable side, relative to the computer
  200. ---@param theColour integer The colour to listen to on the side
  201. ---@param itemId integer The item ID to extract from the ME
  202. ---@param itemDmg integer The damage of the item to extract
  203. ---@param maxStackSize integer The maximum stack size for this item (e.g. enderpears is 16, cobble is 64)
  204. ---@param assemblyTime number The amount of time it takes to make 1 item for 1 machine. This must be percise!
  205. function Register(theSide, theColour, itemId, itemDmg, maxStackSize, assemblyTime)
  206.     local info = {
  207.         side = theSide,
  208.         colour = theColour,
  209.         id = itemId,
  210.         dmg = itemDmg,
  211.         assemblyTime = assemblyTime,
  212.         maxStackSize = maxStackSize,
  213.         currentlyAssembled = 0,
  214.         lastTick = nil,
  215.         buffer = 0
  216.     }
  217.  
  218.     table.insert(REGISTRY, info)
  219.     local sideTable = SIDE_REGISTRY[theSide]
  220.     if (not sideTable) then
  221.         sideTable = {}
  222.         SIDE_REGISTRY[theSide] = sideTable
  223.     end
  224.  
  225.     table.insert(sideTable, info)
  226.     return info
  227. end
  228.  
  229. function OnActiveAssemblyCompletionDelayFinished(record)
  230.     record.timeUntilCompleted = nil
  231.     ACTIVE_ASSEMBLY = nil
  232. end
  233.  
  234. --- Process the active record
  235. ---@param record table the record
  236. ---@param time number os time
  237. ---@return boolean True if the record has finished being processed, otherwise false to keep processing
  238. function ProcessActiveRecord(record, time)
  239.     local input = rs.getBundledInput(record.side)
  240.     if (colours.test(input, record.colour)) then
  241.         if (record.timeUntilCompleted ~= nil) then
  242.             record.timeUntilCompleted = nil
  243.             print("Signal restored. Continuing assembly of " .. record.id .. ":" .. record.dmg)
  244.         end
  245.  
  246.         local assemblyTime = record.assemblyTime
  247.         local machineCount = MACHINE_COUNT
  248.         local itemsPerSec = machineCount / assemblyTime
  249.  
  250.         local extractCount = 0
  251.         if (record.lastTick ~= nil) then
  252.             local count = (time - record.lastTick) * itemsPerSec
  253.             extractCount = math.floor(count)
  254.             local excess = count - extractCount
  255.             if (excess > 0) then
  256.                 record.buffer = record.buffer + excess
  257.             end
  258.    
  259.             local extra = math.floor(record.buffer)
  260.             if (extra >= 1) then
  261.                 record.buffer = record.buffer - extra
  262.                 extractCount = extractCount + extra
  263.             end
  264.         else
  265.             extractCount = itemsPerSec
  266.         end
  267.  
  268.         local finalExtraction = DoExtraction(record.id, record.dmg, extractCount)
  269.         if (finalExtraction < 1) then
  270.             local assembleCount = math.min(record.currentlyAssembled, record.maxStackSize)
  271.             local waitTime = math.floor((record.assemblyTime * assembleCount) / 1.2)
  272.             record.timeUntilCompleted = time + waitTime
  273.             print("Not enough items in ME system. Waiting for machines to clear (" .. waitTime .. " secs) before switching to next extractable item")
  274.             record.WasStoppedForNotEnoughItems = true
  275.             record.currentlyAssembled = 0
  276.         else
  277.             record.currentlyAssembled = record.currentlyAssembled + finalExtraction
  278.         end
  279.     elseif (record.timeUntilCompleted == nil) then
  280.         local assembleCount = math.min(record.currentlyAssembled, record.maxStackSize)
  281.         local waitTime = math.floor((record.assemblyTime * assembleCount) / 1.2)
  282.         record.timeUntilCompleted = time + waitTime
  283.         print("Assembly signal no longer active, Waiting for machines to clear (" .. waitTime .. " secs)")
  284.     elseif (time > record.timeUntilCompleted) then
  285.         OnActiveAssemblyCompletionDelayFinished(record)
  286.         print("Assembly completed. Beginning next item on next app tick")
  287.         record.lastTick = nil
  288.         record.currentlyAssembled = 0
  289.         return true
  290.     end
  291.  
  292.     record.lastTick = time
  293.     return false
  294. end
  295.  
  296. function OnBeginProcessRecord(record, time)
  297.     ACTIVE_ASSEMBLY = record
  298.     OnAutoProcessingStarted()
  299. end
  300.  
  301. function ProcessNextOrCurrent(time)
  302.     if (ACTIVE_ASSEMBLY == nil or ProcessActiveRecord(ACTIVE_ASSEMBLY, time)) then
  303.         -- find next item to start processing
  304.         for side, values in pairs(SIDE_REGISTRY) do
  305.             local input = rs.getBundledInput(side)
  306.             for i, record in pairs(values) do
  307.                 if (colours.test(input, record.colour)) then
  308.                     if (record.WasStoppedForNotEnoughItems) then
  309.                         record.WasStoppedForNotEnoughItems = false
  310.                     else
  311.                         OnBeginProcessRecord(record, time)
  312.                         return
  313.                     end
  314.                 end
  315.             end
  316.         end
  317.     end
  318. end
  319.  
  320. function LoadConfigInfo()
  321.     if (not fs.exists("config")) then
  322.         return false
  323.     end
  324.  
  325.     local hFile = fs.open("config", "r")
  326.     if (hFile == nil) then
  327.         print("Failed to open config file")
  328.         return false
  329.     end
  330.  
  331.     local isFail = false
  332.  
  333.     if (hFile.readLine() ~= CURRENT_VERSION) then
  334.         isFail = true
  335.         print("Config file is old, and cannot be used")
  336.     end
  337.  
  338.     local itf_side
  339.     local itf_pull_dir
  340.     local machine_count
  341.     if (not isFail) then
  342.         local machines_raw = hFile.readLine()
  343.         local machines = tonumber(machines_raw)
  344.         if (machines == nil) then
  345.             print("Invalid integer for the machine count in config: " .. machines_raw)
  346.             isFail = true
  347.         elseif (machines < 1) then
  348.             print("Machine count was negative in config: " .. machines)
  349.             isFail = true
  350.         else
  351.             machine_count = machines
  352.         end
  353.        
  354.         local itf_side_raw = hFile.readLine()
  355.         itf_side = CanonicaliseSide(itf_side_raw)
  356.         if (itf_side == nil) then
  357.             print("Invalid interface side in config: " .. itf_side_raw)
  358.             isFail = true
  359.         end
  360.  
  361.         if (not isFail) then
  362.             local itf_pull_dir_raw = hFile.readLine()
  363.             itf_pull_dir = CanonicaliseNSWE(itf_pull_dir_raw)
  364.             if (itf_pull_dir == nil) then
  365.                 print("Invalid interface extract direction: " .. itf_pull_dir_raw)
  366.                 isFail = true
  367.             end
  368.         end
  369.  
  370.         if (not isFail) then
  371.             ClearRegistry()
  372.             -- left,colour_int,id,dmg,qtyRate,isAsync
  373.             while (true) do
  374.                 local nextLine = hFile.readLine()
  375.                 if (nextLine == nil) then
  376.                     break
  377.                 end
  378.  
  379.                 local values = SplitInputByCommaAsTable(nextLine)
  380.                 if (#values ~= 6) then
  381.                     print("Invalid line in config. Expected 6 elements in an item record, separated by commas")
  382.                     isFail = true
  383.                     break
  384.                 end
  385.  
  386.                 local side = CanonicaliseSide(values[1])
  387.                 if (side == nil) then
  388.                     print("Invalid side in item record: " .. values[1])
  389.                     isFail = true
  390.                     break
  391.                 end
  392.  
  393.                 local col = ParseColourString(values[2])
  394.                 if (col == nil) then
  395.                     isFail = true
  396.                     break
  397.                 end
  398.  
  399.                 local id = tonumber(values[3])
  400.                 if (id == nil) then
  401.                     print("Invalid number for item id in item record: " .. values[3])
  402.                     isFail = true
  403.                     break
  404.                 end
  405.  
  406.                 local dmg = tonumber(values[4])
  407.                 if (dmg == nil) then
  408.                     print("Invalid number for item damage in item record: " .. values[4])
  409.                     isFail = true
  410.                     break
  411.                 end
  412.  
  413.                 local maxStackSize = tonumber(values[5])
  414.                 if (maxStackSize == nil) then
  415.                     print("Invalid integer for maximum stack size in item record: " .. values[5])
  416.                     isFail = true
  417.                     break
  418.                 end
  419.  
  420.                 local qtyRate = tonumber(values[6])
  421.                 if (qtyRate == nil) then
  422.                     print("Invalid number for quantity rate in item record: " .. values[6])
  423.                     isFail = true
  424.                     break
  425.                 end
  426.  
  427.                 Register(side, col, id, dmg, maxStackSize, qtyRate)
  428.             end
  429.         end
  430.     end
  431.  
  432.     hFile.close()
  433.  
  434.     if (isFail) then
  435.         ClearRegistry()
  436.         INTERFACE_SIDE = nil
  437.         INTERFACE_EXTRACT_DIRECTION = nil
  438.         MACHINE_COUNT = 0
  439.         return false
  440.     else
  441.         INTERFACE_SIDE = itf_side
  442.         INTERFACE_EXTRACT_DIRECTION = itf_pull_dir
  443.         MACHINE_COUNT = machine_count
  444.         return true
  445.     end
  446. end
  447.  
  448. function SaveConfigInfo()
  449.     local hFile = fs.open("config", "w")
  450.     if (hFile == nil) then
  451.         print("Failed to open config file for writing")
  452.         return
  453.     end
  454.  
  455.     hFile.writeLine(CURRENT_VERSION)
  456.     hFile.writeLine(MACHINE_COUNT)
  457.     if (INTERFACE_SIDE ~= nil) then
  458.         hFile.writeLine(INTERFACE_SIDE)
  459.     else
  460.         hFile.writeLine("")
  461.     end
  462.  
  463.     if (INTERFACE_EXTRACT_DIRECTION ~= nil) then
  464.         hFile.writeLine(INTERFACE_EXTRACT_DIRECTION)
  465.     else
  466.         hFile.writeLine("")
  467.     end
  468.  
  469.     for i, record in pairs(REGISTRY) do
  470.         hFile.writeLine(record.side .. "," .. Colour_Int2String(record.colour) .. "," .. record.id .. "," .. record.dmg .. "," .. record.maxStackSize .. "," .. record.assemblyTime)
  471.     end
  472.  
  473.     hFile.close()
  474. end
  475.  
  476. function ReadInputWithMsg(...)
  477.     for i = 1, arg.n, 1 do
  478.         print(arg[i])
  479.     end
  480.     term.write(">")
  481.     return read()
  482. end
  483.  
  484. function ReadRecordFromTermAndRegister()
  485.     local theSide = CanonicaliseSide(ReadInputWithMsg("Input rednet cable side (relative to computer)"))
  486.     if (theSide == nil) then
  487.         print("Invalid side")
  488.         return nil
  489.     end
  490.  
  491.     local theColour = ParseColourString(ReadInputWithMsg("Input the rednet colour"))
  492.     if (theColour == nil) then
  493.         return nil
  494.     end
  495.  
  496.     local itemId = tonumber(ReadInputWithMsg("Input the Item ID to extract"))
  497.     if (itemId == nil) then
  498.         print("Invalid integer for item ID")
  499.         return nil
  500.     end
  501.  
  502.     local itemDamage = tonumber(ReadInputWithMsg("Input the item damage"))
  503.     if (itemDamage == nil) then
  504.         print("Invalid integer for item damage")
  505.         return nil
  506.     end
  507.  
  508.     local maxStackSize = tonumber(ReadInputWithMsg("Input the maximum stack size for this item", "(or for this item in the specific machine)"))
  509.     if (maxStackSize == nil) then
  510.         print("Invalid integer for max stack size")
  511.         return nil
  512.     end
  513.  
  514.     local assemblyTime = tonumber(ReadInputWithMsg("Input the assembly time for this item in 1 machine", "(cobble in a RS furnace takes 4s, so input 4)"))
  515.     if (assemblyTime == nil) then
  516.         print("Invalid number for assembly time")
  517.         return nil
  518.     end
  519.  
  520.     return Register(theSide, theColour, itemId, itemDamage, maxStackSize, assemblyTime)
  521. end
  522.  
  523. function SetupConfig()
  524.     local machines_raw = ReadInputWithMsg("Input the number of machines")
  525.     local machines = tonumber(machines_raw)
  526.     if (machines == nil) then
  527.         print("Invalid integer for the machine count: " .. machines_raw)
  528.         return false
  529.     end
  530.  
  531.     local itf_side_raw = ReadInputWithMsg("Input the side that the interface is on", "(top, bottom, left, right, front or back)")
  532.     local itf_side = CanonicaliseSide(itf_side_raw)
  533.     if (itf_side == nil) then
  534.         print("Invalid side: " .. itf_side_raw)
  535.         return false
  536.     end
  537.  
  538.     local pull_dir_raw = ReadInputWithMsg("Input world direction of the chest, relative to the ME Interface", "(up, down, north, east, south, or west)")
  539.     local pull_dir = CanonicaliseNSWE(pull_dir_raw)
  540.     if (pull_dir == nil) then
  541.         print("Invalid direction: " .. pull_dir_raw)
  542.         return false
  543.     end
  544.  
  545.     MACHINE_COUNT = math.floor(machines)
  546.     INTERFACE_SIDE = itf_side
  547.     INTERFACE_EXTRACT_DIRECTION = pull_dir
  548.     return true
  549. end
  550.  
  551. local function OnApplicationEvent(time, eventType, p1, p2, p3, p4, p5)
  552.     if (eventType == "timer" and p1 == AppTimerId) then
  553.         SetupTimer(math.max(AppTimerInterval - (os.clock() - time), 0))
  554.         ProcessNextOrCurrent(time)
  555.     elseif (eventType == "key" and tonumber(p1) == 28) then
  556.         print("Automatic processing stopped. Input command")
  557.         print("(reset, add, clear records, list, start, exit):")
  558.         local breakLoop
  559.         repeat
  560.             breakLoop = true
  561.             term.write(">")
  562.             local cmd = read()
  563.             if (cmd == "reset") then
  564.                 ClearTerminal()
  565.                 while (not SetupConfig()) do end
  566.                 ClearTerminal()
  567.                 SaveConfigInfo()
  568.                 OnAutoProcessingStarted()
  569.             elseif (cmd == "add") then
  570.                 repeat
  571.                     ReadRecordFromTermAndRegister()
  572.                 until ReadInputWithMsg("Do you want to add another? (yes/no)") ~= "yes"
  573.                 ClearTerminal()
  574.                 SaveConfigInfo()
  575.                 OnAutoProcessingStarted()
  576.             elseif (cmd == "clear records") then
  577.                 ClearRegistry()
  578.                 if (ReadInputWithMsg("Do you want to add some records? (yes/no)") == "yes") then
  579.                     repeat
  580.                         ReadRecordFromTermAndRegister()
  581.                     until ReadInputWithMsg("Do you want to add another? (yes/no)") ~= "yes"
  582.                 end
  583.                 ClearTerminal()
  584.                 SaveConfigInfo()
  585.                 OnAutoProcessingStarted()
  586.             elseif (cmd == "list") then
  587.                 print(MACHINE_COUNT .. " machines")
  588.                 for i, record in pairs(REGISTRY) do
  589.                     print(record.id .. ":" .. record.dmg .. " via '" .. record.side .. "->" .. Colour_Int2String(record.colour) .. "'. AT = " .. record.assemblyTime .. "s" .. " (" .. math.floor(MACHINE_COUNT / record.assemblyTime) .. " itm/s)")
  590.                 end
  591.  
  592.                 print("Press any key to continue")
  593.                 read()
  594.                 OnAutoProcessingStarted()
  595.             elseif (cmd == "skipwait") then
  596.                 if (ACTIVE_ASSEMBLY == nil or ACTIVE_ASSEMBLY.timeUntilCompleted == nil) then
  597.                     print("Not currently waiting for an assembly to complete")
  598.                 else
  599.                     OnActiveAssemblyCompletionDelayFinished(ACTIVE_ASSEMBLY)
  600.                     print("Cleared assembly wait time. The machines may still have items in them")
  601.                 end
  602.                 OnAutoProcessingStarted()
  603.             elseif (cmd == "start") then
  604.                 ClearTerminal()
  605.                 OnAutoProcessingStarted()
  606.             elseif (cmd == "exit") then
  607.                 print("Exiting application")
  608.                 IsAppRunning = false
  609.             else
  610.                 print("Unknown command: " .. cmd)
  611.                 breakLoop = false
  612.             end
  613.         until breakLoop
  614.     end
  615. end
  616.  
  617. function AppMain()
  618.     if (not LoadConfigInfo()) then
  619.         while (not SetupConfig()) do end
  620.         SaveConfigInfo()
  621.     end
  622.  
  623.     while true do
  624.         THE_INTERFACE = peripheral.wrap(INTERFACE_SIDE)
  625.         if (THE_INTERFACE == nil) then
  626.             print("No interface found. Retrying in 4 seconds...")
  627.             sleep(4)
  628.         else
  629.             break
  630.         end
  631.     end
  632.  
  633.     OnAutoProcessingStarted(true)
  634.     SetupTimer(AppTimerInterval)
  635.     while IsAppRunning do
  636.         local eType, p1, p2, p3, p4, p5 = os.pullEvent()
  637.         local time = os.clock()
  638.         OnApplicationEvent(time, eType, p1, p2, p3, p4, p5)
  639.         AppLastEventTime = time
  640.     end
  641. end
  642.  
  643. AppMain()
  644.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement