Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

Molinko

Members
  • Content Count

    451
  • Joined

  • Last visited

  • Days Won

    35

Everything posted by Molinko

  1. 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 ) )
  2. 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
  3. --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...
  4. Molinko

    Button API

    This is the first line of your getClick() function. Try changing it to this... notice the quotes. local _, _, x, y = event.pull( 1, 'touch' )
  5. Molinko

    Button API

    Please run the code and copy and paste the errors. I'll try to help ya out
  6. yes it does. try again. less tude...
  7. Molinko

    Command problem

    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())
  8. Molinko

    Command problem

    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...
  9. 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
  10. 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() }
  11. You really shouldn't have to. I'm not an expert but that sounds fishy..
  12. Molinko

    Vintage green GUI

    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'.
  13. 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??
  14. 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.
  15. 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
  16. Also I wanted to ask..? What does you program do?? lol. Can I see all ye code?
  17. 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..
  18. 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.
  19. 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.
  20. 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,
  21. 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[
  22. 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?
  23. Yep. There are some"gotchas" but for the most part its great. Thanks for the uptick
  24. 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
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.