Jump to content


Wobbo's Content

There have been 24 items by Wobbo (Search limited from 10-February 22)


By content type

See this member's

Sort by                Order  

#159548 CC-Logging, a logging API

Posted by Wobbo on 06 January 2014 - 04:31 PM in APIs and Utilities

CC-Logging provides a simple API for logging in ComputerCraft Lua that is based of Lua Logging. It currently supports logging to a function and to a file. Both can be provided by the user. The file should be closed after use automatically.

The documentation can be found here.

Usage example:
os.loadAPI("logging")
local logger = logging.new{func = function(self, level, message)
  print(level..": "..message)
end,
file = "log.log"}

logger:info("Opened log file")

Download:
The file can be fetched from my Github repo here or from pastebin: LeNqT36Q

If you have any questions, feel free to ask them here.

You can use this wherever you want, but it would be nice if you give me credit.



#158570 (Kind of) Slotmachine help?

Posted by Wobbo on 30 December 2013 - 03:28 PM in Ask a Pro

You could also use wired modems on each computer and connect them all to a disk drive. Then you could create one file per user that each slot machine can acces. This file could simply be a serialised table with the amount of spins left and all the other data you would like to store.



#158531 What Are The Most Common Languages On The Forums/of Cc Users?

Posted by Wobbo on 30 December 2013 - 10:14 AM in General

View Postoeed, on 07 September 2013 - 05:23 AM, said:

View PostGravityScore, on 07 September 2013 - 05:13 AM, said:

How is this going to work for developers who submit apps? Do we have to localise our own descriptions/app name/app/etc (I assume so)? This doesn't seem to be of great use since the vast majority of the content in the app store is submitted, meaning that unless you want to get an army of translators to translate everything that goes into the app store, it's a bit pointless because most of the stuff seen by people in different languages will just be in English (apart from headings).

On topic: English only for me :)

No no, I mustn't have made this clear enough, I'll change the main description.

This is only for the website and (possibly) the app store app. Localisation is something that developers will have to do themselves.

But wouldn't it look odd if the description is in English while the rest of the site is in, for example, Dutch?

I know from experience that is annoying if the Finder is in English, while Midnight commander uses Dutch as default language.



#157904 Sudo Bash

Posted by Wobbo on 24 December 2013 - 06:28 AM in Ask a Pro

There are some shells/OSes that allow for piping, like Leadlined OS and Project NewLife, so it is possible to do piping.

Also, I created a small grep utility here. It uses Lua regex and supports almost all POSIX options(and silently accepts the rest)

​EDIT: found lik to project newlife.



#157448 Cc Grep

Posted by Wobbo on 20 December 2013 - 04:02 PM in Programs

No, without piping it isn't that much use. But you could use it to look up where you use variables.

But there are some shells/OSes that do allow for piping, for example Leadlined OS and Project NewLife both support piping. There might be more.



#155687 [Grapher] CC Graphing Utility

Posted by Wobbo on 09 December 2013 - 02:27 PM in APIs and Utilities

I took some time to play with it, and noticed that ^+s is a bad combination to move around the plane, my computer keeps shutting down.

Also, it would be nice if there would be a grapher API that would display graphs on the screen. I could see a gnuplot like program that would use this as a plotting device.



#155429 [Grapher] CC Graphing Utility

Posted by Wobbo on 07 December 2013 - 08:28 AM in APIs and Utilities

If you mean this: http://en.wikipedia....plicit_function kind of implicit function, that looks like a constraint satisfaction problem to me. In that case, I know of some algorithms to solve this.
If that is what you meant, I would like to join forces. I know quite a bit about math as well.



#154960 Lua: What would you change?

Posted by Wobbo on 03 December 2013 - 05:09 AM in General

I would like a switch statement that isn't a function with a lookup table. There are ways around needing one, obviously, but it would be nice to have one if you have a lot of states, for example when checking for command line arguments.

I haven't really had the need to use one yet, but I think it would make checking for keys a lot easier. And if it used a lookup table underneath, also faster.

View Posttheoriginalbit, on 02 December 2013 - 09:30 PM, said:

  • data type checking function foo(string bar) why: I hope this is fairly obvious
  • default parameter values function foo(string bar = "none") why: I hope this is fairly obvious too, its one of the only parts of Python that I like

