How to: Make straight fine lines in a view...
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

How to: Make straight fine lines in a view...

Started by NightLitch, 24 February, 2004, 21:49:36

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

NightLitch

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:
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
//NL

Skrollster

*hint* strlen() *hint*

Skrollster

#2
One way of solving it is:

Msg = Msg .. "\r\n ( "..Nick.." )"..strrep(" ", 30 - strlen(Nick)).."( "..byOP.." )"..strrep(" ", 30 - strlen(byOP)).."( "..Count.." )"..strrep(" ", 30 - strlen(Count)).."( "..Reason.." )"

NightLitch

Thx Alot Skrollster. Was thinking in that direction but didn't know how to do it.

Thx / NL
//NL

NightLitch

#4
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:
( [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 ???
//NL

NightLitch

#5
Noticed that it wasn't compatible with MS Sans Serif

But that is the standard font for the clients...
//NL

NightLitch

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

tezlo

it will only show up right with fixed fonts (all characters have the same width).. ie. terminal would work as well

Skrollster

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):

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...

Skrollster

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...

NightLitch

Thx Skrollster gonna see what I can come by.
//NL

tezlo

had the same problem the other day so i made these two functions..
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..

Skrollster

I had to try this out then i came home this was the result i had:

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

NightLitch

Nice, Nice NICE!!!!

Thx Alot!!!

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

But I had never got that out.

/NL
//NL

Skrollster

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']

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

tezlo

try to feed it strings

Skrollster

Sorry, i guess i'm just a bit tired ;)

Stravides

Seems to work :) cheers m8y

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

SMF spam blocked by CleanTalk