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

Question

I've been trying to create a few arguments for a GUI I've been working on, and trying to use the RC script's complimentary cfg system to do so, and thus have a list with 4 items in it, so my rc.cfg looks as thus:

enabled = {"startup"}
startup = {}
startup[col0] = 0xFF9200
startup[col1] = 0xFF6D00
startup[col2] = 0x000000
startup[col3] = 0xFFFFC0

 

My problem is that when I actually go to my startup.lua program I don't actually understand how to access these arguments, and looking in the example.lua has yet to avail me of any answers as to how it actually works, could someone please explain it to me in layman's terms

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

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"

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

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