1. Type checking is possible: http://lua-users.org...LuaTypeChecking
2. I would like to have this as well, and it can be achieved by creating a function that dynamically calls other functions. The wrapper function would have a closure with defaults and the order of the arguments, and it would call the function accordingly. Not really what you are looking for, but it is better than nothing.
Spoiler



#154148 Leadlined-Kernel: A Mostly Experimental Kernel

Posted by Wobbo on 26 November 2013 - 01:47 PM in Operating Systems

I got the system working now, and when I try to open /docs/api_documentation.txt using edit, I get a No permissions stored for user error. I can open the file when I log in as root.



#153718 Leadlined-Kernel: A Mostly Experimental Kernel

Posted by Wobbo on 22 November 2013 - 04:33 PM in Operating Systems

It boots now, but I noticed a problem. It only asks for a root password after you have pressed a key.

And after you have entered the password for the normal account for the second time, he comes up with an error:
Fatal error: sys/svcs/userAuth:212: attempt to call nil



#153712 Cc Grep

Posted by Wobbo on 22 November 2013 - 04:09 PM in Programs

This is an implementation of (almost) POSIX grep for computer craft. It uses Lua regular expressions for matching, and this is the only difference between my version and a POSIX complaint one, as far as I can tell.
It is my first real program in Lua.

Grep looks for occurrences of patterns in files. If it finds one, it prints the line that it occurred on. As said before, the patterns are lua regular expressions. The program is called like this:
grep pattern files
Where pattern is one pattern and files is a list of one or more files.
Multiple patterns can be specified like this:
grep -e pattern -e pattern files
Patterns can also be read from a file:
grep -f patternfile files
grep -e pattern -f patternfile files
grep -f patternfile -f patternfile files

-F turns on plain matching, aka no character will be seen as magic. -i makes grep ignore case in patterns. -x makes patterns only match if they match the whole line. -v inverts grep's behaviour, it will only print lines that do not match the specified pattern.

-n prints a line number in front of the matching line, while -c only prints a count of matching lines.

-l prints the name of the searched file only once when a pattern has been found.
-s stops the printing of file not found errors.

-E and -q are quietly accepted, but don't do anything (actually, -q works, but os.run doesn't return the correct values)

Grep can be found here or installed using pastebin:
pastebin get E1PNzrA2 grep

If you find any bugs/inconsistencies please reply in this thread.



#153690 Leadlined-Kernel: A Mostly Experimental Kernel

Posted by Wobbo on 22 November 2013 - 11:24 AM in Operating Systems

I am getting a different error when I boot.

Fatal error: init:280: Could not load API: init 88:[string "sys/svcs/async_crypto"]:111: '}' expected (to close '{' at line 106)

I get this error after I installed it on a newly placed computer.



#152188 LuaLua - OOP Programming Language for CC. NEW - Anonymous Function Syntax

Posted by Wobbo on 07 November 2013 - 12:40 PM in Programs

This is looking really nice! It reminded me of Obj-C before I saw it was modelled after it :P
As a name change, may I suggest Objective-Lua? Since it is so heavily inspired on Objective-C.



#152173 Api/app For Ip.board Notifications

Posted by Wobbo on 07 November 2013 - 10:29 AM in Forum Discussion

View Postoeed, on 12 September 2013 - 05:27 PM, said:

View PostCranium, on 12 September 2013 - 09:55 AM, said:

There is no app to do this, as each iteration of IP.Board is different, depending on the configurations. You can however change your settings to email you upon certain notifications.

I see. I am aware that I can be emailed, it just ends up cluttering my inbox. I might just make a folder for it if I can't find a better way.
If you use Mail.app, you could write a Mail rule that fires an Apple Script. You could probably send a notification out that way, although you maybe need to use Cocoa to get it to work properly.
After you are done with the mail, you could automatically trash it or move it to a different mailbox.



#152158 How to carry over variables to programs

Posted by Wobbo on 07 November 2013 - 08:25 AM in Ask a Pro

You could do:
local y = 1
local env = {y = y}
os.run(env, 'test')
Now test should have y visible, but I haven't tested this. I believe that in this case, the variable does not get carried back over to the main program, because only the value is passed and not the variable itself. I am not sure though.

