「モジュール:Grid/Item」の版間の差分
ナビゲーションに移動
検索に移動
PerfectBoat (トーク | 投稿記録) (took from ftb wiki) |
PerfectBoat (トーク | 投稿記録) 編集の要約なし |
||
(同じ利用者による、間の1版が非表示) | |||
1行目: | 1行目: | ||
local p = {} | local p = {} | ||
local g = require("Module: | local g = require("Module:FTBCommon") | ||
local s = require("Module: | local s = require("Module:FTBSprite") | ||
local cn = require("Module:Grid/Crafting_Square_Numbers") | local cn = require("Module:Grid/Crafting_Square_Numbers") | ||
12行目: | 12行目: | ||
end | end | ||
output = output .. '">' | output = output .. '">' | ||
if isDict then | --if isDict then | ||
-- output = output .. '<div style="position:absolute;">' .. g.img('Grid_Ore_Dictionary.png',32,link,name) .. '</div>' | |||
end | --end | ||
output = output .. g.img(img, 32, link, name) .. '</div>' | output = output .. g.img(img, 32, link, name) .. '</div>' | ||
2022年5月22日 (日) 22:07時点における最新版
このモジュールについての説明文ページを モジュール:Grid/Item/doc に作成できます
local p = {}
local g = require("Module:FTBCommon")
local s = require("Module:FTBSprite")
local cn = require("Module:Grid/Crafting_Square_Numbers")
function p.makeItem(name, amount, img, link, tooltip, top, left, fill, isDict)
local output = '<div data-tooltip="' .. tooltip .. '" class="tooltip griditem" '
output = output .. 'style="top:' .. g.px(top) .. ';left:' .. g.px(left)
if g.isGiven(fill) then
output = output .. ';background-color:' .. fill .. ';'
end
output = output .. '">'
--if isDict then
-- output = output .. '<div style="position:absolute;">' .. g.img('Grid_Ore_Dictionary.png',32,link,name) .. '</div>'
--end
output = output .. g.img(img, 32, link, name) .. '</div>'
if amount > 1 then
output = output .. '<div data-tooltip="' .. tooltip .. '" class="tooltip gridamount" '
output = output .. 'style="top:' .. g.px(top + 16) .. ';left:' .. g.px(left - 4)
output = output .. '">' .. cn.makeCraftingNumbers(amount, link) .. '</div>'
end
return output
end
function p.main(frame)
local frame, args = g.getFrameAndArgs(frame)
if not g.isGiven(args.name) then
return ''
end
local tooltip = ''
if g.isGiven(args.chance) and tonumber(args.chance) then
local chance = tonumber(args.chance)
if chance < 0 then
chance = 0
end
if chance > 100 then
chance = 100
end
tooltip = tooltip .. chance .. '% chance of '
end
local amount = 1
if g.isGiven(args.amount) and tonumber(args.amount) then
amount = tonumber(args.amount)
end
if amount > 1 then
tooltip = tooltip .. amount .. ' '
elseif g.isGiven(args.liquid) and tonumber(args.liquid) then
local liquid = tonumber(args.liquid) * 1000
tooltip = tooltip .. liquid .. 'mB of '
end
tooltip = tooltip .. args.name
local tooltext = args.tooltext
if g.isGiven(tooltext) then
if g.isGiven(args.noname) then
tooltip = tooltext
else
tooltip = tooltext .. ' - ' .. tooltip
end
end
local image = args.image
if not g.isGiven(image) then
image = 'Grid ' .. args.name .. '.png'
end
local dict = args.dict
local isDict = false
if g.isGiven(dict) then
tooltip = dict .. ' - ' .. tooltip
isDict = true
end
local link = args.link
if not g.isGiven(link) then
if g.isGiven(dict) and
((not g.isGiven(args.dictamount)) or
tonumber(args.dictamount) > 1) then
link = dict
else
link = args.name
end
end
local top = 0
if g.isGiven(args.top) and tonumber(args.top) then
top = tonumber(args.top)
end
local left = 0
if g.isGiven(args.left) and tonumber(args.left) then
left = tonumber(args.left)
end
return p.makeItem(args.name, amount, image, link, tooltip, top, left, args.fill, isDict)
end
return p