Module:ScriptItem: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(20 intermediate revisions by 3 users not shown)
Line 37: Line 37:
p.categoryWords = {
p.categoryWords = {
-- Category Names. (String(s) to look for in an item name, case-INsensitive.)
-- Category Names. (String(s) to look for in an item name, case-INsensitive.)
'Blip', 'Building', 'Camera', 'Chatbox', 'Civilian', 'Cheat', 'Client', 'Command', 'Cursor', 'Debug', 'Dodo',
'Blip', 'Building', 'Camera', 'Chatbox', 'Cheat', 'Client', 'Command', 'Cursor', 'Debug', 'Dodo',
'Element', 'Entity', 'Event', 'File', 'Font', 'Garage', 'HTTP', 'HUD', 'Key', 'Mission', 'Mouse', 'Network', 'Object',
'Element', 'Entity', 'Event', 'File', 'Font', 'Garage', 'HTTP', 'HUD', 'Key', 'Mission', 'Mouse', 'NetFlags', 'Network', 'Object',
'Pause', 'Ped', 'Pickup', 'Player', 'Process', 'Render', 'Resource', 'Screen', 'Socket', 'Sphere', 'Time', 'Transformable', 'Vehicle', 'Weather', 'World'
'Pause', 'Ped', 'Pickup', 'Player', 'Process', 'Render', 'Resource', 'Screen', 'Socket', 'Sphere', 'Time', 'Vehicle', 'Weather', 'World'
}
}


Line 63: Line 63:
-- item page types
-- item page types
function p.showVariablePage(frame)
function p.showVariablePage(frame)
local parts = { "Value" }
return p.showPage(frame, { "Value" })
return p.showPage(frame, parts)
end
end


function p.showFunctionPage(frame)
function p.showFunctionPage(frame)
local parts = { "Parameters", "Return", "Callbacks" }
return p.showPage(frame, { "Parameters", "Return", "Callbacks" })
return p.showPage(frame, parts)
end
end


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


function p.showMethodPage(frame)
function p.showMethodPage(frame)
local parts = { "Parameters", "Return", "Callbacks" }
return p.showPage(frame, { "Parameters", "Return", "Callbacks" })
return p.showPage(frame, parts)
end
end


function p.showEventPage(frame)
function p.showEventPage(frame)
local parts = { "Parameters", "Attributes" }
return p.showPage(frame, { "Parameters", "Attributes" })
return p.showPage(frame, parts)
end
end


Line 93: Line 88:
table.insert(parts, "Types")
table.insert(parts, "Types")
end
end
table.insert(parts, "Symbols")
--table.insert(parts, "Symbols")
local lines = p.getPageTopLines(frame)
local lines = p.getPageTopLines(frame)
for i,part in ipairs({"Notes", "Examples", "Compatibility", "Related"}) do
for i,part in ipairs({"Notes", "Examples", "Compatibility", "Related"}) do
Line 114: Line 109:
local lines = {}
local lines = {}
table.insert(lines, frame:preprocess("{{DISPLAYTITLE:"..p.getDisplayedName(frame).."}}"))
table.insert(lines, frame:preprocess("{{DISPLAYTITLE:"..p.getDisplayedName(frame).."}}"))
    -- Added for discord embed styling
