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

Help please my code won't work.

Started by Brandon_sanc, 17 September 2014 - 01:22 PM
Brandon_sanc #1
Posted 17 September 2014 - 03:22 PM
The code is:

local monitor = peripheral.wrap("left")
local ticketMachine = peripheral.wrap("right")

while true do
monitor.setCursorPos(10,6)
monitor.setBackgroundColor(colors.red)
monitor.setTextColor(colors.white)
monitor.write("mall")

event,side,x,y = os.pullEvent("monitor_touch")
if x < 25 and x > 10 and y==6 and side == "left" then
ticketMachine.createTicket("mall")
end
end

I tried typing it from bottom to top and from top to bottom. When I typed it from bottom to top and connected it to a monitor it said, "attempted to call nil. When I typed it from top to bottom it said Bios 339: [string"mall"] expected.

Im fairly new to this mod and I'm not sure what I did wrong. Thank you in advance
Edited on 17 September 2014 - 03:13 PM
blipman17 #2
Posted 17 September 2014 - 10:19 PM
okay, let's go through your problem.

you just stated two errors;
attempted to call nil.
Bios339:[string"mall"] expected

the first one has a number behind it, or before or something.
that number is the number at what line the error happened.
that would help us a lot in helping you.

the second error is an error with openblocks, which I don't know anything usefull about.
TheOddByte #3
Posted 17 September 2014 - 10:23 PM
- Snip -
Just a question, are you using an advanced monitor? ( gold monitor )
If you aren't then there's where the attempt to call nil error is coming from, because the regular monitor doesn't support colours.
KingofGamesYami #4
Posted 17 September 2014 - 11:32 PM
- Snip -
Just a question, are you using an advanced monitor? ( gold monitor )
If you aren't then there's where the attempt to call nil error is coming from, because the regular monitor doesn't support colours.
I'm pretty sure you can still set colors, because you can have black text on a white background…
Dog #5
Posted 18 September 2014 - 12:43 AM
I *think* TheOddByte is correct - if I remember correctly (I tried this once), trying to set any color other than black or white on a b/w monitor will result in an attempt to call nil.

EDIT: Clarification based on BB's comment below - I didn't mean to imply that the functions weren't available, just that setting a color other than black or white would result in an error.
Edited on 17 September 2014 - 11:54 PM
Bomb Bloke #6
Posted 18 September 2014 - 01:52 AM
setTextColour and setBackgroundColour are available to monochrome displays. Although they'll error if you ask them to switch to anything other than black or white, that doesn't make them pop out of existence.