Skip to content

Commit 0791585

Browse files
authored
Create main.lua
1 parent 7c1fe59 commit 0791585

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

luaquest/main.lua

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
require("game")
2+
require("data")
3+
4+
print("Welcome to LuaQuest! Type 'help' for commands.")
5+
describe_location()
6+
7+
while true do
8+
io.write("\n> ")
9+
local input = io.read()
10+
if input == "help" then
11+
print("Commands: move <direction>, pickup, fight, inventory, quit")
12+
elseif input:match("^move") then
13+
local dir = input:match("^move%s+(%w+)")
14+
if dir then move(dir) end
15+
elseif input == "pickup" then
16+
pickup()
17+
elseif input == "fight" then
18+
fight()
19+
elseif input == "inventory" then
20+
if #player.inventory == 0 then
21+
print("Inventory empty.")
22+
else
23+
print("Inventory:")
24+
for _, item in ipairs(player.inventory) do
25+
print("- " .. item.name)
26+
end
27+
end
28+
elseif input == "quit" then
29+
print("Goodbye!")
30+
break
31+
else
32+
print("Unknown command.")
33+
end
34+
end

0 commit comments

Comments
 (0)