Jump to content




Modem Channel Help With ICBM


  • You cannot reply to this topic
6 replies to this topic

#1 thedogs

  • Members
  • 3 posts

Posted 09 August 2013 - 07:08 PM

Hello I need help with the new modem api

I am trying to make is if the message is 1234 it launches the missile

Here is my code

Server
local modem = peripheral.wrap("right")
icbm = peripheral.wrap("left")
modem.open(3)
if modem_message == "1234" then
icbm.launch()
end
end

Another question is how would I write a message to send
So I would have to write the message and then it would send that message to the server

Client
local modem = peripheral.wrap("right")
modem.transmit(3, 1, "1234")

In case you guys don't understand what I am trying to do with my code.
On the client side- You type the launch code if it is wrong a message comes up that says WRONG and something blows up. If it is write then the client send the command to the server to launch the missile.

Server Side
If it recieves the command it launches the missile

Or

Client Side
You type in launch code to send. Sends it and server receives message

Server side
If message is right it launches missiles
If wrong sends a command back to client that will make the area surrounding it blow up


What I don't Understand:
I do not understand how to make the server read a message that is sent from the client.
I do not understand how to make the server check the client message versus the right answer.

#2 Bubba

    Use Code Tags!

  • Moderators
  • 1,142 posts
  • LocationRHIT

Posted 09 August 2013 - 07:48 PM

Split into new topic.

#3 thedogs

  • Members
  • 3 posts

Posted 09 August 2013 - 08:41 PM

Heres another question is rednet still working or has it been discontinued?

#4 thedogs

  • Members
  • 3 posts

Posted 09 August 2013 - 10:19 PM

Another question lol how do Make it where a computer revieves a message from a modem and does a command?

#5 reububble

  • Members
  • 72 posts
  • LocationBehind you

Posted 09 August 2013 - 11:09 PM

you need to use events. For most of this information you can see the wiki page http://computercraft...ki/Os.pullEvent.

All that you need to do is tell your program to wait for a message by using the line
event, param1, param2, param3 = os.pullEvent('rednet_message')
Then the message that is received will be stored in the variable called param2.

You will need to call the pullEvent function every time you want to wait for a new message.

#6 reububble

  • Members
  • 72 posts
  • LocationBehind you

Posted 09 August 2013 - 11:16 PM

For writing the command you can use the read function.
the read function takes an optional argument for what to display as the string is being entered, most commonly '*' is used.

A basic implementation would look like this.

local modem = peripheral.wrap('right')
repeat
  term.clear()
  term.setCursorPos(1,1)
  print('Enter Command')
  command = read('*')
  -- you can put in the exact desired function here
  -- perhaps this is what you need
  modem.transmit(3,1,command)
until command=='exit'


#7 reububble

  • Members
  • 72 posts
  • LocationBehind you

Posted 09 August 2013 - 11:17 PM

Also, yes rednet still works. lol





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users