Log In  

Is there a way to determine rendered text height, knowing that said text may contain the tall rendering mode option ? I could search for the presence of "\^t" if I can find a way to express the escaped version of that.

-- always prints 6
local text = "\^thello"
local h = 6
if sub(text,1,3) == "\^t" then h = 12 end
print(h)
P#141328 2024-02-09 14:29

Apparently \^ is treated as one character. Try sub(text,1,2) == "\^t"

Edit: the special character's value is equivalent to nil so this may return false positives in cases of other special characters or nil values.

P#141331 2024-02-09 15:39 ( Edited 2024-02-09 15:40)
1

yes! you can call print off-screen and use the maxx,maxy values that it returns: https://www.lexaloffle.com/dl/docs/pico-8_manual.html#PRINT

(version 0.2.5d added the second return value)

P#141341 2024-02-09 18:37

Nice call @merwok! Didn't know about the second return value

P#141342 2024-02-09 18:50

Thanks @kozm0naut and @merwok! 2 solutions for 1. It must be Friday. :p

P#141349 2024-02-09 21:19 ( Edited 2024-02-09 21:19)

Strange. Are you sure about this? I am running 2.5g but print("hello", 0,0) definitely returns only, in the present case, 20.

> res = print("hello", 0, 0)
> ?(res)
20
P#141350 2024-02-09 21:29

My bad.

> x,y = print("hello", 0,0)
> ?(x)
20
> ?(y)
6

Sorry for noise.

P#141351 2024-02-09 21:31

no worry! let’s blame lua multivals :-p

P#141390 2024-02-11 00:30

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-18 02:55:59 | 0.049s | Q:20