Jump to content




Help please my code won't work.


  • You cannot reply to this topic
5 replies to this topic

#1 Brandon_sanc

  • Members
  • 4 posts

Posted 17 September 2014 - 02: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 by Brandon_sanc, 17 September 2014 - 04:13 PM.


#2 blipman17

  • Members
  • 92 posts

Posted 17 September 2014 - 09: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.

#3 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 17 September 2014 - 09:23 PM

View PostBrandon_sanc, on 17 September 2014 - 02:22 PM, said:

- 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.

#4 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 17 September 2014 - 10:32 PM

View PostTheOddByte, on 17 September 2014 - 09:23 PM, said:

View PostBrandon_sanc, on 17 September 2014 - 02:22 PM, said:

- 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...

#5 Dog

  • Members
  • 1,179 posts
  • LocationEarth orbit

Posted 17 September 2014 - 11:43 PM

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 by Dog, 18 September 2014 - 12:54 AM.


#6 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 18 September 2014 - 12: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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users