-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
34 lines (32 loc) · 907 Bytes
/
Copy pathmain.lua
File metadata and controls
34 lines (32 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require("game")
require("data")
print("Welcome to LuaQuest! Type 'help' for commands.")
describe_location()
while true do
io.write("\n> ")
local input = io.read()
if input == "help" then
print("Commands: move <direction>, pickup, fight, inventory, quit")
elseif input:match("^move") then
local dir = input:match("^move%s+(%w+)")
if dir then move(dir) end
elseif input == "pickup" then
pickup()
elseif input == "fight" then
fight()
elseif input == "inventory" then
if #player.inventory == 0 then
print("Inventory empty.")
else
print("Inventory:")
for _, item in ipairs(player.inventory) do
print("- " .. item.name)
end
end
elseif input == "quit" then
print("Goodbye!")
break
else
print("Unknown command.")
end
end