Module:InventorySlot: Difference between revisions
Jump to navigation
Jump to search
(v 0.1) |
(No difference)
|
Revision as of 13:33, 8 November 2018
-- Based on work by the MC wiki: https://minecraft.gamepedia.com/
local UISlot = {}
local Sprite = require([[Module:Sprite]]):new("inventory")
function UISlot:new(item)
o = {}
setmetatable(o, {__index = self})
o:SetItem(item)
return o
end
function UISlot:SetItem(item)
self.__sprite = item and Sprite:Item(item) --nil if item = nil else get sprite
return self
end
function UISlot.Item(item)
return UISlot:new(item):GenerateHTML()
end
function UISlot:GenerateHTML ()
local slot = mw.html.create( 'div' ):addClass( 'invslot-item' )
if self.__sprite then
self.__sprite:GenerateHTML(slot)
end
return slot
end
return UISlot