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

Help

Started by S0N_G0KU_Z, 14 April 2013 - 02:18 PM
S0N_G0KU_Z #1
Posted 14 April 2013 - 04:18 PM
Im trying to write a program that th screen has WELCOME flashing on it and when i touch it it displays logog can someone help me it get startup:7: attempt to call nil

  • –By S0N_G0KU_Z
  • local pos = 18
  • mon = peripheral.wrap("right")
  • mon.clear()
  • mon = setBackgroundColor(32768)
  • mon.setTextColor(1)
  • mon.setTextScale(5)
  • while true do
  • if pos==-30
  • then pos = 18
  • end
  • mon.clear()
  • mon.setCursorPos(pos,1)
  • mon.write("WELOCOME")
  • pos = pos-1
  • os.sleep(0.15)
  • end
  • local mon = peripheral.wrap("right")
  • local img = paintutils.loadImage("logo")
  • term.redirect(mon)
  • paintutils.drawImage(img,1,1)
  • term.restore()
SuicidalSTDz #2
Posted 14 April 2013 - 04:22 PM
local pos = 18
local mon = peripheral.wrap("right")
mon.clear()
mon.setBackgroundColor(32768)
mon.setTextColor(1)
mon.setTextScale(5)
while true do
if pos == 30 then
  pos = 18
end
mon.clear()
mon.setCursorPos(pos,1)
mon.write("WELOCOME")
pos = pos-1
sleep(0.15)
end
local img = paintutils.loadImage("logo")
term.redirect(mon)
paintutils.drawImage(img,1,1)
term.restore()
You were redefining the variable mon.
S0N_G0KU_Z #3
Posted 15 April 2013 - 04:22 AM
thank you but how do i get it so whn i click the screen it changes to the logo
SuicidalSTDz #4
Posted 15 April 2013 - 04:36 AM
while true do
 local ev = os.pullEvent()
 if ev == "mouse_click" then
  --logo
 else
  --something else
 end
end
S0N_G0KU_Z #5
Posted 15 April 2013 - 06:00 AM
thank you all so much but were would it put that SuicidalSTDz
SuicidalSTDz #6
Posted 15 April 2013 - 06:01 AM
So when you click the screen you want the logo to appear, right? What do you want to appear if you click the screen again?

EDIT So just flash Welcome, then if someone clicks display the logo, correct?
SuicidalSTDz #7
Posted 15 April 2013 - 06:19 AM
Here, try this:

local w,h = term.getSize()
local pos = w
local mon = peripheral.wrap("right")

local function scrollText(text)
  for i = 1,w+#text do
    mon.clear()
    mon.setCursorPos(pos,1)
    mon.write(text)
    sleep(0.1)
    pos = pos-1
  end
  pos = w
end

local function welcome()
    mon.setBackgroundColor(32768)
    mon.setTextColor(1)
    mon.setTextScale(5)
    while true do
        scrollText("WELCOME")
    end
end

local function click()
    local ev = os.pullEvent("mouse_click")
    local img = paintutils.loadImage("logo")
    term.redirect(mon)
    paintutils.drawImage(img,1,1)
    term.restore()
    return
end

parallel.waitForAny(welcome,click)
S0N_G0KU_Z #8
Posted 15 April 2013 - 10:35 AM
thnanks but now im getting a parallel:22: error it works but i when i click it dosent change
S0N_G0KU_Z #9
Posted 15 April 2013 - 10:36 AM
thnanks but now im getting a parallel:22: error it works but i when i click it dosent change
and i wanted it a touch screen

Sorry if you dont answer im a noob i feel bad if im bothering anyone if so you can kick me off this website :(/>
S0N_G0KU_Z #10
Posted 15 April 2013 - 02:11 PM
Im sorry to bother anyone but can i have an awnser or will i get kicked from this site
SuicidalSTDz #11
Posted 15 April 2013 - 04:48 PM
Whoops, sorry. I was busy doing something.

local w,h = term.getSize()
local pos = w
local mon = peripheral.wrap("right")

local function scrollText(text)
  for i = 1,w+#text do
    mon.clear()
    mon.setCursorPos(pos,1)
    mon.write(text)
    sleep(0.1)
    pos = pos-1
  end
  pos = w
end

local function welcome()
    mon.setBackgroundColor(32768)
    mon.setTextColor(1)
    mon.setTextScale(5)
    while true do
        scrollText("WELCOME")
    end
end

local function click()
    local ev = os.pullEvent("monitor_touch")
    local img = paintutils.loadImage("logo")
    term.redirect(mon)
    paintutils.drawImage(img,1,1)
    term.restore()
end

parallel.waitForAny(welcome,click)