-
Notifications
You must be signed in to change notification settings - Fork 0
/
luatextrpg.lua
116 lines (97 loc) · 4.32 KB
/
luatextrpg.lua
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
game = {}
game.running = true
game.state = "char_create" -- char_create == character creation | game == game loop
player = {}
player.name = ""
player.hp = 100
player.level = 1
player.class = ""
player.inventory = {}
player.classMade = false
player.dead = false
player.location = "Main Hall"
function handlePlayerLocation()
if player.location == "Main Hall" then
player.locationDescription = "You are standing in the middle of a narrow hall. There are three doors."
elseif player.location == "Door 1" then
player.locationDescription = "You are where door 1 leads good sir!"
if r == nil then r = math.random(1,5) end
player.locationDescription = "There are " .. r .. " monsters in front of you!"
elseif player.location == "Door 2" then
player.locationDescription = "You are where door 1 leads good sir!"
if r == nil then r = math.random(1,5) end
player.locationDescription = "There are " .. r .. " monsters in front of you!"
elseif player.location == "Door 3" then
player.locationDescription = "You are where door 1 leads good sir!"
if r == nil then r = math.random(1,5) end
player.locationDescription = "There are " .. r .. " monsters in front of you!"
end
end
while game.running == true do
if game.state == "char_create" then
print("Welcome to ZockRPG!\n")
print("Name your character...")
player.name = io.read()
if player.classMade == false then
print("Will you be a Human, Elf, or God? (human, elf, or god)")
print("Please type clearly..............")
player.class = io.read()
if player.class == "human" or player.class == "elf" or player.class == "god" then
player.classMade = true
else
print("Type human, elf, or god please! >_>")
end
end
print("Ok, your character name is " .. player.name .. " and you are a " .. player.class .. "!\n")
print("For command list, type 'help'...")
print("The rest you will learn on the way! Goodluck adventurer!")
print("Tell JesseH how much you love his game!")
game.state = "game"
elseif game.state == "game" then -- THIS IS THE GAME LOOP
if player.dead == false then
handlePlayerLocation()
print(player.locationDescription .. "\n" .. player.location .. "\n" .. "What will you do?")
choice = io.read()
if choice == "attack" then
if r ~= nil then
killed = math.random(1,2)
if killed == 1 then
success = true
r = r - 1
else
player.hp = player.hp - 10
success = false
end
end
elseif choice == "move" then
if player.location == "Main Hall" then
print("Ok son, type door1, door2, or door3....If you fudge this up, I will hit you....in the face...")
elseif player.location == "Door 1" then
print("Ok son, type mainhall...")
elseif player.location == "Door 2" then
print("Ok son, type mainhall...")
elseif player.location == "Door 3" then
print("Ok son, type mainhall...")
end
elseif choice == "mainhall" then
player.location = "Main Hall"
elseif choice == "door1" then
player.location = "Door 1"
elseif choice == "door2" then
player.location = "Door 2"
elseif choice == "door3" then
player.location = "Door 3"
elseif choice == "help" then
print("To move type 'move'")
print("To attack type 'attack'")
end
if player.hp == 0 then player.dead = true end
else
print("HAHAHA YOU THOUGHT THIS WAS A FULL GAME FULL OF AWESOME SHIT? YOU WERE WRONG! Anyhow.... You are dead!")
print("THANKS FOR PLAYING! EMAIL [email protected] AND TELL HIM HOW MUCH YOU FUCKING LOVED THIS GAME!")
print("press something to continue...")
io.read()
game.running = false
end
end
end