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

Molinko

Members
  • Content Count

    426
  • Joined

  • Last visited

  • Days Won

    34

Molinko last won the day on May 28

Molinko had the most liked content!

2 Followers

About Molinko

  • Rank
    Leading Member

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

2149 profile views
  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, "Current Reactor Temps")) -- Grab a reference to the text object you need to update local gui_temp = GUI.text(5, 5, 0xFFFFFF, currentTemps) application:addChild(gui_temp) application:draw(true) -- initial paint thread.create(application.start, application) -- Start the app event handler as a subprocess of this one while true do os.sleep(3) -- Update the element every 3 seconds gui_temp.text = tostring(reactor.getHeat()) gui_temp:update() -- Signal the app that this element should be refreshed end This is just another attempt in case I missed something... If this doesn't work yet again, then could you run `cat /tmp/event.log` after running this (if it fails), and reply with its output if it's available. Threads and event timers don't throw errors in the main process.
  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 application:addChild(GUI.panel(4, 2, 23, 4, 0x880000)) application:addChild(GUI.text(5, 3, 0xFFFFFF, "Current Reactor Temps")) -- Grab a reference to the text object you need to update local gui_temp = GUI.text(5, 5, 0xFFFFFF, currentTemps) application:addChild(gui_temp) -- Create a timer that will run every 3 seconds, forever. local tid = event.timer(3, function() gui_temp.text = tostring(reactor.getHeat()) -- overwrite the text data gui_temp:update() -- notify the app that the state of gui_temp has changed end, math.huge) -------------------------------------------------------------------------------- application:draw(true) application:start() event.cancel(tid) -- cleanup the timer after application:start returns
  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 of course an eeprom. No hdd and no OS(no OpenOS floppy either).
  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 main script yields i.e event.pulls, os.sleeps, etc.. local guiProc = thread.create(application.start, application) -- # Continue below with main program runtime logic. -- # Be aware that the GUI will only be able to process stuff when this main script yields as Lua is single threaded Multiline text is handled by GUI.textBox rather than GUI.text as far as I can tell. Hope this helps you over the initial hump. Happy to help more if you still need it
  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 then drone.setStatusText("We in business bb") end while true do drone.move(0, 0, 0) -- to keep the drone running end Drones can be a bit of a pain to get used to as they dont have any of the sweet libs defined in OpenOS. See https://ocdoc.cil.li/tutorial:custom_oses to see what is available in a hardware only env like drones or and hw that is without an OS
  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] -- # the `args` table here is your `startup` table as defined in /etc/rc.cfg local ofg = gpu.setForeground(color) print(text) gpu.setForeground(ofg) end -- # call start from the cmd line like so.. -- > rc startup start col2 "this is colored text"
  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
×
×
  • Create New...

Important Information

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