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

[LUA] [ERROR] Level disigner not displaying the scene properly

Started by Geforce Fan, 15 December 2012 - 12:01 PM
Geforce Fan #1
Posted 15 December 2012 - 01:01 PM
First: I'm not done with the designer yet. Second: This will likely not be released, so there is some stuff that is printed on the screen that won't make sence.
Code:



function placeThing()
_, but, x, y = os.pullEvent("mouse_click") ;
paintutils.drawPixel( x, y, colornum)
end
print("levelname(type open to open 1 nvm)") ;
levelname = read()

print()
print()
print()
print()
print()
print()
print()
print()
print()
print()
print()
print()
print()
print()
print()

function choices()
term.clear()
term.setCursorPos(1,17)
print("--------------------------------------------------") ;
print("list: 1colorChange, 2place, 3makeNonSolid, 4exit")
print("5makeMonster, 6doWhenPosRight, 7PosRightButten")
choice = read()
if choice == "1" then
term.setCursorPos(1,17)
term.write("colornum: ") ;
colornum = read()
colornum = tonumber(colornum)
term.clear()
term.setCursorPos(1,17)
choices()
elseif choice == "2" then
placeThing()
choices()
end
end
choices()
Inputs:
first: 1(top of prog)
second: 1(in the choices() function)
Third: 7(The result of putting 1 in the choices function, also in the function)
Forth: 2(Choices again)
5th: Clicked somehere on the screen(first function in the code)
RESULT ScreenShoot(I'm using CCemu)


(I termitated the app after I got it, but the part cuttoff was blue and the black spot was too.)
Sammich Lord #2
Posted 15 December 2012 - 01:04 PM
You need to have the os.pullEvent in a loop to constantly get input.
Geforce Fan #3
Posted 15 December 2012 - 01:47 PM
New problem: Every time I clear the terminal it does that
Geforce Fan #4
Posted 15 December 2012 - 02:21 PM
Noone? :C!!
theoriginalbit #5
Posted 15 December 2012 - 02:43 PM
New problem: Every time I clear the terminal it does that

does what?
Geforce Fan #6
Posted 15 December 2012 - 02:59 PM
New problem: Every time I clear the terminal it does that

does what?
It does the same thing as the screenshot, but it does work as paint. I'll post the new code below.


function placeThing()
while true do
_, but, x, y = os.pullEvent("mouse_click") ;
if y <16 then
paintutils.drawPixel( x, y, colornum)
else
choices()
end
end
end
print("levelname(type open to open 1 nvm)") ;
levelname = read()

print()
print()
print()
print()
print()
print()
print()
print()
print()
print()
print()
print()
print()
print()
print()

function choices()
term.clear()
term.setCursorPos(1,17)
print("--------------------------------------------------") ;
print("list: 1colorChange, 2place, 3makeNonSolid, 4exit")
print("5makeMonster, 6doWhenPosRight, 7PosRightButten")
choice = read()
if choice == "1" then
term.setCursorPos(1,17)
term.write("colornum: ") ;
colornum = read()
colornum = tonumber(colornum)
term.clear()
term.setCursorPos(1,17)
choices()
elseif choice == "2" then
placeThing()
choices()
end
end
choices()

theoriginalbit #7
Posted 15 December 2012 - 03:17 PM
New problem: Every time I clear the terminal it does that

does what?
It does the same thing as the screenshot, but it does work as paint. I'll post the new code below.


function placeThing()
while true do
_, but, x, y = os.pullEvent("mouse_click") ;
if y <16 then
paintutils.drawPixel( x, y, colornum)
else
choices()
end
end
end
print("levelname(type open to open 1 nvm)") ;
levelname = read()

print()
print()
print()
print()
print()
print()
print()
print()
print()
print()
print()
print()
print()
print()
print()

function choices()
term.clear()
term.setCursorPos(1,17)
print("--------------------------------------------------") ;
print("list: 1colorChange, 2place, 3makeNonSolid, 4exit")
print("5makeMonster, 6doWhenPosRight, 7PosRightButten")
choice = read()
if choice == "1" then
term.setCursorPos(1,17)
term.write("colornum: ") ;
colornum = read()
colornum = tonumber(colornum)
term.clear()
term.setCursorPos(1,17)
choices()
elseif choice == "2" then
placeThing()
choices()
end
end
choices()


well the black in the corner is because Dan200 has programmed the terminal to print in black.

so if I understand correctly when you click the entire page goes blue? or am I not understanding correctly?
Geforce Fan #8
Posted 15 December 2012 - 03:25 PM
You are understanding perfectly. But text is still there. It goes the color I selected.
theoriginalbit #9
Posted 15 December 2012 - 03:32 PM
You are understanding perfectly. But text is still there. It goes the color I selected.

Oh so the text is meant to disappear?
dissy #10
Posted 15 December 2012 - 04:33 PM
It looks perfectly fine to me.

You run paintutils.drawPixel and are passing it a variable for the color value. In code you didn't show, it is setting it to blue. Now the screen is blue.
When you term.clear, that won't change the color you set, but will fill the screen with it
No where shown does it change it back to black.
theoriginalbit #11
Posted 15 December 2012 - 04:45 PM
It looks perfectly fine to me.

You run paintutils.drawPixel and are passing it a variable for the color value. In code you didn't show, it is setting it to blue. Now the screen is blue.
When you term.clear, that won't change the color you set, but will fill the screen with it
No where shown does it change it back to black.

the black comes from the terminal setting it that way. its part of how dan200 makes it work.
dissy #12
Posted 15 December 2012 - 05:28 PM
the black comes from the terminal setting it that way. its part of how dan200 makes it work.

The only black I see is when he terminated the program. That is normal yes.
The rest of the screen being blue however, is from where he set it. I don't think he expects to control the screen after the program quits running ;}

I thought the question was, why wasn't the whole screen black. Or did I misunderstand?

You can understand my confusion, since he never really stated what the problem was.

Edit: Yea I'm pretty sure i'm correct. He said:
(I termitated the app after I got it, but the part cuttoff was blue and the black spot was too.)
So he terminated it. That little black section isn't the problem.
He states the part cut off was blue, and the black spot was too. I just pointed out the line of code that caused that to happen. Specifically:
paintutils.drawPixel( x, y, colornum)
theoriginalbit #13
Posted 15 December 2012 - 05:37 PM
The only black I see is when he terminated the program. That is normal yes.

Yes that is normal.

The rest of the screen being blue however, is from where he set it. I don't think he expects to control the screen after the program quits running ;}

From what I understood the bug was that the text should not be there anymore.

You can understand my confusion, since he never really stated what the problem was.

Yes that was a problem
dissy #14
Posted 15 December 2012 - 05:46 PM
If you want to clear the screen to black, use:

paintutils.drawPixel(1, 1, colors.black)
term.clear()
theoriginalbit #15
Posted 15 December 2012 - 06:03 PM
If you want to clear the screen to black, use:

paintutils.drawPixel(1, 1, colors.black)
term.clear()

or just as easy


term.setBackgroundColor(colors.black)
term.clear()
Geforce Fan #16
Posted 15 December 2012 - 06:25 PM
But wouldn'tng so reset everything on the screen? I need the objects to stay!
theoriginalbit #17
Posted 15 December 2012 - 06:28 PM
But wouldn'tng so reset everything on the screen? I need the objects to stay!

so redraw them?
Geforce Fan #18
Posted 15 December 2012 - 06:29 PM
:\ that is impossible, as all of the objects would need seperate varubles
theoriginalbit #19
Posted 15 December 2012 - 06:34 PM
:\ that is impossible, as all of the objects would need seperate varubles

not if you store them in a table
Geforce Fan #20
Posted 15 December 2012 - 06:37 PM
How the
SpoilerNothing is in here expect for that and: . Thought I would cuss huh?
do you use tables? All I cal do is write one and print all of its content on the screen, that is it. Could you post a –GOOD– youtube video as a link for me?
Also, you seem like a good beta tester. Read the forum topic and you can find out how to apply to test mai game when it's ready for testing.
theoriginalbit #21
Posted 15 December 2012 - 06:40 PM
How the
SpoilerNothing is in here expect for that and: . Thought I would cuss huh?
do you use tables? All I cal do is write one and print all of its content on the screen, that is it. Could you post a –GOOD– youtube video as a link for me?
Also, you seem like a good beta tester. Read the forum topic and you can find out how to apply to test mai game when it's ready for testing.

ummm I dont really know of any good youtube videos. I'll pm you how to use tables.
Geforce Fan #22
Posted 15 December 2012 - 06:46 PM
aww you got the bump :C
dissy #23
Posted 15 December 2012 - 07:12 PM
But wouldn'tng so reset everything on the screen? I need the objects to stay!

But you already have a term.clear() in your code, I didn't add that.
You call it literally first thing in function choices…..
snoble2022 #24
Posted 16 December 2012 - 03:13 AM
IF you don't want to clear the screen then try this:


line = 1
for i=1,19 do
  term.setBackgroundColor(colors.blue)
  term.setCursorPos(1,line)
  print("                                                ")
  line = line + 1
end

this shoud work and it doesent clear the screen
1lann #25
Posted 16 December 2012 - 06:04 PM
IF you don't want to clear the screen then try this:


line = 1
for i=1,19 do
  term.setBackgroundColor(colors.blue)
  term.setCursorPos(1,line)
  print("												")
  line = line + 1
end

this shoud work and it doesent clear the screen
Actually that would clear the screen because the " "s (Spaces) will overwrite the characters on the screen.