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',
+
item = 'Module:Items/data',
item = 'Module:Silent1/sandbox/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)
 
-- local id
 
-- name = string.lower(name)
 
-- local image = p.loadData('other')[name]
 
 
-- --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
 
 
-- return image
 
-- end
 
 
 
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 not image then
+
--If name is a number, pass in as an item ID
image = p.loadData('item')[name]
+
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

Please note that all contributions to Idlescape Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see IdleScape Wiki:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Template used on this page: