Old Code - Don't Know The Issue...

Started by FoxtrotJeff, Mar 04, 2019, 03:32 AM

Previous topic - Next topic

FoxtrotJeff

I found old code on one of my minecraft worlds before 1.7.10 and would like to run it in 1.12.2.

I get an error when sending a message from my pocket computer..
Error "mwi.lua:5: attempt to index ? (a nil value)

Code ran on Computer:

while true do
  local monitor=peripheral.wrap('monitor_0')
  rednet.open('right')
  local cid, cmsg, cdist=rednet.receive()
  monitor.setCursorPos(1,1)
  monitor.write(cmsg)
  sleep(3)
  monitor.clear()
end

Code ran on Wireless Pocket Computer:

local args = {...}
local message = ""
rednet.open("back")
  for i,v in ipairs(args) do
    message = message .. v .. " "
  end
rednet.send(1, message)

Dog

#1
From what I can see the problem is when you call monitor.setCursorPos(1, 1) in your computer code

If the monitor attached is not connected via modem and network cable and isn't named "monitor_0" then it won't find a monitor and the monitor table won't be populated with methods for you to call.  Make sure a monitor is attached then add the following to the beginning of your computer code (before the while loop)...

local monitor = peripheral.find("monitor")

Then inside your while loop remove or comment out the following line...

local monitor = peripheral.wrap("monitor_0")

FoxtrotJeff

Okay, it's fixed, thank you for the help. :)