Editing Module:Silent1/sandbox
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 10: | Line 10: | ||
local data_module_names = { | local data_module_names = { | ||
− | + | item = 'Module:Items/data', | |
− | |||
other = 'Module:OtherImages/data' | other = 'Module:OtherImages/data' | ||
} | } | ||
Line 41: | Line 40: | ||
--Find the image from the name | --Find the image from the name | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
function p.findImage(name) | function p.findImage(name) | ||
local id | local id | ||
Line 76: | Line 45: | ||
local image = p.loadData('other')[name] | local image = p.loadData('other')[name] | ||
− | if | + | --If name is a number, pass in as an item ID |
− | + | if tonumber(name) then | |
+ | id = name | ||
+ | else | ||
+ | id = p.findItemID(name) | ||
+ | end | ||
+ | |||
+ | --If id is valid | ||
+ | if id then | ||
+ | local item = p.loadData('item')[id] | ||
+ | local url = item['itemImage'] | ||
+ | local icon = item['itemIcon'] | ||
+ | local realname = item['name'] | ||
+ | |||
+ | if icon then url = icon end | ||
+ | image = {name = realname, image = url} | ||
+ | |||
+ | if not (image['name'] and image['image']) then | ||
+ | image = nil | ||
+ | end | ||
end | end | ||
+ | |||
return image | return image | ||
end | end |