String2Tiles

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: String2Tiles

Post by kikito »

arquivista wrote:kikito sorry to post this here because is a bit off-topic but is a doubt related with your string2Tiles. I know that this could seem so basic... ermm...
well, I was trying to quickly use your example program that use console and prints. I'm on mac and using console to see messages it's not friendly. There is a way of use "print" commands directly in app window without have to transform them all to love.graphics.print and have to put coordinates (instead of "flow" the text as in a console/terminal)?

thanks.
Well actually I think that if you give the console a chance you will find that it is actually quite suited for development in general. It is actually more friendly than not using it.

I guess you could use an array of messages to hold 'logs'. Something like this (WARNING: completely untested code)

Code: Select all

-- file log.lua
local font = -- ... load a font here
local fontHeight = font:getHeight()
local messagesPerScreen = math.floor(love.graphics.getHeight() / fontHeight) 

local logs = {}

function log(msg)
  table.insert(logs, msg)
  if #logs > messagesPerScreen then table.remove(logs, 0) end
end

function draw_log()
  love.graphics.setFont(font)
  love.graphics.setColor(255,255,255)
  for i,msg in ipairs(logs) do
    love.graphics.print(msg, 0, (i-1)*fontHeight)
  end
end
Usage:

Code: Select all

-- main.lua
require('log.lua')

function love.update(dt)
  log('potato')
  log('tomato')
end

function love.draw()
  draw_log()
end
This (if it works, I haven't tested it) should allow you to print stuff on the screen. When the screen fills up with messages, any new message should 'move the others up'. This isn't as good as the console because you can't scroll up. Once a message leaves the screen 'upwards', you've lost it. It also doesn't handle lines wider than the screen. And you can't copy and paste.

It could be refined, but seriously, I doubt that would be wise. That effort is best invested in creating your game, while you simply use the console, a wonderful tool for logging.
When I write def I mean function.
User avatar
arquivista
No longer with us
Posts: 266
Joined: Tue Jul 06, 2010 8:39 am
Location: Insert Geolocation tag here
Contact:

Re: String2Tiles

Post by arquivista »

I think was a kind of mistake that love.graphics.print must always have coords and don't let to flow text. thanxs kikito I gonna experience this solution.

Well, I don't think Console really friendly on the mac. Here we don't have -console switch to attach the console to the window....
and console here is not like plain terminal and each line is filled with extra info
Screen shot 2010-11-19 at 10.56.20 PM.png
Screen shot 2010-11-19 at 10.56.20 PM.png (87.99 KiB) Viewed 1424 times
EDITED: I'm trying to aply String2Tiles to my roguelike engine and studying if i can do a dual Ascii/Tiles system without have to use a pseudo-ascii output.
--------------------------------------------------------
To Do: Insert Signature Here
--------------------------------------------------------
User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: String2Tiles

Post by zac352 »

What the? That's not a console! It's a debug program! :shock:
Hello, I am not dead.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: String2Tiles

Post by kikito »

arquivista wrote:I think was a kind of mistake that love.graphics.print must always have coords and don't let to flow text. thanxs kikito I gonna experience this solution.

Well, I don't think Console really friendly on the mac. Here we don't have -console switch to attach the console to the window....
and console here is not like plain terminal and each line is filled with extra info
Screen shot 2010-11-19 at 10.56.20 PM.png
EDITED: I'm trying to aply String2Tiles to my roguelike engine and studying if i can do a dual Ascii/Tiles system without have to use a pseudo-ascii output.
What???

What is that thing?

EDIT (pressed the button by mistake)

ARRGH. I think I see what the problem is. Mac people call "console" to some weird log-viewing app.

Ok that is SO WRONG.

Consoles are not log-viewers for the rest of the world. When you hear "Console" on this forum, and pretty much any other programming place, what they mean is a "Terminal".
  • Open the mac Terminal (also called console by the rest of the world)
  • Go to the folder where your game is, with cd your/game/path
  • Execute love . (notice the dot at the end)
You should get a simple text outputted on that console if you do it like that.
Last edited by kikito on Fri Nov 19, 2010 11:25 pm, edited 2 times in total.
When I write def I mean function.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: String2Tiles

Post by Robin »

arquivista wrote:I think was a kind of mistake that love.graphics.print must always have coords and don't let to flow text. thanxs kikito I gonna experience this solution.
It's not so much of a mistake when you realise LÖVE is a game framework and not a terminal emulator. ;)
arquivista wrote:Well, I don't think Console really friendly on the mac. Here we don't have -console switch to attach the console to the window....
and console here is not like plain terminal and each line is filled with extra info
What, don't you have a Terminal.app or something? I use that when on one of the Macs @ uni.
Help us help you: attach a .love.
User avatar
arquivista
No longer with us
Posts: 266
Joined: Tue Jul 06, 2010 8:39 am
Location: Insert Geolocation tag here
Contact:

Re: String2Tiles

Post by arquivista »

Robin wrote:
arquivista wrote:I think was a kind of mistake that love.graphics.print must always have coords and don't let to flow text. thanxs kikito I gonna experience this solution.
It's not so much of a mistake when you realise LÖVE is a game framework and not a terminal emulator. ;)
arquivista wrote:Well, I don't think Console really friendly on the mac. Here we don't have -console switch to attach the console to the window....
and console here is not like plain terminal and each line is filled with extra info
What, don't you have a Terminal.app or something? I use that when on one of the Macs @ uni.
Lol, but ascii text games are also games. :)
Really first time I used love.graphics.print command I found very strange don't let to output without coords.

Yeah but it seems print command is not outputed to terminal.app but to the console.app. I spent some time with terminal open waiting for output there! Only then checked console.app :D
--------------------------------------------------------
To Do: Insert Signature Here
--------------------------------------------------------
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: String2Tiles

Post by kikito »

arquivista wrote:Yeah but it seems print command is not outputed to terminal.app but to the console.app. I spent some time with terminal open waiting for output there! Only then checked console.app :D
Even when you execute love directly from the terminal?
When I write def I mean function.
User avatar
arquivista
No longer with us
Posts: 266
Joined: Tue Jul 06, 2010 8:39 am
Location: Insert Geolocation tag here
Contact:

Re: String2Tiles

Post by arquivista »

kikito wrote:
arquivista wrote:Yeah but it seems print command is not outputed to terminal.app but to the console.app. I spent some time with terminal open waiting for output there! Only then checked console.app :D
Even when you execute love directly from the terminal?
yeah, I tried from terminal "open test.love" It opens and run like it should do but still not outputting to terminal, but still does to the console. see why isn't really friendly? :D
--------------------------------------------------------
To Do: Insert Signature Here
--------------------------------------------------------
User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: String2Tiles

Post by zac352 »

The linux terminal, to me, is practically my best friend. :3
Hello, I am not dead.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: String2Tiles

Post by Robin »

arquivista wrote:yeah, I tried from terminal "open test.love" It opens and run like it should do but still not outputting to terminal, but still does to the console. see why isn't really friendly? :D
You probably see something like

Code: Select all

$ open test.love
$
right?

It means LÖVE can't talk to the terminal using "open'. Try love test.love
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 3 guests