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

Need Help With a Program

Question

So I found this Program(Below) But the user hasnt been online in a while. Iv tried flashing to an eeprom and booting with just the eeprom, just running the program, and i keep getting an error (attached)

The Program :

local user = { "user1", "user2", "user3" }
 
local red = component.proxy(component.list("redstone")())
local scr = {}
local gpu = {}
 
for a in component.list("screen") do table.insert(scr, a) end
for a in component.list("gpu") do table.insert(gpu, component.proxy(a)) end
for i = 1, #gpu do gpu[i].bind(scr[i]) end
 
function showState(s)
  for i, g in ipairs(gpu) do
    g.setResolution(40, 20)
    g.fill(1, 1, 40, 20, " ")
    if s then
      g.setForeground(0x00FF00)
      g.set(16, 10, "Access denied")
    else
      g.setForeground(0xFF0000)
      g.set(16, 10, "Access granted")
    end
  end
end
 
function sleep(x)
  local tgt = computer.uptime() + x
  while computer.uptime() < tgt do
    computer.pullSignal(tgt - computer.uptime())
  end
end
 
while true do
  showState(false)
  local type, _, x, y, btn, nick = computer.pullSignal(5)
  if type == "touch" then
    nick = nick:lower()
    for i, v in ipairs(user) do
      if v == nick then
        showState(true)
        red.setOutput(1, 255)
        sleep(2)
        red.setOutput(1, 0)
      end
    end
  end
end 

Instructions included :

Modify user list on top of code, flash it to EEPROM, connect some screens, install same amount of GPUs and one redstone block. Program will trigger pulse on top side of it.

 

2019-06-30_13.59.33.png

2019-06-30_13.59.52.png

Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

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). 

Link to post
Share on other sites
  • 0
22 hours ago, Molinko said:

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.

As Molinko said, this code goes to an EEPROM. To do this, follow these steps:

  1. Get a fresh EEPROM (not Lua BIOS included one).
  2. Get a computer with OpenOS loaded.
  3. Put the fresh EEPROM to the computer.
  4. run `edit /dev/eeprom` and paste the code there. But, I assume you already have it, you will just need to modify it.
  5. As the instruction said, modify the user list on top with your name and/or people you want to grant access to. If it's `Bob`, then write `{ "Bob" }`. Note: CaSe SeNsItIvE.
  6. Done.

After setting up the EEPROM, set up another computer for the EEPROM, by following these steps:

  1. Set up a fresh computer (Tier 1 is okay), with door on top, or a redstone connection to other contraption.
  2. Put a CPU (Tier 1 is okay), a Memory (Tier 1 is okay too), and a redstone card.
  3. Put a number (1 or more) of GPU and screen.
  4. Turn on the computer
  5. Done!

To use this code, sneak-rightclick the screen with barehand to trigger it, or open the screen gui, then click the screen.

 

After trying the code you've shared, I found some oddities and, my suggestion, is to change to my modified code here:

local user = { "user1", "user2", "user3" }
 
local red = component.proxy(component.list("redstone")())
local scr = {}
local gpu = {}
 
for a in component.list("screen") do table.insert(scr, a) end
for a in component.list("gpu") do table.insert(gpu, component.proxy(a)) end
for i = 1, #gpu do if scr[i] ~= nil then gpu[i].bind(scr[i]) end end
 
function showState(s)
  for i, g in ipairs(gpu) do
    g.setResolution(40, 20)
    if s then
      g.setForeground(0x00FF00)
      g.set(16, 10, "Access granted.")
    else
      g.setForeground(0xFF0000)
      g.set(16, 10, "Access denied.")
    end
  end
end
 
function sleep(x)
  local tgt = computer.uptime() + x
  while computer.uptime() < tgt do
    computer.pullSignal(tgt - computer.uptime())
  end
end
 
while true do
  showState(false)
  local sigType, _, x, y, btn, nick = computer.pullSignal(5)
  if sigType == "touch" then
    for i, v in ipairs(user) do
      if v == nick then
        showState(true)
        red.setOutput(1, 255)
        sleep(2)
        red.setOutput(1, 0)
      end
    end
  end
end 

Hope this solves your problem. Well, have a nice day then!

Edited by ayangd
bios.lua comments stripped, case sensitive note, step order fix, payonel's alternative advice (Thanks)
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.