Module:ScriptItem: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 73: Line 73:


function p.showPropertyPage(frame)
function p.showPropertyPage(frame)
local parts = { "Value", "Settable", "Types" }
local parts = { "Value", "Settable" }
return p.showPage(frame, parts)
return p.showPage(frame, parts)
end
end


function p.showMethodPage(frame)
function p.showMethodPage(frame)
local parts = { "Parameters", "Return", "Callbacks", "Types" }
local parts = { "Parameters", "Return", "Callbacks" }
return p.showPage(frame, parts)
return p.showPage(frame, parts)
end
end
Line 91: Line 91:
local args = p.getArgs(frame)
local args = p.getArgs(frame)
local lines = p.getPageTopLines(frame)
local lines = p.getPageTopLines(frame)
table.insert(parts, 1, "Usage")
for i,part in ipairs({"Notes", "Examples", "Compatibility", "Related"}) do
for i,part in ipairs({"Notes", "Examples", "Compatibility", "Related"}) do
table.insert(parts, part)
table.insert(parts, part)
Line 583: Line 584:
end
end


function p.types(frame)
function p.usage(frame)
local args = p.getArgs(frame)
local args = p.getArgs(frame)
return p.getDerivedClassesText(frame, args.class)
return p.getDerivedClassesText(frame, args.class)
Line 823: Line 824:
}
}
local baseTypeLower = baseType:lower()
local serverTypes = {
'World', 'Train'
}
local sharedTypes = {
'Client', 'Effect', 'Event', 'Font', 'Timer', 'ReflectedFunction', 'Resource', 'Stream', 'Vec2', 'Vec3', 'Matrix4x4',
'Element', 'Transformable', 'Blip', 'Pickup', 'Entity', 'Physical','Vehicle'
}
local out = {}
local line1 = "The <span style=\"font-family: 'Source Code Pro', monospace;\">"..p.getDisplayedName(frame).."</span> "..args.type.." is used "
if args.type == 'variable' or args.type == 'function' then
line1 = line1.."globally."
elseif args.type == 'property' or args.type == 'method' then
line1 = line1.."via OO."
elseif args.type == 'event' then
line1 = line1.."via the observer pattern. [https://wiki.gtaconnected.com/HowTo/Events Read more.]"
end
table.insert(out, line1)
local getTypeSide = function(type)
for i2,type2 in ipairs(serverTypes) do
if type:lower() == type2:lower() then
return 'server'
end
end
for i2,type2 in ipairs(sharedTypes) do
if type:lower() == type2:lower() then
return 'shared'
end
end
return 'client'
end
if derivedTypes[baseTypeLower] then
if args.type ~= 'event' then
local types = p.copyTable(derivedTypes[baseTypeLower])
local baseTypeLower = baseType:lower()
local allTypes = derivedTypes[baseTypeLower] and derivedTypes[baseTypeLower] or { baseType }
local types = p.copyTable(allTypes)
table.insert(types, baseType)
table.insert(types, baseType)
for i,type in ipairs(types) do
for i,type in ipairs(types) do
Line 832: Line 869:
end
end
p.sortTable(types)
p.sortTable(types)
return "This "..args.type.." can be used on types: "..p.formatSource(table.concat(types, " "), frame)
for i,type in ipairs(types) do
else
types[i] = "{{Side|"..getTypeSide(type).."=1}} "..type
return "This "..args.type.." can only be used on type: "..p.formatType(baseType, frame)
end
table.insert(out, table.concat(types, "<br>"))
local parts = p.split(p.getDisplayedName(frame), ".")
local rows = {}
if args.type == 'variable' or args.type == 'function' then
for i=1,(#parts)-1 do
rows[i] = { "<span style=\"font-family: 'Source Code Pro', monospace;\">"..p.properCase(parts[i]).."</span>", "namespace" }
end
rows[#parts] = { "<span style=\"font-family: 'Source Code Pro', monospace;\">"..p.properCase(parts[#parts]).."</span>", p.properCase(args.type) }
elseif args.type == 'property' or args.type == 'method' then
rows[0] = { "<span style=\"font-family: 'Source Code Pro', monospace;\">"..p.properCase(parts[0]).."</span>", "Object (JS Object, Lua Userdata, Squirrel Userdata)" }
rows[1] = { "<span style=\"font-family: 'Source Code Pro', monospace;\">"..p.properCase(parts[1]).."</span>", p.properCase(args.type) }
end
if #rows > 0 then
table.insert(out, p.table(false, rows, { 80, 400 }, false))
end
end
end
return table.concat(out, "<br>\n")
end
end


6,834

edits

Navigation menu