Jump to content


MKlegoman357's Content

There have been 76 items by MKlegoman357 (Search limited from 10-February 22)


By content type

See this member's


Sort by                Order  

#254783 GUI API doesent work

Posted by MKlegoman357 on 25 June 2016 - 12:58 PM in Ask a Pro

View PostWilma456, on 25 June 2016 - 12:44 PM, said:

View PostKingofGamesYami, on 25 June 2016 - 12:13 PM, said:

--Exampele
--Best way to call the func test
function test()
print("test")
end
os.loadAPI("/lib/gui")
gui.createScroll("Hello")
gui.addScrollFunc(test,"hello",1) --#this passes the actual function, rather than a string, as an argument.
gui.createScroll("world")
gui.addScrollFunc("print","world",1)
gui.drawScroll()
This doesent works

How are you using the argument (function)?



#254688 A Rather Dapper Mapper – 'Satellite' GPS Maps!

Posted by MKlegoman357 on 24 June 2016 - 08:07 AM in Programs

Cannot test it right now but as I understand the turtle reports all the info to the server which actually stores the map? If so does that mean I can use multple turtles at once to speed up scanning?



#254577 [Results in!] CCJam 2016

Posted by MKlegoman357 on 23 June 2016 - 07:53 AM in General

 TheRockettek, on 23 June 2016 - 07:26 AM, said:

It starts at the beggining of friday @ UTC+1 (UK TIME) ;p

UTC+0 actually.



#254553 [Results in!] CCJam 2016

Posted by MKlegoman357 on 22 June 2016 - 09:29 PM in General

In which timezone does the competition start. Because the live counter says there's 1 day and 22 hours left, but for me after 23 hours it will be Friday. May I suggest the GMT timezone? Since it's the one and only GMT+0 timezone :D.



#254551 Converting KEYCODE into CHARACTER

Posted by MKlegoman357 on 22 June 2016 - 09:09 PM in Ask a Pro

View PostTechnicalCoding, on 22 June 2016 - 06:54 PM, said:

View PostLyqyd, on 22 June 2016 - 04:55 PM, said:

You could not use a filter when pulling events, allowing you to handle both char events for typed characters and key events for control keys. This is what the read function does.
I have tested this and it works perfectly... It gets the pressed key id/code and it finds the name of it..

But this will not detect whether the letter written should be upper case or not (by holding shift button or caps lock). Also, numbers won't work. And if someone will be using a keyboard with a different layout then they won't be able to write anything. You should simply remove the event filter and use both: "key" and "char" events. Using the "key" event for backspace and enter and "char" event for any text characters. Oh, and there's also the "paste" event which you could add support for.



#254522 [Results in!] CCJam 2016

Posted by MKlegoman357 on 22 June 2016 - 05:05 PM in General

So I guess I should post this here in case I come up with ideas. I'm in!

GitHub repo



#254442 Full Lua library support and a few more suggestions

Posted by MKlegoman357 on 21 June 2016 - 08:52 PM in Suggestions

I never really understood this: why CC's Lua does not have full support for Lua libraries. I can understand why such libraries (debug, package system, io, os) were disabled, but I couldn't think of a reason of (other than the debug library) rewriting those libraries either in Java or Lua side with a bit more sandboxing in place. Most of the mentioned libraries and their functions (with the exception of debug library) can be rewritten in CC right now, so why don't we have support for them yet?

And why would I actually want "native" Lua support? As most of CC users who want the same: there are a bunch of already written programs and libraries for Lua which could easily be loaded and used inside of CC if only we had the "native" Lua support.




For other suggestions. These are a few suggestions that didn't get negative feedback and got no comment/got positive feedback from Dan:

Http enhancements - the solution would be to add a new xhttp library and having the http library simply a wrapper around xhttp.

Selecting a color palette - a way to expand the current colors without the "program changing the colors of a windowed OS" problem.

File seeking - something that would allow my above suggestion to fully implement io library.

Why doesn't CC have the require function and the Lua package system - partly my suggestion which didn't really talk about a solution.



#254431 Argser - parsing program arguments with ease

Posted by MKlegoman357 on 21 June 2016 - 07:34 PM in APIs and Utilities

View PostCrazedProgrammer, on 21 June 2016 - 05:25 PM, said:

