Module:SlabStuff

From IdleOn MMO Wiki
Revision as of 15:32, 20 January 2023 by Kiokurashi (talk | contribs) (Created page with "local slab = {} function slab.slabOrderList(frame) local bigList = frame.args.OrderList local tableList = explode(bigList, ',') local ret = '' for i = 1, #tableList do mw.ext.VariablesLua.vardefine('Slaborder', i - 1) ret = ret .. '{{SlabOrder/store|Item=' .. tableList[i] .. '|Number=' .. i-1 .. '}}' end return ret end function slab.SlabNumGrab(frame) local item = frame.args.Item local tables = 'SlabOrder' local fields = 'Number' local args = {...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:SlabStuff/doc

local slab = {}

function slab.slabOrderList(frame) 
	local bigList = frame.args.OrderList
	local tableList = explode(bigList, ',')
	local ret = ''
	for i = 1, #tableList do
		mw.ext.VariablesLua.vardefine('Slaborder', i - 1)
		ret = ret .. '{{SlabOrder/store|Item=' .. tableList[i] .. '|Number=' .. i-1 .. '}}'
	end
	
	return ret
end

function slab.SlabNumGrab(frame)
	local item = frame.args.Item
	local tables = 'SlabOrder'
    local fields = 'Number'
    local args = {
        where = 'SlabOrder.Item="'.. item ..'"',
		orderBy = 'SlabOrder.Number',
		default = ''
    }
    local results = cargo.query( tables, fields, args )
    if #results == 0 then return '' end -- if no results, return original string and continue.
    mw.ext.VariablesLua.vardefine('SlabNum', results[1].Number)
    return ''
end

return slab