Page 3 of 3

Re: 6.12.2: Text Handling

Posted: Sat Jul 16, 2011 11:57 pm
by 0ion9
"It's dark. You might be eaten by an [enemy[name]]."
Cool that we don't have to quote the string indice. Isn't that ambiguous though?
For example: (this uses actual Python formatting, so it looks a little different)

Code: Select all

>>> d2 = {'str' : {'me': 22, 1: 44}, 'me':1}
>>> "{str[me]}".format(**d2)
'22'
As a point of fact, in '{indexable[XXX]}' ('[indexable[XXX]' in renpy), XXX is always a literal string key.
(whereas in my example, you might be expecting '44' as your output -- the result of looking up 'me' in the toplevel dictionary, and indexing str by that value; in the context of RenPy, 'me' would correspond to a global variable)

My point? The documentation needs to be clear on this fact, and how to deal with it.

BTW, while I was looking for a good explanation of the intention behind that behaviour, I found this: http://stackoverflow.com/questions/1012 ... -of-python
Which is quite fascinating.

EDIT: Ah, here's an explanation:
Unlike some other programming languages, you cannot embed arbitrary
expressions in format strings. This is by design - the types of
expressions that you can use is deliberately limited. Only two operators
are supported: the '.' (getattr) operator, and the '[]' (getitem)
operator. The reason for allowing these operators is that they don't
normally have side effects in non-pathological code.
...
It should be noted that the use of 'getitem' within a format string
is much more limited than its conventional usage. In the above example,
the string 'name' really is the literal string 'name', not a variable
named 'name'. The rules for parsing an item key are very simple.
If it starts with a digit, then it is treated as a number, otherwise
it is used as a string.
-- http://www.python.org/dev/peps/pep-3101/

Re: 6.12.2: Text Handling

Posted: Sun Jul 17, 2011 4:23 am
by jack_norton
Since you're working on texts, I have a suggestion (forgive me if you already have done/planned but I'm lost with lots of work recently): it would be nice if when going fullscreen the texts (when using TTF fonts) would scale using higher points. A bit like what happens with sprites, that if you have them setup at higher resolution, when you go fullscreen they're displayed using the best fit.
Right now in fullscreen the texts are just scaled up with zoom and are a bit blurry, instead if you could use a higher pt it would look much much better on people playing at high resolution screens (1280+ and up). Hope I managed to express myself :D

Re: 6.12.2: Text Handling

Posted: Sun Jul 17, 2011 5:05 am
by 0ion9
Well, IMO a non-blurry scale would also be good, when the scale factor is an integer. And it would save on texture memory if needed.

Re: 6.12.2: Text Handling

Posted: Sun Jul 17, 2011 8:09 am
by PyTom
The scaling of text is something I've considered, but it's more appropriate for Glitz (the GL improvements) than Meat (the newtext work).