Author Topic: How to: Make straight fine lines in a view...  (Read 4992 times)

0 Members and 1 Guest are viewing this topic.

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
How to: Make straight fine lines in a view...
« on: 24 February, 2004, 21:49:36 »
I want to know how to line up my List's propertly and straight...

this is mine now:

         Msg = Msg .. "\r\n ( "..Nick.." )\t( "..byOP.." )\t( "..Count.." )\t( "..Reason.." )"


outcome like this:
Code: [Select]
NXS-3 Ban Info

 ( [Local]KR ) ( [SU+]NightLitch ) ( 2 ) ( for no reason )
 ( [Local]KalleAnkasattp ) ( [SU+]NightLitch ) ( 1 ) ( for no reason )


help plz...

want it to be in straight lines no matter the nicks lenghts.

Hope for good answers.

/NL
« Last Edit: 24 February, 2004, 21:49:50 by NightLitch »
//NL

PtokaX forum

How to: Make straight fine lines in a view...
« on: 24 February, 2004, 21:49:36 »

Offline Skrollster

  • Lord
  • ***
  • Posts: 293
  • Karma: +3/-0
(No subject)
« Reply #1 on: 24 February, 2004, 23:03:01 »
*hint* strlen() *hint*

Offline Skrollster

  • Lord
  • ***
  • Posts: 293
  • Karma: +3/-0
(No subject)
« Reply #2 on: 24 February, 2004, 23:07:22 »
One way of solving it is:

Code: [Select]
Msg = Msg .. "\r\n ( "..Nick.." )"..strrep(" ", 30 - strlen(Nick)).."( "..byOP.." )"..strrep(" ", 30 - strlen(byOP)).."( "..Count.." )"..strrep(" ", 30 - strlen(Count)).."( "..Reason.." )"
« Last Edit: 24 February, 2004, 23:08:47 by Skrollster »

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #3 on: 25 February, 2004, 00:39:51 »
Thx Alot Skrollster. Was thinking in that direction but didn't know how to do it.

Thx / NL
//NL

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #4 on: 25 February, 2004, 00:45:34 »
Your fine ex. you sent. Is that supposed to work or just a hint for me do get it working in some way?`

cause with yours I get:
Code: [Select]
( [Local]KR )                     ( [SU+]NightLitch )               ( 2 )                             ( for no reason )
 ( [Local]KalleAnkasattp )         ( [SU+]NightLitch )               ( 1 )                             ( for no reason )
plz some help.


*EDITED*

HUH!!! how is that possible here and not in my client ???
« Last Edit: 25 February, 2004, 00:50:40 by NightLitch »
//NL

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #5 on: 25 February, 2004, 00:51:37 »
Noticed that it wasn't compatible with MS Sans Serif

But that is the standard font for the clients...
« Last Edit: 25 February, 2004, 00:52:00 by NightLitch »
//NL

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #6 on: 25 February, 2004, 01:09:12 »
Why is it that that ( Courier New ) is the only Font I have that lines up the line right.... why Skrollster ???

I would want it to work with MS Sans Serif...
//NL

Offline tezlo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +1/-0
(No subject)
« Reply #7 on: 25 February, 2004, 01:50:00 »
it will only show up right with fixed fonts (all characters have the same width).. ie. terminal would work as well

Offline Skrollster

  • Lord
  • ***
  • Posts: 293
  • Karma: +3/-0
(No subject)
« Reply #8 on: 25 February, 2004, 12:34:43 »
as tezlo says it only works with fixed fonts...

but you can get almost perfect by using a formula like(i know this isn't right but you might get it):

Code: [Select]
Msg = Msg .. "\r\n ( "..Nick.." )"..strrep("\t", 30/(1+strlen(Nick))).."( "..byOP.." )"..strrep("\t", 30/(1+strlen(byOP))).."( "..Count.." )"..strrep("\t", 30/(1+strlen(Count))).."( "..Reason.." )"
i'm using (1+strlen(Count)) to not devide by zero

hope you can get my thought so you can get it to work...

Offline Skrollster

  • Lord
  • ***
  • Posts: 293
  • Karma: +3/-0
(No subject)
« Reply #9 on: 25 February, 2004, 12:36:29 »
i'm in school right now so i don't know how strrep() will reakt to a real instead of an int, you might have to format it so it becomes an int instead...

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #10 on: 25 February, 2004, 16:47:39 »
Thx Skrollster gonna see what I can come by.
//NL

Offline tezlo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +1/-0
(No subject)
« Reply #11 on: 25 February, 2004, 16:59:38 »
had the same problem the other day so i made these two functions..
Code: [Select]
function pad(str, len)
local diff = len - strlen(str)
if diff <= 0 then return strsub(str, 1, len-2)..".."
else return str..strrep(" ", diff) end
end

function columnize(...)
local str = ""
for i = 1, getn(arg), 2 do str = str..pad(arg[i], arg[i+1]) end
return str
end

columnize(victim, 25, kicker, 25, count, 5, reason, 25)
maybe it helps..

Offline Skrollster

  • Lord
  • ***
  • Posts: 293
  • Karma: +3/-0
(No subject)
« Reply #12 on: 25 February, 2004, 17:04:10 »
I had to try this out then i came home this was the result i had:

Code: [Select]
function StraightLines(Nick, byOP, Count, Reason)
Msg = " ( "..Nick.." )"..strrep("\t", 40/(8+strlen(Nick))).."( "..byOP.." )"..strrep("\t", 40/(8+strlen(byOP))).."( "..Count.." )"..strrep("\t", 40/(8+strlen(Count))).."( "..Reason.." )"
return Msg
end

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #13 on: 25 February, 2004, 17:17:13 »
Nice, Nice NICE!!!!

Thx Alot!!!

Wasn't that big of a different from the first.

But I had never got that out.

/NL
//NL

Offline Skrollster

  • Lord
  • ***
  • Posts: 293
  • Karma: +3/-0
(No subject)
« Reply #14 on: 25 February, 2004, 17:26:22 »
Tezlo i get an error the i try to use your functions:

Syntax error: bad argument #1 to `strlen' (string expected, got nil)
stack traceback:
   1:  function `strlen' [C]
   2:  function `pad' at line 16 [file `C:\DC-Hub\Op-m?te\scripts\Test.lua']
   3:  function `columnize' at line 23 [file `C:\DC-Hub\Op-m?te\scripts\Test.lua']
   4:  function `OnTimer' at line 12 [file `C:\DC-Hub\Op-m?te\scripts\Test.lua']

