- Sky
- Blueberry
- Slate
- Blackcurrant
- Watermelon
- Strawberry
- Orange
- Banana
- Apple
- Emerald
- Chocolate
- Charcoal
-
Content Count
451 -
Joined
-
Last visited
-
Days Won
35
Everything posted by Molinko
-
Key presses are events. You need to yield (i.e event.pull ) to catch them. Try this.. require('event').pull('key') print( require('keyboard').isKeyDown( 0x39 ) )
-
How do I get a print function working for a drone BIOS?
Molinko replied to ethanwdp's question in Programming
FYI, dunno if you already know this but, the print function is just a wrapper for io.stdout:write with a concatenated newline char. i.e. function print( ... ) local out = "" for i = 1, #arg do out = out .. type(arg[i]) == 'string' and arg[i] or tostring(arg[i]) end io.stdout:write( out .. '\n' ) end ... Seems the latest definition of print in OpenOS uses a buffer like what @TYKUHN2 said. Here is the real def in the latest version of OpenOS. -- Other code above in file. -- found @ "/boot/00_base.lua" function print(...) local args = table.pack(...) local stdout = io -
--try loading the robot lib through the require statement. In the lua interpreter the robot lib is loaded by default. -- I dont think the component.robot library uses the same robot.fill function.... -- So, either replace the top lines of your program with this... local robot = require 'robot' robot.fill(1000) -- this assumes the tank is attatched to sides.front -- Or try this which i would recommend... local component = require 'component' local sides = require 'sides' local robot = component.proxy( component.get('967f') ) robot.fill( sides.front, 1000 ) -- or whatever side you want...
-
This is the first line of your getClick() function. Try changing it to this... notice the quotes. local _, _, x, y = event.pull( 1, 'touch' )
-
Please run the code and copy and paste the errors. I'll try to help ya out
-
yes it does. try again. less tude...
-
oh but it did work. rs.getItems() returns a list(table). I assume you have 505 of something in your storage... The list returned has data(as a table) in each index. Look at it like this... local function dumpSlot(n, items) local info = items[ n ] for k, v in pairs( info ) do print( k, v ) end end -- look at details of slot 1 in list of items returned by rs.getItems() dumpSlot(1, rs.getItems())
-
The table is being turned into a string. Lua doesn't know how to do this in a meaningful way by default. What you want are the table keys and its values. Try this out and see if its what you're looking for. for k, v in pairs(test) do print( k, tostring(v) ) end Sorry for the crap formatting. Phone...
-
I've made some small changes.. I think this is what you're looking for arg1=... cm=require("component") si=require("sides") s=si.east c=require("colors") rs=cm.redstone doors = { -- # key, value list of door id's and their respective colors ["s1"] = 'red', ["s2"] = 'green', ["s3"] = 'brown', ["s4"] = 'blue', ["s5"] = 'purple', ["s6"] = 'cyan', ["p1"] = 'pink', ["p2"] = 'lime', ["office"] = 'yellow', ["utility"] = 'orange' } function openDoor(id, doorlist) local color = doorlist[ id ] if color then rs.setBundledOutput(s, c[ color ], 255) else print(("[%s] is not a va
-
individual terminal glasses (openperiherals compatibility)
Molinko replied to Hellreaper's question in Programming
This script looks like its for OC rather than CC so maybe the line should really read... local event = require "event" -- this should be up top with the others... -- line 60. os.pullEvent is ComputerCraft evt = { event.pull() } -
individual terminal glasses (openperiherals compatibility)
Molinko replied to Hellreaper's question in Programming
You really shouldn't have to. I'm not an expert but that sounds fishy.. -
I'm not sure about this but I believe there is a setting in the oc config to change the default fg and BG color of a tier 1 monitor... Dig through the cfg The setting is in the 'client' section of 'settings.conf' in your minecraft folder. The setting is called 'monochromeColor'.
-
individual terminal glasses (openperiherals compatibility)
Molinko replied to Hellreaper's question in Programming
FYI the table lib is loaded globally by default. No need to require it. Table.unpack is lua 5.2. Perhaps you're running 5.1 architecture?? -
individual terminal glasses (openperiherals compatibility)
Molinko replied to Hellreaper's question in Programming
Rather than write my own I decided to search a bit and found this. The program shows how to capture events, draw privately to players, and generally shows the mods potential. -
individual terminal glasses (openperiherals compatibility)
Molinko replied to Hellreaper's question in Programming
Actually, the users table is more like a struct than the data inside it. A big difference is where in memory these are in comparison. When I made that I was really just showing off the flexibility of Lua tables. In reflection, that was probably just confusing, but good to know before you fuck things up.. Personally I try to not mix up my tables and use any one instance of a table as either an array* or an object*. Coming from a strict language like C to a variably typed language like Lua can be weird. I would really look at these two references: Lua 5.2 manual, OC documentation. OC is su -
individual terminal glasses (openperiherals compatibility)
Molinko replied to Hellreaper's question in Programming
Also I wanted to ask..? What does you program do?? lol. Can I see all ye code? -
Is it possible that your robot also requires the inventory controller upgrade as well?? Inventory upgrade for space. Trading for ... trading. Inv controller for inventory interaction..
-
I don't quite understand what you mean by 'run name'. But if you want to print text to the screen its pretty easy. In the shell type( no quotes ): 'edit test.lua' This will open a new file name 'test.lua' to write your basic program. Inside... -- # this is a comment, not code. print( "Hello world!" ) -- # press ctrl+s to save. then press ctrl+w to exit the edit program. You should be back in the OpenOS shell now. Type( no quotes ): 'test.lua' to run your program.
-
Buttons, Loading Bars, Pages and Content but how?
Molinko replied to Chaoschaot234's question in Programming
That a lot of stuff to think about! I can't answer all of this but I have something to take a fat chunk out of your graphics request. Check out Gophers OC programs repo. Specifically GML Gophers GML. This should make crafting a sensible gui a whole lot cleaner. -
individual terminal glasses (openperiherals compatibility)
Molinko replied to Hellreaper's question in Programming
Hi again, sorry for the delay, It's 12:35 in the afternoon here. I made a bit of an error. It can work, but it may have given you a slight headache if you weren't sure what you were looking at. Lua can be a little strange but I love me some strange . First off you should know that in Lua tables can be an Array or an Object (as you understand them in other languages). Even stranger still to a C guy is that they can be a hermaphroditic structure too! Like that users table we created. See here. local users = {} for i, v in ipairs( bridge.getUsers() ) do local user = { name = v.name, -
individual terminal glasses (openperiherals compatibility)
Molinko replied to Hellreaper's question in Programming
Hello again :). I found some old openperipheral docs that should help. Beware, they might not be entirely accurate. OP bridge docs. It seems you want to use 1 bridge and use the method 'getSurfaceByName' or 'getSurfaceByUUID'. I would suggest creating a table of players where the keys are player names and the value is player specific data... i.e. local users = {} for i, v in ipairs( bridge.getUsers() ) do local user = { name = v.name, uuid = v.uuid, -- this might be v.UUID im not sure :/ surface = bridge.getSurfaceByName( v.uuid ) -- check v.uuid here too :/ } users[ -
Asynchron communication with Multiple Computers
Molinko replied to MinerSebas's question in Programming
Tell me if I understand your question correctly. You have a two door system, kind of like an airlock on a spacecraft, and you want the first door to open when the password is correct and the second door to open only after the first has closed... Is that what you are trying to achieve? -
Yep. There are some"gotchas" but for the most part its great. Thanks for the uptick
-
If all you want is a list of names you can do this.. local names = {} local users = bridge.getUsers() for i = 1, #users do names[ i ] = users[ i ].name end I prefer something kinda functional though... -- create a new table with the result of fn(el) @ each el local function map( t, fn ) local _t = {} for i = 1, #t do _t[ i ] = fn( t[ i ] ) end return _t end -- create a function that takes a table and returns the val of given key in said table local function pluck( key ) return function( t ) return t[ key ] end end -- create a list of names by mapping over users list and p
-
I've edited my initial post.