Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Sandbox/alistair3149

From the Star Citizen Wiki, the fidelity™ encyclopedia
Module documentation[view][edit][history][purge]
This documentation is transcluded from Module:Sandbox/alistair3149/doc. Changes can be proposed in the talk page.
Function list
L 9 — methodtable.get
L 14 — methodtable.set
L 19 — p.new
L 27 — p.template0
L 35 — p.template1
L 39 — p.template2
L 43 — p.template3

template1: set Lua error at line 36: attempt to index upvalue 'instance' (a nil value). Lua error at line 40: attempt to index upvalue 'instance' (a nil value). Lua error at line 44: attempt to index upvalue 'instance' (a nil value).


local p = {}

local metatable = {}
local methodtable = {}
local instance

metatable.__index = methodtable

function methodtable.get( self, entry, template )
    --mw.log( 'Get: ' .. self.data[entry] ?? '' )
    return string.format( '%s: get %s', template, table.concat( self.data ) )
end

function methodtable.set( self, input )
    mw.log( 'Set: ' .. input )
    table.insert( self.data, input )
end

function p.new( self )
    local instance = {
        data = {}
    }
    setmetatable( instance, metatable )
    return instance
end

function p.template0( self )
	instance = p:new()
	instance:set( 'Apple' )
	instance:set( 'Orange' )
	instance:set( 'Banana' )
	return 'template1: set'
end

function p.template1( self )
	return instance:get( 1, 'template1' )
end

function p.template2( self )
	return instance:get( 2, 'template2' )
end

function p.template3( self )
	return instance:get( 3, 'template3' )
end

return p