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

window:247 double expected, got nil help

Started by Carrots084, 25 July 2014 - 08:09 PM
Carrots084 #1
Posted 25 July 2014 - 10:09 PM
Hello guys! I'm currently transposing the awesome game, A Dark Room, into CC! I'll post it to the forums when I finish. But when I run my function yN, iget the error window:247 that I named the topic. Please help! Thanks in advance,
carrot
Spoiler

term.clear()
local function centerText(text)
local x,y = term.getSize()
local x2,y2 = term.getCursorPos()
term.setCursorPos(math.ceil((x/2) - (text:len() / 2)), y2)
write(text)
end
term.setCursorPos(1,2)
centerText("A Dark Room Remix")
term.setCursorPos(1,3)
centerText("By: carrots084")
sleep(5)
term.clear()
term.setCursorPos(1,2)
local selector = ""
function yN()
local n = 1
while true do
local x,y = term.setCursorPos(1,1)
term.clearLine()
if(n== 1) then write(">Start Game<  Secrets") else write("Start Game >Secrets<") end
term.setCursorPos(x, y)
a, b=os.pullEvent()
while a ~="key" do a, b=os.pullEvent() end
if b == 204 and n ==2 then n=1 end
if b ==205 and n ==1 then n = 2 end
if b == 28 then print("") break end
end
if n ==1 then selector = 1 end
if n == 2 then selector = 2 end
return false
end
yN()
if selector == 1 then
game = 1
secrets = 0
elseif selector == 2 then
game = 0
secrets = 1
end

if secrets == 1 then

term.clear()
centerText("Hello. My name is Jeremy, or carrots084.")
centerText("I have decided to make a slight adaptation of A Dark Room, by Michael Townsend.")
centerText("I did this to learn more about Lua, and because it is one of my favourite games.")
centerText("You can currently find it by Googling 'A Dark Room'")
centerText("I hope you have as much fun playing as I had making it")

end
Edited on 25 July 2014 - 08:21 PM
KingofGamesYami #2
Posted 25 July 2014 - 10:12 PM
problem is most likely here:

local x,y = term.setCursorPos(1,1) --#did you mean term.getCursorPos() ?
(btw, put your code in code tags.)
[code] [/code]

Edit: fixed formatting.
Edited on 25 July 2014 - 08:13 PM
Carrots084 #3
Posted 25 July 2014 - 10:22 PM
problem is most likely here:

local x,y = term.setCursorPos(1,1) --#did you mean term.getCursorPos() ?
(btw, put your code in code tags.)
[code] [/code]

Edit: fixed formatting.

Thanks!