Posted 12 February 2012 - 09:32 AM
Here is simple API for helping handling events and also lightweight implementation of vi editor.
Download: https://github.com/p...zipball/release
Github: https://github.com/p...pi/tree/release
vi editor
Simple and lightweight implementation. Made by pro coder for pro coders. ^_^/>/>
Ctrl emulates esc-key.
ComputerPark API
Simple library which includes helpers for event handling, remote logging, helper for redstone signals and optimized bitwise library which is 10x faster than default one.
Needs to have second computer connected with bundle cable.
Download: https://github.com/p...zipball/release
Github: https://github.com/p...pi/tree/release
vi editor
Simple and lightweight implementation. Made by pro coder for pro coders. ^_^/>/>
Ctrl emulates esc-key.
Spoiler
left,right,up,down : move cursor
h,j,k,l : move cursor
/search : search string
n : search same string again
?search : reverse search string
N : reverse search same string again
i : insert
I : insert at start of line
a : append
A : append at end of line
o : insert line bellow cursor
O : insert line above cursor
u : undo
yy, Y : copy line to buffer
p, P : past line from buffer
^, 0 : ho yo begin of line
$ : go to end of line
G : go to last line
1G : go to first line
<n>G : go to nth line
dd : delete line
:w : write file
:q : quit
:wq : write file and quit
:x : write file and quit
:wr : write file and run it
:sh : start shell
ComputerPark API
Simple library which includes helpers for event handling, remote logging, helper for redstone signals and optimized bitwise library which is 10x faster than default one.
Spoiler
Application API
computerpark.callLater(timeout, function)
Calls function later.
timeout: Timeout of seconds
func: function to be called
> function foo() print('bar') end
> computerpark.callLater(5, foo)
> computerpark.callLater(1, function() rs.setOutput('back', false) end)
---
computerpark.handleTimer(timer)
Default handled for timer events. Required for callLater function.
timer: timer events parameter.
> evt, arg = os.pullEvent()
> if evt == 'timer' then handleTimer(arg) end
---
computerpark.main(listener)
Simple main loop with listener suport.
listener: Table of event listeners
> computerpark.main({
> key = function(code)
> print('key:', key)
> end;
>
> default = function(a,b,c,d)
> print('default:', a,b,c,d)
> end
>})
Port helper API
port = computerpark.openPort()
Opens port
> local port = computerpark.openPort('back')
---
port:set()
Set signal enabled.
Redstone:
> port:set()
Bundled:
> port:set(colors.white, colors.red)
---
port:clear()
Clears signal.
Redstone:
> port:clear()
Bundled:
> port:clear(colors.green, colors.blue)
---
port:test()
Test input signal.
Redstone:
> port:test()
Bundled:
> port:test(colors.yellow)
---
port:testOut()
Test output signal.
Bundled:
> port:testOut(colors.gray)
Remote loggerNeeds to have second computer connected with bundle cable.
cp.initLog(side, targetID)
Initializes remote logger.
> computerpark.initLog('back')
or
> computerpark.initLog('back', remoteComputerID)
---
cp.log(message)
Sends log message to remote computer.
> computerpark.log('foobar')
And in the other computer run:
logger
Bitwise API
computerpark.bnot(n)
computerpark.band(a,:P/>/>
computerpark.bor(a,B)/>/>
computerpark.bxor(a,B)/>/>
computerpark.blshift(a,bits)
computerpark.brshift(a,bits)