Also, like Lyqyd says, it is probably better to write an API instead of using this trick.



#151864 Netprint, An Api For Easier Printing While Using Network Cables

Posted by Wobbo on 04 November 2013 - 01:39 PM in APIs and Utilities

Good to hear that it worked for you ;)

I have updated the API, you don't have to call init() before you can use it anymore. I also added version(), print() and wrapPrint().
print() and wrapPrint() do the same as write() and wrapWrite() but set the cursor position at the first position in the new line.



#151741 Leadlined-Kernel: A Mostly Experimental Kernel

Posted by Wobbo on 03 November 2013 - 04:21 AM in Operating Systems

Will you also implement io.popen when the redirection works? Then we could have a more complete io API and with the pipes it should be possible.

And how will the function get its input? Using read/write or with its function call or something?

I do ask a lot of questions, but that is because I am hyped to see an OS with actually IO redirection. I have been looking for this, to the point where I was planning my own OS.



#151673 Netprint, An Api For Easier Printing While Using Network Cables

Posted by Wobbo on 02 November 2013 - 02:37 PM in APIs and Utilities

Hello everybody,

I have written an API for easier printing when you have multiple printers in a network. It is not entirely done yet, but it should be useable.

It works by having one printer designated as the active printer, and it will forward all the print functions you call to this printer. The API supports all the functions of the native printer API. It is possible to manually or automatically select a printer as active printer. By default, it selects the printer that can print the most pages.

The API also allows the user to give labels to printers. This way, you can easily access printers, since you can give them a meaningful name.

The code can be found on pastebin: http://pastebin.com/Sg10An9P

The API selects a printer as active printer using the function comp. It takes two printers. It is possible to override this method if you want a different way to select printers. You can also set the active printer with setActivePrinter.

Labels are set using the setPrinterLabel, this function first takes the name of the printer in the network, followed by the label. The labels get stored in print.conf on your computer. If you want to change this, you can edit the variable config in the API.

Before you can use the API, you have to call the function init(). This function looks for printers in the network and makes sure one of them is designated as active printer. If you have used the API before, he will use the one you used last time. Otherwise, he will automatically select a printer among the network.

It is also possible to get a table with all the printers in the network, including the ink and paper levels. This can be done by using getPrinterTable for a table, and getPrinterTableString for a badly formatted string.

In combination with the standard printer API functions, a function called wrapWrite was added that prints the string it gets and makes sure it doesn't run of the page.

The API is not entirely done yet, I would like to add more comments in the code and do some minor improvements, but it should be useable. If you find any bugs or have any question on how to use it, please reply to this tread.



#151639 Leadlined-Kernel: A Mostly Experimental Kernel

Posted by Wobbo on 02 November 2013 - 10:40 AM in Operating Systems

View PostKillaVanilla, on 02 November 2013 - 10:14 AM, said:

View PostWobbo, on 02 November 2013 - 05:43 AM, said:

This is looking good! I am interested in seeing where you are going to take this.
IO redirection is something I wanted in an OS, are you going to make it work like UNIX pipes? So multiple commands in one line? Or API calls?

I did find some bugs however. Whenever I log in on a Advanced computer, the windows for logging in don't line up. This is not really a bug, but it does look weird.

Secondly, whenever I try to see what is in sys/filePerm, I get a bin/shell:526: attempt to get length of nil
I can cd into /sys/filePerm however. I should note that I am not logged in as root.
When I do log in as root, it just works.

When I am in the directory sys and want to look at apis(for example) I get a Not a directory error. When I type ls /sys/apis, it does work.

Also, if you try to shutdown the computer using exit, it just hangs.

But it looks really good. I will follow this OS.
I/O redirection will work like UNIX pipes.

About using exit: the "exit" function actually just causes the /bin/shell program to exit, it doesn't actually shutdown the computer; this will be changed.
I will look into the other bugs; they're mostly issues with the fs function overrides. Some of them are actually not supposed to be bugs; attempting to look into another user's directory without the read permission for that directory will return what appears to be an empty directory. The fact that the functions return nil instead of an empty table or an error is a bug.

Neat. How are you going to redirect the IO? just overwriting read/write to read from/write to files? Or do you have a better approach?

