## text based game

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
supertails
Prole
Posts: 5
Joined: Sun Jul 18, 2010 5:08 am

### text based game

I know love is more designed to make 2d games but can love be used to make text based games?

Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

### Re: text based game

Here's how I would do it:

Code: Select all

text = ""

function keypressed(key)
text = text ..key
end

function love.draw()
love.graphics.drawText(text,400,300) --I KNOW ITS WRONG, JUST AN EXAMPLE.
end

And you know, it checks to see if text is a specific value...and then sets it back to "". So as a short answer: Yes, you can.

supertails
Prole
Posts: 5
Joined: Sun Jul 18, 2010 5:08 am

### Re: text based game

text = ""

function keypressed(key)
text = text ..key
end

function love.draw()
love.graphics.drawText(text,400,300) --I KNOW ITS WRONG, JUST AN EXAMPLE.
end

Do I write it word for word or like this?

text = "You're in a castle"

function keypressed(1)
text = "You're in the throne room"
end

function love.draw()
love.graphics.drawText(text,400,300)
end

Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

### Re: text based game

Unless you want a retarded sentence generator, yes.

And I mean like for the text box, that was my example, and when they pressed the "enter" key, it would send and check. If not a valid answer, say so, and if so, would direct to the right place.

supertails
Prole
Posts: 5
Joined: Sun Jul 18, 2010 5:08 am

### Re: text based game

I inserted the text and made the .love file but when ever I open it, it just shows the love tank.

Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

### Re: text based game

supertails wrote:I inserted the text and made the .love file but when ever I open it, it just shows the love tank.
That's how you shouldn't test an incomplete game. Put your script[s] in one folder, than drag that folder onto the LOVE.exe icon or the desktop shortcut.

supertails
Prole
Posts: 5
Joined: Sun Jul 18, 2010 5:08 am

### Re: text based game

I'm doing that on linux.

Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

### Re: text based game

supertails wrote:I'm doing that on linux.
Oh. Dang. Remember, my drawText thing was incorrect, and just an example. Look up on the wiki for the Hello World example to get an idea on how to ACTUALLY draw text.

As for the tank, did you name your .lua file "main.lua"?

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: text based game

Text based games in LÖVE are very graphical, because you still have to worry about vertical and horizontal placement.

My advice is to get to know LÖVE and Lua better before attempting such a text based game.

nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

### Re: text based game

It seems kind of counter-intuitive to write a text-based game in Löve, when you could just write it in pure Lua and run it in a terminal. Though I guess you could show some pretty pictures to go along with it if you were using Löve.

### Who is online

Users browsing this forum: No registered users and 23 guests