This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ModeratlySexy's profile picture

monitors and such

Started by ModeratlySexy, 21 January 2016 - 07:21 PM
ModeratlySexy #1
Posted 21 January 2016 - 08:21 PM
i am making a game. basiclly i want to use x = math.random(0,36) but i need that number to be displayed on a monitor. HELP
KingofGamesYami #2
Posted 21 January 2016 - 08:29 PM

local x, mon = math.random( 0, 36 ), peripheral.find( 'monitor' )
if mon then
  mon.clear()
  mon.setCursorPos( 1, 1 )
  mon.write( x )
end
ModeratlySexy #3
Posted 21 January 2016 - 08:33 PM

local x, mon = math.random( 0, 36 ), peripheral.find( 'monitor' )
if mon then
  mon.clear()
  mon.setCursorPos( 1, 1 )
  mon.write( x )
end

it said attempt to call nill
Bomb Bloke #4
Posted 21 January 2016 - 11:34 PM
It said more than that, but I guess that means you've got an older version of ComputerCraft, one that lacks peripheral.find(). Try peripheral.wrap() instead (pass it the side your monitor is connected to, or if it's running through wired modem, use its network name).