Profile
Name: |
CompactContent |
ID: |
2903 |
Created on: |
Thu, 06/17/2010 - 13:04 |
Updated on: |
Thu, 06/17/2010 - 20:04 |
Description: |
Shows contents of a table in a compact way.
This example shows a list with 15 entries with 5 entries per line. |
Best For
Comments
|
| | |
|
Want to try?
Add to Cookbook!
To download recipes to your cookbook, you need to have the game client running.
| |
| | |
| | |
|
-- Compact Content by Crashguard303
function CompactContent(NumSegs,field,SpacingString,ResultString,PerLine) -- shows [PerLine] contents of a table [field] per line
-- NumSegs: Length of the table
-- field: name of the table, which content is to show
-- SpacingString: String which is between two List elements
-- ResultString: String which connects field entry number with content
-- PerLine: Show this many table elements per Line
Elements=0
OutputString=""
for k=1,NumSegs do -- show content of field[1 to Numsegs]
Elements=Elements+1
if Elements>PerLine then -- creates a line break every x elemtens Per Line
Elements=1
OutputString=OutputString.."\n" -- symbol for line break
end -- if
if Elements>1 then OutputString=OutputString..SpacingString end
OutputString=OutputString..k..ResultString..field[k] -- one element
end -- k
print(OutputString) -- show content spreadsheet
end -- function
function get_field_length(field) -- checks how many entries are in a list
l=1
k=0
while (l~=nil) do
k=k+1
l=field[k]
end -- while
return (k-1)
end -- function
field={17,1,13,9,12,11,18,54,66,109,7,4,18,21,13}
FieldLength=get_field_length(field)
CompactContent(FieldLength,field," ","=",5)