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

Minecrafted9193

Members
  • Content Count

    6
  • Joined

  • Last visited

Posts posted by Minecrafted9193

  1. No problem :)

     

    As for multiple messages, are you sure there are not any loops within the network between the 2 machines you have?

    No, I tested it two ways. One with cables, one wirelessly. Both cause several messages. But the .5 second delay fixes it every time. Also I'm glad my post needs to be reviewed thing is gone, I have no patience, at all.

  2. Try this

     

    
    local component = require( "component" )
    local event = require( "event" )
     
    print( "Pulling broadcasts from port 25565" )
    component.modem.open( 25565 ) -- only need to open it once
    while true do
      -- don't need the sleep in there, event.pull blocks until the signal is detected
      local _, _, from, port, _, message = event.pull( "modem_message" ) -- parts with "_" are not stored
      print( "Got " .. tostring( message ) .. " from " .. from .. " on port " .. port ) 
    end
    
    

    http://ocdoc.cil.li/component:modem for reference

    The sleep is only to prevent the message being duplicated, because when I only sent one message, it would come up as several "modem_message" about 4-6 of them, rarely 3. I'm trying it now however to see if it will work, and I was hoping it would be simpler than this :/ rather I thought it would be simpler.

  3. maybe because the signal ist called "modem_message", not "modem" like in your event.pull("modem")?

    I don't know about that. If you go into the Lua testing prompt and type this in this order as long as you have a network card or wireless network card you can recieve broadcasts, but it shows a whole lot of stuff, including the message.

     

    component.modem.open(Port)

    =event.pull("modem")

    will recieve the next message sent on the port you opened. But I can't do the =event.pull("modem") because it errors with the =

  4. I decided to write two programs. One to broadcast whatever you type and another to receive broadcasts.

    The one that broadcasts, works perfectly. But the receiving one doesn't. It gets the broadcasts, but doesn't display the how I want. Instead of saying a whole broadcast, it says "modem_message" and the code is shown below.

    component = require("component")
    event = require("event")
     
    print("Pulling broadcasts from port 25565")
     
    while true do
     
        os.sleep(.5) --To make sure it doesn't repeat single messages
     
        component.modem.open(25565)
        x = event.pull("modem") --Doing it like this =event.pull("modem") brings errors
        print(x)
     
    end
    
     

    Any solution?

×
×
  • Create New...

Important Information

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