Very nice! :D
My suggestion would be that you make some small code changes so people can copy+paste this into their program (I know this is very simple, but it's nice :P), so they don't have to have an external file.

I was actually thinking of doing this, but was too lazy to actually do something myself. You know, literally change two lines in this API :P. But I guess that's what makes a good programmer - being lazy :D.




Anyway, I updated the code so now it only contains a single function which you can copy-paste into your own program. The function is called "argser()" by the way and it does exactly the same as if you were to load the API like this:

local argser = dofile("argser")



#254378 Argser - parsing program arguments with ease

Posted by MKlegoman357 on 21 June 2016 - 11:41 AM in APIs and Utilities

View PostIncinirate, on 21 June 2016 - 12:29 AM, said:

Nice! I'm always too lazy to implement actual terminal arguments like this. :P

That's the reason I made this. Got tired of writing the same argument handling logic in every program.




I updated the API. There was a bug where if the API was given an undefined named argument it would crash. And yes, it will parse any undefined arguments. By default switches can have no values and named arguments can optionally have a string value. Running this program:

print(textutils.serialize(
  dofile("argser")(...):parse().args
))

...using these arguments:

1 bar -switch --named1 --named2=foo 3

...would print this onto the screen:

{
  "1",
  "bar",
  "3",
  switch = true,
  named1 = true,
  named2 = "foo",
}



#254320 Argser - parsing program arguments with ease

Posted by MKlegoman357 on 20 June 2016 - 02:39 PM in APIs and Utilities

Argser

pastebin get 3jkDVune argser


This is an API I wrote to help with parsing program arguments. It's made to process such things like switches (myprogram -a -b valueforb anothervalueforb) and named arguments (myprogram --named1=valuefor1 --named2), as well as simple "normal" arguments (myprogram arg1 arg2 arg3). It can also automatically convert the passed arguments to certain Lua types and preprocess them using custom functions.

Loading the API

To load the API you can use dofile() function (os.loadAPI() will not work):
local argser = dofile("argser")

Documentation

The API returns a single function to which you pass the program's arguments, setup all the switches, named arguments, value types, defaults and aliases, and parse the arguments. The parsed arguments are then returned in a table which you can then use to get the arguments.

Example

Parser methods and variables

Changelog

Licensing
You can use and edit this API as much as you want. I only ask that you don't start redistributing it as if it was your own API.



#254189 CCEmuRedux Character Sheet

Posted by MKlegoman357 on 18 June 2016 - 10:06 PM in General

I'm not really sure about the usefulness of signs such as 180 (´ - Acute accent - spacing acute) and 184 (¸ - Spacing cedilla). Where exactly would you use them? They're quite specific to my mind and maybe could be replaced with some more usable and generic

BTW, I noticed that the characters 238 and 206 look like nice torches.



#254177 CCEmuRedux Character Sheet

Posted by MKlegoman357 on 18 June 2016 - 08:24 PM in General

Oh, I see. Well, a euro sign (€) would be useful to have as another very common currency.



#254143 CCEmuRedux Character Sheet

Posted by MKlegoman357 on 18 June 2016 - 12:09 PM in General

I see a bunch of duplicate characters, like 20 and 182 or 0 and 9 and 10 and 13 and 128, which could be used to expand the character set even more.

EDIT: 21 and 167.



#254011 CCEmuRedux Character Sheet

Posted by MKlegoman357 on 17 June 2016 - 03:55 PM in General

View Postbauen1, on 17 June 2016 - 03:32 PM, said:

CC has a lot of unicode or something characters, a map of those chars would also be nice :)

This is the map those characters.



#253825 [Results in!] CCJam 2016

Posted by MKlegoman357 on 15 June 2016 - 02:25 PM in General

Just because it has already been done doesn't mean you cannot redo it better, with more features and what not..



#253731 A question about compiling/bundling files together....

Posted by MKlegoman357 on 13 June 2016 - 11:34 PM in Ask a Pro

It doesn't compress. The "size" property is the number of bytes the file contains while the "size on disk" property is the number of bytes the file is taking up on the actual drive. You can read about this more here. Basically the actual file size increases but it takes less bytes to store one bigger file than a bunch of small files.



#253311 Speadersheet program - updated!

Posted by MKlegoman357 on 08 June 2016 - 12:01 PM in Programs

View Postrandomdude999, on 07 June 2016 - 06:50 PM, said:

Some new laptop keyboards don't even have an insert key. (For example my laptop (came preinstalled with win7))

All keyboards have an insert key. It might be hidden as a function key (fn). Or it's name might be shortened to something like "ins".



#253059 Writing multifile lua programs

Posted by MKlegoman357 on 05 June 2016 - 09:00 AM in Ask a Pro

You should first decide how you'll want to load these files. My personal preference would be to use dofile, loading files which return a table of functions. Next you'll want to use shell.getRunningProgram together with fs.getDir to find out the root directory of your program, so you could load your files relative to your program's location. And then you'll have to figure out how you'll want to distribute your program. There are plenty of programs which allow you to pack a bunch of files together so you could put the single packed file onto pastebin. Just search for them in Programs/APIs and Utilities subforum.



#252781 remove spaces between strings?

Posted by MKlegoman357 on 01 June 2016 - 09:29 PM in Ask a Pro

That's because in the latest CC versions print() was changed to add spaces between each argument. Just concatenate the strings to remove the space:

print(shell.dir() .. ">")



#252652 String, optional captures

Posted by MKlegoman357 on 31 May 2016 - 12:02 PM in Ask a Pro

Like I mentioned before, what's the rest of the code that is erroring?



#252606 String, optional captures

Posted by MKlegoman357 on 30 May 2016 - 08:03 PM in Ask a Pro

We should probably start with: what's the error you're getting? This code:

local function foo (str)
  for str, pattern in str:gmatch('(.-)(%b[])') do
    print(str, pattern)
  end
end

foo('a string [/*-] a string [-*/] a string')

Runs perfectly fine for me: as expected returns only the first two matches. It's probably the <CODE> part that is actually erroring.



#251901 :/ Bloody ISP

Posted by MKlegoman357 on 22 May 2016 - 05:44 PM in General

View PostWaitdev_, on 21 May 2016 - 11:12 PM, said:

You might aswell just use a VPN whenever it's not working, or maybe private browsing mode? I'm not sure if that changes it but I do know that it spoofs your IP

No it doesn't. It simply doesn't save any local stuff, like Cookies or Session Storage.



#251896 CraftOS 2.0 - Dan's Secret Project

Posted by MKlegoman357 on 22 May 2016 - 04:27 PM in General

Also, looks like the OS is called CraftOS 2.0, but the game is CCNext. Or not. :D



#251249 What happened to the forums?

Posted by MKlegoman357 on 01 May 2016 - 07:30 PM in Forum Discussion

Also, is posting a problem that it needs approval? I wonder what the actual moderators think about this, there will be a lot more work for them and the forums will slow down, because of slower reply rates.

And I cannot edit my post yet (which should be above this one) because it's not approved yet, which is a bummer.



#251248 What happened to the forums?

Posted by MKlegoman357 on 01 May 2016 - 07:27 PM in Forum Discussion

What..?

Posted Image