Jump to content

Help with the Modem API

api computer peripheral

3 replies to this topic

#1 Astrophylite

  • Members
  • 121 posts
  • Locationgps.locate()

Posted 17 July 2015 - 05:59 PM


I was wondering if anyone could help me with this code.
I was trying to make a remote unlock but I only want it working from a certain distance.
I tried to put "if senderDistance == 3 then" but it just kept opening and closing and I was way over 5 blocks away..

Code: http://pastebin.com/AWNeVpPp

Thanks in advance,

#2 Lupus590

  • Members
  • 1,974 posts
  • LocationUK

Posted 17 July 2015 - 06:08 PM

Could you give us a line number to work with? Where do you need this distance check?

Edited by Lupus590, 17 July 2015 - 06:09 PM.

#3 jerimo

  • Members
  • 74 posts

Posted 17 July 2015 - 06:22 PM

Line 25 you are declaring a function inside a while loop, meaning that it will be declared every time that loop runs, if it runs at all never attempted such a thing personally
Also you are locking/unlocking the door if there is a player event, without checking anything then pulling a new event and seeing if its a modem event, without checking the distance at all.

Not your exact problem but imagine what would happen if you had a modem message followed by a player message. Your code would take the modem message see its not a player event and take the player event see its not a modem message and discard it.
To solve this simply change your if in line 51 to an elseif

#4 Astrophylite

  • Members
  • 121 posts
  • Locationgps.locate()

Posted 18 July 2015 - 10:57 AM

Thank you both for your responses. I am just about to split the two scripts into separate programs to debug it :)

I will let you know the outcome if I need anymore help !

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users