robhol, on 04 June 2013 - 08:53 AM, said:
- ComputerCraft | Programmable Computers for Minecraft
- → CoolisTheName007's Content
CoolisTheName007's Content
There have been 297 items by CoolisTheName007 (Search limited from 30-March 23)
#123532 debug.traceback in CC! Traceback with file extracts!
Posted by CoolisTheName007 on 04 June 2013 - 10:34 AM in APIs and Utilities
#117147 [1.4.5] NPaintPro
Posted by CoolisTheName007 on 11 May 2013 - 06:47 PM in Programs
#111842 [1.4.5] NPaintPro
Posted by CoolisTheName007 on 19 April 2013 - 11:23 AM in Programs
This is how it looks(freshly installed):
Basically, startup script starts npaint in the monitor, and a running a function parallely to sleep and queue a key event makes sure the init screen of npaint is bypassed. Dirty, but quick!
#108427 Idea Exchange
Posted by CoolisTheName007 on 10 April 2013 - 06:48 AM in General
Engineer, on 27 March 2013 - 12:58 PM, said:
#108426 debug.traceback in CC! Traceback with file extracts!
Posted by CoolisTheName007 on 10 April 2013 - 06:46 AM in APIs and Utilities
#106737 debug.traceback in CC! Traceback with file extracts!
Posted by CoolisTheName007 on 06 April 2013 - 06:05 AM in APIs and Utilities
#100709 debug.traceback in CC! Traceback with file extracts!
Posted by CoolisTheName007 on 23 March 2013 - 03:39 PM in APIs and Utilities
TheOriginalBIT, on 23 March 2013 - 03:18 PM, said:
#100699 debug.traceback in CC! Traceback with file extracts!
Posted by CoolisTheName007 on 23 March 2013 - 03:15 PM in APIs and Utilities
TheOriginalBIT, on 23 March 2013 - 03:06 PM, said:
#100687 debug.traceback in CC! Traceback with file extracts!
Posted by CoolisTheName007 on 23 March 2013 - 03:02 PM in APIs and Utilities
#100603 debug.traceback in CC! Traceback with file extracts!
Posted by CoolisTheName007 on 23 March 2013 - 09:25 AM in APIs and Utilities
#100589 TurtleSim - A turtle simulator sort of thing made in love2d!
Posted by CoolisTheName007 on 23 March 2013 - 08:37 AM in General
#100258 Github repository cloner
Posted by CoolisTheName007 on 22 March 2013 - 12:54 PM in APIs and Utilities
Sammich Lord, on 22 March 2013 - 05:01 AM, said:
I suppose a safe way to do things is to somehow avoid rechecking each repository path.
#100255 debug.traceback in CC! Traceback with file extracts!
Posted by CoolisTheName007 on 22 March 2013 - 12:49 PM in APIs and Utilities
urielsalis, on 22 March 2013 - 12:25 PM, said:
#100175 debug.traceback in CC! Traceback with file extracts!
Posted by CoolisTheName007 on 22 March 2013 - 10:17 AM in APIs and Utilities
Example:
This code
os.loadAPI'debug' --or dofile'debug' debug.override() local function c() error('a') end local function b() c() end local function a() b() endgives, give or take the paths:
(the * counts the nested calls to the error-ing function in a line)
That's it! The functions used are available in the debug table. See 'Mor'e Examples' for it.
You can, for instance, get only the traceback string without throwing an error using debug.traceback(),
and print text one page at a time using debug.step_print(text).
Code
pastebin get YWwLUUpk debug
or here: http://pastebin.com/YWwLUUpk
Mor'e advanced examples:
debug=dofile('debug') function B() print(debug.traceback()) os.pullEvent('key') s='' for i=1,100 do s=s..i..'\n' end very_long_text=s --will wait for user to press keys if the text is too big for the screen debug.printError(very_long_text) os.pullEvent('key')--wait --all in one go: function d() error(debug.traceback('ups!')) end local ok,err=pcall(d) if not ok then print(err) end os.pullEvent('key')--wait --with xpcall: --this catches latent/runtime erros not caused by error() calls: function e() a=''..{} end local ok, err=xpcall(c,debug.traceback) if not ok then debug.printError(err) end os.pullEvent('key')--wait --dev section --however, this fails, but the shell still runs, right till a new function is created I suppose --(don't rerun this test) function c() c() end local ok2, ok, err=pcall(xpcall(c,function(...) end)) if not ok2 then debug.printError(ok) elseif not ok then debug.printError(err) end --[[java vm overflows aren't caught by xpcall xpcall does not destroys the stack before calling the handler function. If the stack is already at max capacity, it won't even accept the handler? Who knows... ]] end function A() B() endA()
External functions used: Kingdaroo's wrap text function, found somewhere. Thanks.
Changelog:
?-separated traceback from error function.
?-file extracts
24/03/13 - toerror function for pcall produced errors (only one level of trace depth).
09/04/13 - now an api, overrides are optional, xpcall is great for catching errors not throwed by error(), but java vm overflows are not catched by it. pcall seems to do fine, but won't get the traceback. My opinion? xpcall, for tracebacks in almost all ocasions.
Future:
Special shell that opens/closes editor based on the error line automatically?
Dev:
xpcall(function() local f,e=loadstring('1\n1') end,print) prints an error message, but returns true. I.e., the error handler is called, but the execution of the function continues.
#99970 Turtle Swarm Quarry v0.3 and master/module APIs
Posted by CoolisTheName007 on 22 March 2013 - 03:31 AM in Turtle Programs
A little bit of pony magic is used to calculate how should it turnlol
#98217 gitget - An updater for ComputerCraft scripts stored on a github.com
Posted by CoolisTheName007 on 17 March 2013 - 01:17 PM in Programs
Yopu, on 17 March 2013 - 12:35 PM, said:
#98175 gitget - An updater for ComputerCraft scripts stored on a github.com
Posted by CoolisTheName007 on 17 March 2013 - 12:00 PM in Programs
Btw, just finished a python script that recursively minifies an entire directory using LuaSrcDiet (locals get replaced by smaller locals, comments stripped, ect) and then packs everything in auto-extracting lua-file. I had to to that because I'm using github for doing an os and their api limits requests to 60 per hour, and one file get = one request, so for many files, like in my case, the downloader I found wouldn't do, neither will this one, I suppose.
#98072 Github repository cloner
Posted by CoolisTheName007 on 17 March 2013 - 06:42 AM in APIs and Utilities
Eric, on 10 January 2013 - 09:15 AM, said:
Guess I'll have to write something to package everything in one file, and then un-package itself. Or see if dropbox behaves the same way.
#97768 [MC 1.7.10 | CC 1.65] OpenCCSensors
Posted by CoolisTheName007 on 16 March 2013 - 11:38 AM in Peripherals and Turtle Upgrades
#97373 rGUI - Easy-to-use GUI library [public alpha/beta]
Posted by CoolisTheName007 on 15 March 2013 - 10:25 AM in APIs and Utilities
One thing I think you could improve is avoiding resuming the computer's coroutine every 0.05 seconds.
#96063 [MC 1.7.10 | CC 1.65] OpenCCSensors
Posted by CoolisTheName007 on 11 March 2013 - 11:12 PM in Peripherals and Turtle Upgrades
Kye_Duo, on 11 March 2013 - 11:49 AM, said:
Watchful11, on 11 March 2013 - 11:39 AM, said:
If redpower is installed, the Sonic Sensor card mk4 returns a "ocs_error" after being called with getTargets. Well, technically the event it throws has "ocs_error" in the first field and the 3rd field is nil, but you know what I mean. This does not happen without redpower. I have tested a few other sensor cards, including lower levels of Sonic Sensor, and they work fine, but I haven't checked all of them.
Reproduced with,
Forge 6.6.2.534
Computercraft 1.5
OpenCCsensors 0.1.4
Redpower 2.0pr6
Apparently, computercraft error handling fails silently on a error message of nil. So whatever program you are running just terminates without an error in this case. I would recommend adding a condition in waitForResponse() for nil events.
I'll look into it asap. A world save would also help.
#95047 Advanced Mining Turtle - Ore Quarry
Posted by CoolisTheName007 on 09 March 2013 - 02:12 PM in Turtle Programs
It is based off an old version of the original.
#94710 ubolt - never loose sight of a mining turtle on server restart
Posted by CoolisTheName007 on 09 March 2013 - 01:08 AM in Turtle Programs
Just get ubolt from
pastebin get bVmtbdsm
( http://pastebin.com/bVmtbdsm )
Run ubolt, and then any turtle program.
When the mining turtle restarts next, it will return approximately to the height where it was when ubolt was run, mining it's way through if necessary.
For instance, works flawlessly with
http://www.computerc...tle-ore-quarry/
Code:
local main_api=[[ --from quarry program local function moveTurtle(moveFn, detectFn, digFn, attackFn, maxDigCount) -- Flag to determine whether digging has been tried yet. If it has -- then pause briefly before digging again to allow sand or gravel to -- drop local digCount = 0 local moveSuccess = moveFn() while ((moveSuccess == false) and (digCount < maxDigCount)) do -- If there is a block in front, dig it if (detectFn() == true) then -- If we've already tried digging, then pause before digging again to let -- any sand or gravel drop if(digCount > 0) then sleep(0.4) end digFn() digCount = digCount + 1 else -- Am being stopped from moving by a mob, attack it attackFn() end -- Try the move again moveSuccess = moveFn() end -- Return the move success return moveSuccess end local function has() return fs.exists'temp_ubolt' end local function save(n) f=fs.open('temp_ubolt','w') f.write(tostring(n)) f.close() end local function get() f=fs.open('temp_ubolt','r') local n=tonumber(f.readLine()) f.close() return n end local old_up,old_down,old_pull_event local function erase() fs.delete'temp_ubolt' fs.delete'startup' turtle.up=old_up turtle.down=old_down os.pullEvent=old_pull_event end old_up=turtle.up turtle.up=function(...) local r=old_up(...) save(get()+(r and 1 or 0)) --print(get()) return r end old_down=turtle.down turtle.down=function(...) local r=old_down(...) save(get()+(r and -1 or 0)) --print(get()) return r end old_pull_event=os.pullEvent os.pullEvent=function(_sFilter) local eventData = {os.pullEventRaw( _sFilter )} if eventData[1] == "terminate" then erase() --print(get()) printError( "Terminated" ) error() end return unpack(eventData) end if not has() then save(0) end ]] local args={...} if #args>0 then if args[1]=='reset' then main_api=main_api..[[ erase() ]] setfenv(loadstring(main_api),getfenv())() else print([[ Usage: ubolt reset ]]) end return end setfenv(loadstring(main_api),getfenv())() local s=fs.open('startup','w') s.write(main_api..[[ if has() then repeat if get()<0 then moveTurtle(turtle.up, turtle.detectUp, turtle.digUp, turtle.attackUp, math.huge) elseif get()>0 then moveTurtle(turtle.down, turtle.detectDown, turtle.digDown, turtle.attackDown, math.huge) end until get()==0 end erase() ]]) s.close()
For advanced users:
This programs deletes any startup file you may have.
After going to the initial position, it resets itself by deleting the temporary file temp_ubolt and the startup file.
Terminating any program while running ubolt will reset ubolt.
You can also reset ubolt by running:
ubolt reset
This is a temporary solution for state loss during chunk reloads; it has been reported that there is random loss of movements, e.g. any scheme of movement-saving movement is due to miss steps.
y-state is less sensible to loss of steps: +1/-1 height difference from the starting height won't hinder your ability to find it...much. But missing a turn and going right instead of front is more problematic, so I ignored it.
The perfect solution is GPS and matching position and orientation to state, but for my situation it seemed overkill.
#90736 [MC 1.7.10 | CC 1.65] OpenCCSensors
Posted by CoolisTheName007 on 24 February 2013 - 09:39 AM in Peripherals and Turtle Upgrades
#90486 [MC 1.7.10 | CC 1.65] OpenCCSensors
Posted by CoolisTheName007 on 23 February 2013 - 12:17 PM in Peripherals and Turtle Upgrades
Kye_Duo, on 23 February 2013 - 05:49 AM, said:
1. I can't get it to work with the sensorview program, is this a bug or can it not work with that program?
2. Can it detect liquids through a block or two? I'm trying to help setup a sensor that can detect when its safe to raise a piston that is being used to create a pit under a lava fall to prevent the lava from spreading all over the place and lava is notorious for not taking the same amount of time to completely drop from the ceiling once the fall has been shut off.
About 1. : the sonic sensor has many targets (all blocks visible, for a certain definition of 'visible'); sensorview call getTargetsDetails for each, which results in no new intel, but each call takes a tick, so there should be some lag. That's my first attempt at an explanation.
About 2: due to the compact way I implemented it, diagonals are always visible (e.g. (1,1,1) ). So you could check for those, e.g.: wrapped_sensor.getTargetDetails()['1,1,1'] , and still the sensor wouldn't be touching lava. But they are lava-resistant, right? So I guess you want the sensor to be invisible.
It is interesting to let them have a certain see-through power, more than the accidental one, maybe based on the sensor upgrade level.
Also, what do you think about distinguishing between lava and water?
- ComputerCraft | Programmable Computers for Minecraft
- → CoolisTheName007's Content