Code: [Select]
function Main()
SetTimer(500)
StartTimer()
end

function OnTimer()
StopTimer()
Skrollster = GetItemByName("Skrollster")
Skrollster.Send = function(self, text) return Skrollster:SendData(Bot, text) end
test = "Test"
Bot = 'PtokaX'
Skrollster:SendPM(Bot,columnize(victim, 25, kicker, 25, count, 5, reason, 25))
end

function pad(str, len)
local diff = len - strlen(str)
if diff <= 0 then return strsub(str, 1, len-2)..".."
else return str..strrep(" ", diff) end
end

function columnize(...)
local str = ""
for i = 1, getn(arg), 2 do str = str..pad(arg[i], arg[i+1]) end
return str
end

Offline tezlo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +1/-0
(No subject)
« Reply #15 on: 25 February, 2004, 18:10:32 »
try to feed it strings

Offline Skrollster

  • Lord
  • ***
  • Posts: 293
  • Karma: +3/-0
(No subject)
« Reply #16 on: 25 February, 2004, 19:22:22 »
Sorry, i guess i'm just a bit tired ;)

Offline Stravides

  • Triple Ace
  • **
  • Posts: 171
  • Karma: +0/-0
(No subject)
« Reply #17 on: 26 February, 2004, 10:32:50 »
Seems to work :) cheers m8y

Code: [Select]
victim =
{
"jasdfjasdflh",
"kjasdkja",
"kjashdflkjashdflkjasdfl",
}

kicker =
{
"kjasdkja",
"kjashdflkjashdflkjasdfl",
"jasdfjasdflh",
}

count =
{
"134",
"1234",
"2",
}

reason =
{
"kjasdkja",
"kjashdflkjashdflkjasdfl",
"jasdfjasdflh",
}

function Main()
SetTimer(500)
StartTimer()
end

function OnTimer()
StopTimer()
Stravides = GetItemByName("Stravides")
Stravides.Send = function(self, text) return Stravides:SendData(Bot, text) end
test = "Test"
Bot = 'PtokaX'
for i=1,3 do
Stravides:SendPM(Bot,columnize(victim[i], 30, kicker[i], 30, count[i], 10, reason[i], 25))
end
end

function pad(str, len)
local diff = len - strlen(str)
if diff <= 0 then return strsub(str, 1, len-2)..".."
else return str..strrep(" ", diff) end
end

function columnize(...)
local str = ""
for i = 1, getn(arg), 2 do str = str..pad(arg[i], arg[i+1]) end
return str
end
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

PtokaX forum

(No subject)
« Reply #17 on: 26 February, 2004, 10:32:50 »