Author Topic: Cut of Nick's  (Read 1408 times)

0 Members and 1 Guest are viewing this topic.

Offline VidFamne

  • Triple Ace
  • **
  • Posts: 173
  • Karma: +2/-0
Cut of Nick's
« on: 06 June, 2004, 01:33:36 »
Here is a little code snippet ;
Code: [Select]
function Name(name)
local n = name
if strlen(n) > 18 then
n = strsub(n,1,15)
n = n.."..."
end
return n
end
to cut off very long Nick's, maybe to fit in,  in a column or whatever...
Just wonder if there is a smother way to do this.
« Last Edit: 06 June, 2004, 01:36:36 by VidFamne »

PtokaX forum

Cut of Nick's
« on: 06 June, 2004, 01:33:36 »

Offline NotRabidWombat

  • Lord
  • ***
  • Posts: 384
  • Karma: +2/-0
(No subject)
« Reply #1 on: 06 June, 2004, 07:59:22 »
It's late, so I'm just going to throw out an idea without testing.

format("%"..width.."s", name);

It *should* behave like printf, allowing you to make nice columns. Only problem is you can't have the "...".

-NotRabidWombat


I like childish behavior. Maybe this post will be deleted next.

Offline VidFamne

  • Triple Ace
  • **
  • Posts: 173
  • Karma: +2/-0
(No subject)
« Reply #2 on: 06 June, 2004, 23:22:18 »
Doesn't ;
Code: [Select]
format("%"..width.."s", name); tell where the name begins?
E.g. 12 character from the begining, if width is 12 .
I'm not so familiar with function format.
**Edit
Hmm, change my mind ;))
format(%1.18s,name)
will do the job, to cut off the string.
« Last Edit: 07 June, 2004, 02:06:27 by VidFamne »

PtokaX forum

(No subject)
« Reply #2 on: 06 June, 2004, 23:22:18 »