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

Tell me where I went wrong?

Question

Posted

I have this code

It works on a computer:

  1. for k,v in pairs(component.radar.getEntities())
  2. do
  3.     if v.name=="PHOBOSS" --entity name
  4.         then print (k,v.x,v.y,v.z) -- coordinates
  5.     end
  6. end
but it screws up in my bot:
stack traceback:
 machine:756: in function '__index '
...
 
is this suppose to be normal?
is this also a thing for drones?
if it is a way around this would be greatly appreciated :)
(note: I used the lua program in running this and the radar component comes from Computronics)
 
furthermore:
so while I was waiting I decided to try and move the process to the computer instead of the bot/drone... I got a bot to broadcast its radars data repeatedly again using the lua program:
  1. while true do
  2. component.modem.broadcast(001, serialization.serialize(component.radar.getEntities())) end
then I had the computer/server do this:
  1. local component=require("component")
  2. local event.require("event")
  3. local serialization.require("serialization")
  4. component.modem.open(001)
  5.  
  6. local function a(_,_,_,_,_msg)
  7. seialization.unserialize(msg)
  8. end
  9. event.listen("modem_message", a)
  10.  
  11. for k,v in pairs(esrialization.unserialize(msg))
  12. do
  13.     if v.name=="PHOBOSS" then
  14.         print (v.name,k,v.x,v.y,v.z) 
  15.     end
  16. end
but instead it does this:
err.png.f177b26e21281d39d20dc6f83303622e.png
 
well I shouldn't be complaining since it did what I want but I need this to be running in a loop and I just also want to know what the error means
again any help is appreciated :)

5 answers to this question

Recommended Posts

  • 0
Posted

local component=require("component")
for k,v in pairs(component.radar.getEntities())
do
    if v.name=="PHOBOSS" --entity name
        then print (k,v.x,v.y,v.z) -- coordinates
    end
end

no errors when used on a computer

but on a robot...

bot.png.42c445019b3b8cefa2a4d77eed8d668a.png

  • 0
Posted

I'm running MC 1.12.2 with Computronics meant for 1.12.1 and although it works* I also cannot retrieve any player information from the radar. So I wouldn't call it a bug because I'm in the wrong version... but it's prob a bug...

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.