dlcruz129, on 24 November 2012 - 07:33 AM, said:
- ComputerCraft | Programmable Computers for Minecraft
- → MysticT's Content
MysticT's Content
There have been 177 items by MysticT (Search limited from 10-February 22)
#56770 term.clearLine() EVOLVED
Posted by
MysticT
on 05 December 2012 - 11:53 AM
in
Suggestions
local function clearPart(x1, x2, y)
term.setCursorPos(x1, y)
term.write(string.rep(" ", (x2 - x1) + 1))
end
#56781 How do I download a binary file?
Posted by
MysticT
on 05 December 2012 - 12:09 PM
in
Ask a Pro
local response = http.get("https://www.google.com/images/srpr/logo3w.png")
if response then
local sResponse = response.readAll()
response.close()
local file = fs.open("file.png", "wb")
for i = 1, #sResponse do
file.write(string.byte(sResponse, i))
end
file.close()
end
#65144 [Question]Other programming languages?
Posted by
MysticT
on 28 December 2012 - 03:43 AM
in
Ask a Pro
Aquilamo, on 28 December 2012 - 03:16 AM, said:
Writing an entirely new mod would make it easier to write the interpreter (you can use an existing one), but you have to make the mod, including the blocks, items, etc. and all the network handling.
Conclusion: just stick to lua
#65149 Turtles not working
Posted by
MysticT
on 28 December 2012 - 03:57 AM
in
Ask a Pro
test.test2()brackets are important, otherwise it will just return the function (the actual function, not it's result).
When you run it, nothing happens because you are not calling the function. Try adding:
test2()at the end of the file.
Also, if you want to make a program, don't put it in the apis directory, that's for apis. Place it in the programs directory or the root of the computer/turtle.
#65184 Turtles not working
Posted by
MysticT
on 28 December 2012 - 05:27 AM
in
Ask a Pro
TheOriginalBIT, on 28 December 2012 - 03:59 AM, said:
Quartiz, on 28 December 2012 - 04:16 AM, said:
TheOriginalBIT, on 28 December 2012 - 03:55 AM, said:
the reason that it says function: random numbers is not actually an error, it is doing a tostring( ) on the function and actually telling you its reference/location in memory, hence the numbers differing each time
hope this helps
function test2() -- do something end test2() -- call the function so it actually does something
#65299 CC 1.48 CCReadImage
Posted by
MysticT
on 28 December 2012 - 12:17 PM
in
Peripherals and Turtle Upgrades
#69813 CC 1.48 CCReadImage
Posted by
MysticT
on 06 January 2013 - 06:50 AM
in
Peripherals and Turtle Upgrades
table[2][4]You are using strings right now, so you have to access the values like
table["2"]["4"]So, this would be java-side:
Map<Integer, Map<Integer, Integer>> map = new TreeMap<Integer, Map<Integer, Integer>>();
for (int x = 0; x < width; x++) {
Map<Integer, Integer> xMap = new TreeMap<Integer, Integer>();
map.put(x, xMap);
for (int y = 0; y < height; y++) {
xMap.put(y, image.getRGB(x, y) & 0x00FFFFFF)
}
}
Then you can use it like you wanted in lua:local rgbValues = imageApi.getValuesRGB()
print("Size: ", #rgbValues)
print("First value: ", rgbValues[1][1])
#69869 BSoD Fail
Posted by
MysticT
on 06 January 2013 - 09:28 AM
in
Ask a Pro
nutcase84, on 06 January 2013 - 03:12 AM, said:
x, y, button = getMouseClick() if x >= xlocation and x <= x1 and y == ylocation then --item1 shell.run(item1cmd) endThis does not work. It gives me a nil at shell.run. why?
(I have the getMouseClick function and the item1cmd var.)
#70867 Use functions in tables
Posted by
MysticT
on 08 January 2013 - 01:58 PM
in
Ask a Pro
action = function() redirect("smartpaste.com/home") end
it works the same way, just saving a few lines.I would still recommend using the method TheOriginalBIT said in some cases. If you are going to use the same function somewhere else, it's better to define it before and then assign it where needed.
#75354 [Solved] "Non-blocking" os.pullEventRaw()
Posted by
MysticT
on 16 January 2013 - 02:19 PM
in
Ask a Pro
Your workaround (starting a timer to fire an event) should work (you could also queue a fake event so it doesn't wait for the timer), but note that it would make computers lag a lot (if there's more than one computer in the world).
Why would you want to do it anyway? there's no need to, you just have to make the "threads" work like that (wait for an event then act accordingly).
#75372 [Solved] "Non-blocking" os.pullEventRaw()
Posted by
MysticT
on 16 January 2013 - 03:14 PM
in
Ask a Pro
RunasSudo, on 16 January 2013 - 02:38 PM, said:
When one of my threads runs coroutine.yield("mouse_click") for example, my API needs to not resume it again until it has pulled a mouse_click event. In the meantime, however, it should still be running other coroutines. This implementation, however, does not let any other coroutines run until it has pulled said event.
I have a window manager that spawns two threads. One updates a clock, and one waits for a mouse_click, then exits the program. With this implementation, it does not run the clock-updating function until an event has been pulled. Not what I want to happen. When I use the parallel API to run both functions at the same time, it works.
RunasSudo, on 16 January 2013 - 12:09 PM, said:
I want the while true loop to continue regardless of whether an event has been fired.
For what I see, that code should work. Can we see the code you use to start the threads and what they run maybe?
#83294 [Question] how to check if a variable is even or odd
Posted by
MysticT
on 03 February 2013 - 10:04 AM
in
Ask a Pro
ikke009, on 03 February 2013 - 07:42 AM, said:
so 1 % 4 and 5 % 4 would both yield 0.25
#83368 Attempt to index....?
Posted by
MysticT
on 03 February 2013 - 12:42 PM
in
Ask a Pro
this should work:
function ReadDir(dir)
local dateien = fs.list(dir)
for i = 1, #dateien do
local path = fs.combine(dir, dateien[i])
if fs.isDir(path) then
ReadDir(path)
end
check(path)
end
end
#84406 Cyclic Redundancy Checks (Aka Crc)
Posted by
MysticT
on 06 February 2013 - 12:26 PM
in
APIs and Utilities
Imgoodisher, on 06 February 2013 - 12:07 PM, said:
data = {"a", "b", nil, "c"}
(it would loop 2 times, not 3)#91091 LuaJ 3.0
Posted by
MysticT
on 25 February 2013 - 11:42 AM
in
Suggestions
Are there any plans to update LuaJ to 3.0? It has support for lua 5.2, wich would be really nice.
I think it's still in alpha, but I had no troubles with it so far.
Or are you still planing to remove LuaJ and use native libraries? I know this is a requirement to use the pluto library, wich is needed to add persistance.
#91122 LuaJ 3.0
Posted by
MysticT
on 25 February 2013 - 01:49 PM
in
Suggestions
- ComputerCraft | Programmable Computers for Minecraft
- → MysticT's Content