--table.insert(lines, "<meta content='"..p.getDisplayedName(frame).."' property='og:title' />"))
--table.insert(lines, "<meta content='"..p.description(frame).."' property='og:description' />"))
--table.insert(lines, "<meta content='#04C765' data-react-helmet='true' name='theme-color' />"))
table.insert(lines, "__NOTOC__"..p.getPageTopBoxes(frame).."\n")
table.insert(lines, "__NOTOC__"..p.getPageTopBoxes(frame).."\n")
table.insert(lines, "<div style='margin-top: 20px;'>Available since "..p.since(frame).."</div>\n")
table.insert(lines, "<div style='margin-top: 20px;'>Available since "..p.since(frame).."</div>\n")
Line 301: Line 302:
function p.onlineBox(frame)
function p.onlineBox(frame)
local args = p.getArgs(frame)
local args = p.getArgs(frame)
if args.sp == 'true' then
if args.sp == 'true' or args.online == 'false' then
return p.loadTemplate(frame, 'RedInformationBox', {'Offline Only',id='online'});
return p.loadTemplate(frame, 'RedInformationBox', {'Offline Only',id='online'});
elseif args.sp == 'false' or args.offline == 'false' then
return p.loadTemplate(frame, 'RedInformationBox', {'Online Only',id='online'});
else
else
return p.loadTemplate(frame, 'GreenInformationBox', {'Online and Offline',id='online'});
return p.loadTemplate(frame, 'GreenInformationBox', {'Online and Offline',id='online'});
Line 368: Line 371:
local entries = p.getIndexedArgs(frame, 'description')
local entries = p.getIndexedArgs(frame, 'description')
local startTextFirstLine = "The <span style=\"font-family: 'Source Code Pro', monospace;\">"..p.getDisplayedNameColoured(frame).."</span> "..args.type.." is "..(args.type == "event" and "invoked when" or "used to").." "
local startTextFirstLine = "The <span style=\"font-family: 'Source Code Pro', monospace;\">"..p.getDisplayedNameColoured(frame).."</span> [[HowTo/Functions|"..args.type.."]] is "..(args.type == "event" and "invoked when" or "used to").." "
for i,entry in ipairs(entries) do
for i,entry in ipairs(entries) do
Line 808: Line 811:
local args = p.getArgs(frame)
local args = p.getArgs(frame)
if p.isOOP(frame) then
if p.isOOP(frame) then
return args.class:lower().."."..args.name
return p.lowerFirstCharCase(args.class).."."..args.name
else
else
return args.name
return args.name
Line 827: Line 830:
local args = p.getArgs(frame)
local args = p.getArgs(frame)
if p.isOOP(frame) then
if p.isOOP(frame) then
return "<span style='color:"..typeRgb..";'>"..args.class:lower().."</span>.<span style='color:"..nameRgb.."';>"..args.name.."</span>"
return "<span style='color:"..typeRgb..";'>"..p.lowerFirstCharCase(args.class).."</span>.<span style='color:"..nameRgb.."';>"..args.name.."</span>"
else
else
return "<span style='color:"..nameRgb.."';>"..args.name.."</span>"
return "<span style='color:"..nameRgb.."';>"..args.name.."</span>"
Line 876: Line 879:
local derivedTypes = {
local derivedTypes = {
ped     = {'Civilian', 'Player'},
ped     = {'Player'},
physical = {'Object', 'Ped', 'Vehicle', 'Civilian', 'Player'},
physical = {'Object', 'Ped', 'Vehicle', 'Player'},
entity = {'Building', 'Physical', 'Object', 'Ped', 'Vehicle', 'Civilian', 'Player'},
entity = {'Building', 'Physical', 'Object', 'Ped', 'Vehicle', 'Player'},
transformable = {'Blip', 'Entity', 'Marker', 'Building', 'Physical', 'Object', 'Ped', 'Vehicle', 'Civilian', 'Player'},
element = {'Blip', 'Entity', 'Marker', 'Building', 'Physical', 'Object', 'Ped', 'Vehicle', 'Player'},
element = {'Transformable', 'Blip', 'Entity', 'Marker', 'Building', 'Physical', 'Object', 'Ped', 'Vehicle', 'Civilian', 'Player'}
vehicle = {'Train'},
event = {'CancellableEvent', 'KeyEvent'},
surface = {'RenderTarget', 'Texture'}
}
}
local serverTypes = {
local serverTypes = {}
'World', 'Train'
}
local sharedTypes = {
local sharedTypes = {
'Client', 'Effect', 'Event', 'Font', 'Timer', 'ReflectedFunction', 'Resource', 'Stream', 'Vec2', 'Vec3', 'Matrix4x4',
'Building', 'Client', 'Effect', 'Event', 'Timer', 'ReflectedFunction', 'Resource', 'Stream', 'Vec2', 'Vec3', 'Matrix4x4',
'Element', 'Transformable', 'Blip', 'Pickup', 'Entity', 'Physical','Vehicle'
'Element', 'Blip', 'Pickup', 'Entity', 'Physical','Vehicle', 'Train', 'XmlDocument', 'XmlElement',
'CancellableEvent', 'KeyEvent', 'Marker', 'Object', 'Ped', 'Player'
}
}
Line 953: Line 957:
rows[#parts][2] = p.properCase(args.type)
rows[#parts][2] = p.properCase(args.type)
rows[#parts][3] = #parts == 1 and 'Global' or 'Namespace: '..parts[#parts-1]
rows[#parts][3] = #parts == 1 and 'Global' or 'Namespace: '..parts[#parts-1]
rows[#parts][4] = #parts == 1 and parts[#parts]..' is a '..p.properCase(args.type)..', which exists in the global namespace.' or parts[i]..' is a '..p.properCase(args.type)..', which exists in the '..parts[#parts-1]..' namespace.'
rows[#parts][4] = #parts == 1 and parts[1]..' is a '..p.properCase(args.type)..', which exists in the global namespace.' or parts[#parts]..' is a '..p.properCase(args.type)..', which exists in the '..parts[#parts-1]..' namespace.'
elseif args.type == 'method' or args.type == 'property' then
elseif args.type == 'method' or args.type == 'property' then
local parts = p.split(p.getDisplayedName(frame), ".")
local parts = p.split(p.getDisplayedName(frame), ".")
Line 976: Line 980:
--table.insert(out, "<div style='margin-top: 20px;'></div>")
--table.insert(out, "<div style='margin-top: 20px;'></div>")
table.insert(out, "\n"..p.table(false, rows, { 120, 120, 400 }, false))
local headers = { 'Symbol Name', 'Symbol Type', 'Container', 'Description' }
table.insert(out, "\n"..p.table(headers, rows, { 120, 120, 400 }, false))
if args.type ~= 'event' then
if args.type ~= 'event' then
Line 996: Line 1,001:
line = language..' uses the '..languageSymbols[language][args.type]..' symbol to get or set a property.'
line = language..' uses the '..languageSymbols[language][args.type]..' symbol to get or set a property.'
end
end
table.insert(out, "<br>\n"..line)
table.insert(out, "<br>"..line)
end
end
end
end
Line 1,017: Line 1,022:


function p.formatSource(type, frame)
function p.formatSource(type, frame)
return frame:preprocess('<source>'..type..'</source>')
return frame:preprocess('<syntaxhighlight>'..type..'</syntaxhighlight>')
end
end


Line 1,151: Line 1,156:
function p.properCase(text)
function p.properCase(text)
return text:sub(1,1):upper()..text:sub(2):lower()
return text:sub(1,1):upper()..text:sub(2):lower()
end
function p.lowerFirstCharCase(text)
return text:sub(1,1):lower()..text:sub(2)
end
end


2,591

edits