Anonymous user
Module:Inventory slot: Difference between revisions
m
Added p.formatDescription. Functions the same as the formatDescription() method of the class GuiContainer.
imported>Ttv pedro270707 mNo edit summary |
imported>Ttv pedro270707 m (Added p.formatDescription. Functions the same as the formatDescription() method of the class GuiContainer.) |
||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p.formatDescription(description, preferredLineLength) | |||
local lineLength = 0 | |||
local result = "" | |||
for i = 1, #description do | |||
local c = description:sub(i, i) | |||
if c == " " then | |||
if lineLength > preferredLineLength then | |||
lineLength = 0 | |||
result = result .. "\n§8" | |||
else | |||
result = result .. c | |||
end | |||
else | |||
lineLength = lineLength + 1 | |||
result = result .. c | |||
end | |||
end | |||
return result | |||
end | |||
function p.createSlot( f ) | function p.createSlot( f ) | ||