Jump to content




CCAsync - Asynchronous engine

utility lua api

  • You cannot reply to this topic
No replies to this topic

#1 AlexDevs

  • Members
  • 72 posts
  • Location~

Posted 05 December 2017 - 01:12 PM

CCAsync

Asynchronous engine for ComputerCraft



CCAsync is an asynchronous engine made for mostly multitasking projects.

The event API will help you manage events and timings better thanks to coroutines.

Usage:
async <file> [args [...]]


Example of async program:
event.on("mouse_click", function(_,x,y)
  print("You clicked at X"..x.." Y"..y)
end)

event.on("key",function(key)
  if key == keys.space then
	local terminable = event.isTerminable()
	local newValue = not terminable
	event.terminable(newValue)
	print("Terminable: "..tostring(newValue))
  end
  if key == keys.backspace then
	print("Closing...")
	event.exit()
  end
end)

local function charHandler(char)
  print("You pressed: "..char)
  event.setTimeout(function(arg)
	print("You pressed "..char.." 2 seconds ago")
	print("This is a random arg: "..arg)
  end,2, "random arg")
end
event.on("char",charHandler)

Install:
wget https://raw.github.com/Ale32bit/CCAsync/master/async.lua async.lua


Full API: https://github.com/A...aster/README.md

Edited by Ale32bit, 06 December 2017 - 10:03 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users