Login Register






Very Simple Lua Text Adventure filter_list
Author
Message
Very Simple Lua Text Adventure #1
Hello,
I made this for a competition on this site. It would have been better, but I don't have much time on my hands lately...so forgive my code...it is as of now 1 hour and 5 minutes old.

Code:
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 fuck 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 j.horne2796@gmail.com AND TELL HIM HOW MUCH YOU FUCKING LOVED THIS GAME!") print("press something to continue...") io.read() game.running = false end end end

JesseH
[Image: 2YpkRjy.png] Follow me on Twitter @jessehorne27

Reply

Very Simple Lua Text Adventure #2
Hello,
I made this for a competition on this site. It would have been better, but I don't have much time on my hands lately...so forgive my code...it is as of now 1 hour and 5 minutes old.

Code:
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 fuck 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 j.horne2796@gmail.com AND TELL HIM HOW MUCH YOU FUCKING LOVED THIS GAME!") print("press something to continue...") io.read() game.running = false end end end

JesseH
[Image: 2YpkRjy.png] Follow me on Twitter @jessehorne27

Reply

RE: Very Simple Lua Text Adventure #3
Lol the ending..

I have actually made one similar in JavaScript about a mouse trying to find the right hole to get out of a house(kinda like russian roulette actually xD)
[Image: 24pe4k8.png]

Reply

RE: Very Simple Lua Text Adventure #4
Lol the ending..

I have actually made one similar in JavaScript about a mouse trying to find the right hole to get out of a house(kinda like russian roulette actually xD)
[Image: 24pe4k8.png]

Reply

RE: Very Simple Lua Text Adventure #5
Code:
There are 1 monsters in front of you! Door 2 What will you do? attack There are 0 monsters in front of you! Door 2 What will you do?

:lol:

Code:
What will you do? move Ok son, type door1, door2, or door3....If you fudge this up, I will hit you....in the face...

Confusedurprised::epic:

I had a hard time figuring out, that move is not a command as stated in the help command. I tried variations from move door1 to move door 2 to move fucking door i don't care which one and then I just looked at the source.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: Very Simple Lua Text Adventure #6
Code:
There are 1 monsters in front of you! Door 2 What will you do? attack There are 0 monsters in front of you! Door 2 What will you do?

:lol:

Code:
What will you do? move Ok son, type door1, door2, or door3....If you fudge this up, I will hit you....in the face...

Confusedurprised::epic:

I had a hard time figuring out, that move is not a command as stated in the help command. I tried variations from move door1 to move door 2 to move fucking door i don't care which one and then I just looked at the source.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: Very Simple Lua Text Adventure #7
Hello,
Hahahaha I am going to work on it a little, and see if I can make it a bit more friendly Tongue If you have any ideas on cool things to add by all means let me know Biggrin
I will update once it is better.

JesseH
[Image: 2YpkRjy.png] Follow me on Twitter @jessehorne27

Reply