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. local GUI = require("GUI") local component = require 'component' local thread = require 'thread' local event = require 'event' local reactor = component.reactor_chamber local currentTemps = reactor.getHeat() -------------------------------------------------------------------------------- -- Create new application local application = GUI.application() -- Add panel that fits application application:addChild(GUI.panel(1, 1, application.width, application.height, 0x262626)) -- Add smaller panels application:addChild(GUI.panel(4, 2, 23, 4, 0x880000)) application:addChild(GUI.text(5, 3, 0xFFFFFF
  2. 1) yes. The quotes. 2) autorun isn't depricated ( I don't think..) but you might like the .shrc format better. Run 'edit .shrc' in the home dir and add the path to the file you want to run on the first available line. It's super simple and can have multiple programs to run on startup. Also programs can take shell args just like typing it in yourself.
  3. I'm not super familiar with this library so you may have to adjust the code as it is untested. local GUI = require("GUI") local component = require 'component' local thread = require 'thread' local event = require 'event' local reactor = component.reactor_chamber local currentTemps = reactor.getHeat() -------------------------------------------------------------------------------- -- Create new application local application = GUI.application() -- Add panel that fits application application:addChild(GUI.panel(1, 1, application.width, application.height, 0x262626)) -- Add smaller panels a
  4. The issue you see here is because `component` is removed from the global scope in OpenOS and must be required using the `require` function. If this file is intended to be run from an eeprom at boot instead of the standard Lua bios then `component` will still be global and this issue shouldn't remain. Running this program from the shell (as you're doing in the picture).. it will be provided an environment that doesn't contain the `component` namespace. This program seems to be intended to only run from a computer with seemingly multiple screens and gpus, cpu, redstone block(or card?), ram, and
  5. On line 349 and others you use an undeclared variable named 'turbineNum' to index the turbine table like so "some_value = turbine[turbineNum].someMethod()". You use this in a few places in the script yet I can't find a placed where it is defined.
  6. It's not possible. You can set them one after the other, sequentially, fast enough that you won't notice. Effectively at the same time.. but parallelization is not possible
  7. If you could post all the code or explain what you're trying to do a bit more that would help me help you. Lua is single threaded so there isn't any real parallelization, so I'm having a hard time understanding what you need.
  8. Typically the GUI and your application are separated because of the reactive nature of the GUI library. Most of your code for reacting to GUI events will go into a GUIObjects event handler. -- # ... myButton.eventHandler = function(app, instance, event) if event == "touch" then -- # react to touch event. Alter state, etc... end end I don't have the time to test this my self but you could try using OpenOS threads to give control back to your main script. -- # ... more stuff up here local thread = require 'thread' -- # Gui logic n stuff... -- # This will now run whenever the
  9. Try this out.. The require function is defined by OpenOS which isn't available in the drone env. require is used to load libraries from the package path. See /lib/package.lua local drone = component.proxy(component.list('drone')()) local position = component.proxy(component.list('navigation')()).getPosition() -- # The require keyword is for libraries accessed via a filesystem which the drone doesn't have. Therefor it isn't available. -- # The `component.someComponentName` functionality is defined in the OpenOS component library.. Again, not available here. if position ~= nil th
  10. Molinko

    RC Arguments

    RC args are accessible from the start method in your startup.lua module under the args env name. Its a little complicated but basically when your startup rc module is loaded the rc.cfg variable with the same name (startup) is accessible as args in your module. -- # rc.cfg enabled = {"startup"} startup = {} -- # this table notation requires quotes btw startup["col0"] = 0xFF9200 startup["col1"] = 0xFF6D00 startup["col2"] = 0x000000 startup["col3"] = 0xFFFFC0 -- # /etc/rc.d/startup.lua local gpu = require("component").gpu function start(cfgColor, text) local color = args[cfgColor] -- #
  11. Have you already installed openos or is it running from the disk?
  12. The `require` function is implemented by the OS and is not in the default Lua environment. It needs a filesystem to search for packages and because the eeprom is basically a one file filesystem.. There's nowhere to look for packages. Either install OpenOS or see package.lua from OpenOS source to get an idea for how to write your own require function.
  13. I suspected you might be coming from python :). You might be interested in moonscript. I made a simple patch that allows programs to use the shebang syntax in OpenOS i.e #!/usr/bin/moon for i = 1, 5 print i unless i%2 == 0
  14. It's hard to tell just from what you've described but it sounds like the computer doesn't have an energy source...
  15. There are a couple errors. The first is that the `while` keyword must be lowercase. Also within the `while` loop the if statement is missing the `end` keyword. I believe you'll also need to require the libraries you need before using them in a definition. local component = require "component" local sides = require "sides" local redstone = component.redstone local reactor = component.nc_fission_reactor local function GP() return reactor.getEnergyStored() end local mP, MP = 4000, reactor.getMaxEnergyStored() local MMP, CP = (MP / 4) * 3, GP() while CP > 0 do if CP > MMP then
  16. The issue is with your variables returned by event.pull. the 6th rturn value is the message. You're assignment for message is the fifth which is actually distance which will always be 1 from a wired modem.
  17. One way is to convert your script to run as an rc program. The other is to use threads from the thread library, see https://ocdoc.cil.li/api:thread. Here's a simple example.. local thread = require "thread" local proc = thread.create(os.execute, "/path/to/program") proc:detach() -- # detach from current process
  18. Yeah it would.. I missed that. Perhaps a nil check would be better. function m.addTrustedUser(user, level) if db.users[user] ~= nil then error "Cannot add an existing user!" end db.users[user] = level db.hasChanges = true end
  19. Overall the program looks pretty solid. Personally I like to write things with more descriptive names for when I have to revisit programs after a while. One place where things become unclear is using 'k' or 'v' in your pairs loops. If the keys and values are really arbitrary then this makes sense however several places in your code could be clarified by using better variable names. Here's an example.. --- Distribute Json -- Disseminates the settings from the database to all turrets. function m.distribJson() -- # also db.turrets is an array so maybe ipairs would help a reader infer that.
  20. You should look to the docs. I'm not versed in pub/priv key pairs but I imagine the decrypt function takes either key(but usually the private?) to decrypt encrypted data
  21. A combo of a wrapper and a custom program env might be able to do what you want but you're right that it might just be just a lot of overhead for a few convenience functions.. It also wouldn't cover cases on raw string values like ("yolo"):len()
  22. Capitalization. You're calling 'getDimensionID' and it should be 'getDimensionId'
  23. @Log you beat me to it by about a minute :p. So I'll just add how to get a useful list OP mentioned. local component = require "component" local debug = component.debug local players = {} for _, name in ipairs(debug.getPlayers()) do local world = debug.getPlayer(name).getWorld() table.insert(players, { name = name, dimension = { name = world.getDimensionName(), id = world.getDimensionId() } }) end print(players[1].name, players[1].dimension.name, players[1].dimension.id) --> "Molinko" "overworld" "0"
×
×
  • Create New...

Important Information

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