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

SpaceBeeGaming

Members
  • Content Count

    65
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by SpaceBeeGaming

  1. Do you know the address of your I/O blocks? They are unique and random Expamle 2 should work IF you enter the correct addresses.

    right click/shift+right click with an analyzer will show you the address. take the first 5 characters of the address and put them inside the component.get() calls.

  2. First, use code blocks. Second, i fixed your errors and made a few improvements. This should do what you wanted, if not reply in this thread.

    local component = require("component")
    local sides = require("sides")
    local colors = require("colors") --Unused
    local event = require("event")
    local term = require("term")
    
    local redstone = component.redstone
    
    local firecount = 1
    local run = true
    
    local function main()
        local input = redstone.getInput(sides.front)
    
        if (input == 10) then
            print("Redstone Lever ON")
    
            print("Firing Firework " .. firecount .. "!")
            firecount = firecount + 1
    
            redstone.setOutput(sides.left, 15)
            os.sleep(1)
            redstone.setOutput(sides.left, 0)
    
            os.sleep(1)
        else
            print("Lever is OFF")
            os.sleep(1)
        end
    end
    
    --Exit the loop with 'q', better than using Ctrl+C
    local function stop(_, _, char)
        if (char == 81 or char == 113) then
            event.ignore("key_down", stop)
            run = false
        end
    end
    
    --Print the prompt for quit key and start listening for it
    print("press 'q' to exit")
    event.listen("key_down", stop)
    
    --Main loop, will run until 'run' is set to false
    while run do
        main()
    end
    
    --Clear the screen after the program ends
    term.clear()

     

  3. First, why are you sleeping after event.pull() , that's unneccesary and could cause issues where a event is missed.

    Second, how are the computers connected (picture), Are the computers separated by a swich, is there a loop where the swich receives a packet twice (This is the most likely reason for duplicating messages.)

  4. First the opencomputers documentation:  http://ocdoc.cil.li

    local computer = require("computer")
    local component = require("component")
    local sides = require("sides")
    local rs = component.redstone
    local gpu = component.gpu
    
    --Desired time in seconds EDIT THIS!!!
    local timer_length = 10
    
    
    --Clear the screen
    local w,h=gpu.getResolution()
    gpu.fill(1,1,w,h," ")
    local time_remaining
    
    
    --Get the current time and add desired countdown to it.
    local time_now = computer.uptime()
    local target_time = time_now + timer_length
    
    -- Function to draw remaining time on screen
    local function PrintTime(time)
      --Screen drawing logic in here!
      --Currently writes the reamining time on screen in seconds
      gpu.fill(1,1,w,1," ")
      gpu.set(1,1,"Time Remaining: " .. time)
    end
    
    --Loop until time is done
    while true do
      time_now = computer.uptime()
      time_remaining = target_time - time_now
      PrintTime(time_remaining)
      if(time_now>=target_time) then
        break
      end
      os.sleep(1)
    end
    
    -- Emit a redstone signal from the back of the computer with a sgnal strength of 15.
    rs.setOutput(sides.back,15)

    This should work, but i have not tested it. 

    It won't format the time in DD:HH:MM:SS (yet). It will howerver send the redstone signal when it hits 0 (in theory).

    Just reply in this thread if you need more help  or if it doesn't work.

  5. Here is a fixed version along with some notes:

    local event = require("event") --< event library needs to be requested.
    
    local component = require("component") --< same for component
    local lift = component.lift
    
    while true do
        local e = event.pull("motion") --< Don't use system reserved variable names for your own.
        if (e == "motion") then --< This event is never false, as the 'event.pull()' is filtered => the upper action will alwayus run.
            lift.callFloor(2)
        else --< Cant be 'elseif', would need a conditon to test
            os.run(elevatormotionmanipulation)
        end
    end
    
    -- <= these things are comments, they are used to explain what code does, without affecting its execution, they can be removed without issues.

     

  6. @BattyCynris When you update OpenComputers (the mod), It doesn't change what is on the computers, it only changes the contents of the OpenOS floppy disk.

    So updating the in-game computer after the mod update only requires you to insert the OpenOS floppy disk and running "install" again.

    The tool you linked is basically just for those who can't update their mod (playing on a server with outdated version but need features of a newer version) so don't use it if normal updating is available.

  7. @Niami Here is a link https://ocdoc.cil.li/component:data

    Basically it works like this: user A and B both generate a key pair. Then they exchange their public keys. Then the actual AES encryption key is calculated from own private and other users public key these calculations end up in the same result. In other words: A public + B private = B public + A private. Thus allowing encryption and decryption. 

    This is explained in the docs, but poorly.

    I may have some examples,I might share if you're interested. 

  8. So, I'm developing a program which uses event.listen(), and debugging them is a pain because of lines like these: 

    bad argument #1 (string expected, got nil)

    How am I supposed to know where the error is when there is no location information? So is there a way to get the full error details somehow?

  9. Hello. So, I'm making an (in-game) monetary transaction system and for that I need encryption. Documentation on the data card is extremely poor (no examples). Here's what I have so far: 

    Note! The key transfer has already been done.

    --Machine #A
    local pubKeyA, privKeyA = data.generateKeyPair()
    local shKeyA = data.ecdh(privKeyA, pubKeyB)
    
    local message = "Hello?"
    ---[What happens in here to encrypt data?]
    
    modem.send(encryptedData) --just placeHolder
    
    --Machine #B
    local pubKeyB, privKeyB = data.generateKeyPair()
    local shKeyB = data.ecdh(privKeyB, pubKeyA)
    
    local message=event.pull() --just placeholder
    ---[What happens in here to decrypt data?]
    
    print(decryptedData)

    Any and all help would be appreciated.

×
×
  • Create New...

Important Information

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