I already guessed it had something to do with permissions. Instead of looking like an empty directory, it might be better to give a warning. Darwin(OS X) gives a Permission Denied error when you try to look into roots home directory for example.



#151633 Old Snorrful OS [Discontinued]

Posted by Wobbo on 02 November 2013 - 08:25 AM in Operating Systems

View PostOptimusSnorr, on 02 November 2013 - 07:54 AM, said:

View PostWobbo, on 02 November 2013 - 05:59 AM, said:

-snip-

Alright, when you say launch to guy, what do you mean guy?
Anyway, I never got around to hiding the registration password... :P

gui >.< Can you get into the gui after you boot into the SHELL? Except for running startup again off course.



#151615 Old Snorrful OS [Discontinued]

Posted by Wobbo on 02 November 2013 - 05:59 AM in Operating Systems

View PostOptimusSnorr, on 01 November 2013 - 01:49 AM, said:

View PostWobbo, on 31 October 2013 - 03:19 PM, said:

-snip-

I'm working on it with Gvin (I think).

I am interested in seeing how you will get it to work.

Also, I downloaded your OS, it looks good. However, when you create a new account and type in your password, it shows what you typed in. It doesn't do this with login, so it is just a minor issue.

Also, when you boot into SHELL, can you launch to guy by hand? or is that impossible?



#151613 Leadlined-Kernel: A Mostly Experimental Kernel

Posted by Wobbo on 02 November 2013 - 05:43 AM in Operating Systems

This is looking good! I am interested in seeing where you are going to take this.
IO redirection is something I wanted in an OS, are you going to make it work like UNIX pipes? So multiple commands in one line? Or API calls?

I did find some bugs however. Whenever I log in on a Advanced computer, the windows for logging in don't line up. This is not really a bug, but it does look weird.

Secondly, whenever I try to see what is in sys/filePerm, I get a bin/shell:526: attempt to get length of nil
I can cd into /sys/filePerm however. I should note that I am not logged in as root.
When I do log in as root, it just works.

When I am in the directory sys and want to look at apis(for example) I get a Not a directory error. When I type ls /sys/apis, it does work.

Also, if you try to shutdown the computer using exit, it just hangs.

But it looks really good. I will follow this OS.



#151436 Old Snorrful OS [Discontinued]

Posted by Wobbo on 31 October 2013 - 03:19 PM in Operating Systems

View PostOptimusSnorr, on 30 October 2013 - 08:56 AM, said:

View PostGvin, on 30 October 2013 - 08:53 AM, said:

View PostOptimusSnorr, on 30 October 2013 - 08:39 AM, said:

At the moment, it's there just for custom wallpapers. But in the next release it will store texts from a word processor and pictures from paint. I'm also trying to make each secure.
Its sad that there is no possibility to prevent some things like autolaunching the "startup" file from the disk before the main "startup" file. If it were possible you could realy make user folders secure inside your system. But because of this I see the only way to implement this - encryption! Or maybe you've found another solution?

I've given it a lot of thought, I thought something like, if the folder name matches the current user (API set from login) then it'll allow him to go in, otherwise kick him out.
But I can't think of a way to prevent it from the Windows Explorer or whatever you use.

You could build a large table that has permissions for each file/folder. Then you would need to inject a lot of functions to see is the current user is allowed to open a file using that table. It isn't really practical, but it could work.

Another, similar approach would be to store a serialised, encrypted table in each directory with the permissions, but you would have to load that table each time a file is accessed. But encryption is probably the best way to go indeed.

If you only check for home folders, it would be impossible for users to change system wide settings. I haven't tried your OS yet, but it doesn't sound like a wanted feature.



#151420 [Open Source] PearOS (Preview 2) - OS X Inspired OS

Posted by Wobbo on 31 October 2013 - 10:28 AM in Operating Systems

If you would want a real OS X feel to your system, don't provide support for anything else then a terminal emulator. That is how Apple does it.

It is pretty easy to get Unix/Linux utilities up and running, but Apple has nothing to do with that(aside from web hosting). There are some package managers, and XQuartz(X11 if you got it with your mac) as a window system, but both are updated and build by volunteers. So if you want support for other programs and do it the way Apple does it, just include a terminal emulator that runs CraftOS in a window. Then people can run the unsupported programs that way.