Posted 03 June 2013 - 02:19 PM
Alright, so I'm trying to make a game (Again).
So far, I had no errors until I tried implement shops.
Error:
AsciiRPG:204: attempt to call boolean
I know that a boolean is true or false.
But it only happends if I press the shop key wich I defined as 'p' twice.
Why?
How do I fix it?
Thanks for help //Mackan90096 (The Duck)
code:
So far, I had no errors until I tried implement shops.
Error:
AsciiRPG:204: attempt to call boolean
I know that a boolean is true or false.
But it only happends if I press the shop key wich I defined as 'p' twice.
Why?
How do I fix it?
Thanks for help //Mackan90096 (The Duck)
code:
Spoiler
-- Variables --
ver = "1.0"
author = "Mackan90096"
w, h = term.getSize()
char = "@"
charX = 2
charY = 10
maxX = w-1
maxY = h-1
lvl = 1
money = 100
inv = false
shop = false
player = "player"
-- Tables --
-- Levels --
xpTable = {
[1] = 100,
[2] = 200,
[3] = 500,
[4] = 1000,
[5] = 2500,
[6] = 4000,
[7] = 5000,
[8] = 7500,
[9] = 10000,
[10] = 11500}
lvlHPTable= {
[1] = 10,
[2] = 20,
[3] = 40,
[4] = 50,
[5] = 100,
[6] = 200,
[7] = 400,
[8] = 500,
[9] = 750,
[10] = 1000}
--[[Items Declare as:
name
lvlNeeded
atkPoints
Type
cost
ID ]]--
item1 = {"Wooden Sword", 1, 1, "Sword", 100, 1}
-- End Items --
-- End Levels --
-- End Tables --
-- Keys --
up = 200
down = 208
left = 203
right = 205
enter = 28
space = 57
i = 23
p = 25
esc = 1
-- End Keys --
-- End Variables --
-- Functions --
-- Text Functions --
function centerPrint(string, X, Y)
term.setCursorPos(math.floor(w-string.len(string))/X, Y)
print(string)
end
-- End Text Functions --
-- Moving Functions --
function Up()
term.setCursorPos(charX, charY)
print(" ")
charY = charY - 1
term.setTextColor(colors.yellow)
term.setCursorPos(charX, charY)
print(char)
end
function Down()
term.setCursorPos(charX, charY)
print(" ")
charY = charY + 1
term.setTextColor(colors.yellow)
term.setCursorPos(charX, charY)
print(char)
end
function Left()
term.setCursorPos(charX, charY)
print(" ")
charX = charX - 1
term.setTextColor(colors.yellow)
term.setCursorPos(charX, charY)
print(char)
end
function Right()
term.setCursorPos(charX, charY)
print(" ")
charX = charX + 1
term.setTextColor(colors.yellow)
term.setCursorPos(charX, charY)
print(char)
end
-- End Moving Functions --
function inventory()
term.clear()
width = 1
term.clear()
term.setBackgroundColor(colors.white)
for x = 1, width do term.setCursorPos(1, x) term.clearLine() end
for x = h - width + 1, h do term.setCursorPos(1, x) term.clearLine() end
for i = 1, width do
for x = 1, h do term.setCursorPos(i, x) term.write(" ") end
for x = 1, h do term.setCursorPos(w - i + 1, x) term.write(" ") end
end
centerPrint("Inventory of "..player,2,1)
end
function shop()
term.clear()
end
function desktop()
function frame()
term.setBackgroundColor(colors.black)
width = 1
term.clear()
term.setBackgroundColor(colors.red)
for x = 1, width do term.setCursorPos(1, x) term.clearLine() end
for x = h - width + 1, h do term.setCursorPos(1, x) term.clearLine() end
for i = 1, width do
for x = 1, h do term.setCursorPos(i, x) term.write(" ") end
for x = 1, h do term.setCursorPos(w - i + 1, x) term.write(" ") end
end
end
frame()
term.setBackgroundColor(colors.black)
term.setTextColor(colors.yellow)
term.setCursorPos(charX, charY)
print(char)
while true do
e, p1, p2, p3 = os.pullEvent()
if e == "key" then
if p1 == up then
if inv == false or shop == false then
if charY > 2 then
Up()
end
end
elseif p1 == down then
if inv == false or shop == false then
if charY < h-1 then
Down()
end
end
elseif p1 == left then
if inv == false or shop == false then
if charX > 2 then
Left()
end
end
elseif p1 == right then
if inv == false or shop == false then
if charX < w-1 then
Right()
end
end
elseif p1 == i then
if inv == false then
inv = true
inventory()
else
inv = false
desktop()
end
elseif p1 == p then
if shop == false then
shop = true
shop()
else
shop = false
desktop()
end
end
end
end
end
desktop()