Toggle menu
1
18
17
345
Emergency Response: Liberty County Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Vehicle specifications: Difference between revisions

From Emergency Response: Liberty County Wiki
Content deleted Content added
No edit summary
No edit summary
 
(17 intermediate revisions by the same user not shown)
Line 4: Line 4:
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local args = getArgs(frame)
local args = getArgs(frame)
local title = mw.uri.encode(mw.title.getCurrentTitle().text, 'WIKI');
local wikitext = '|-|General=\n{|class="wikitable vehicle-specifications-table'
local err = '|-|Error=\n\n{{error|The [[Template:Vehicle_specifications|Vehicle_specifications]] has not been configured correctly. Check the documentation for usage.}}'

if args['form_factor'] == nil then
if args['manufacturer'] then
wikitext = wikitext .. '\n|-\n|Manufacturer\n|' .. args['manufacturer']
return err
end
end

if args['model'] then
local wikitext = '|-|General=\n\n{|class="wikitable vehicle-specifications-table'
wikitext = wikitext .. '\n|-\n|Model\n|' .. args['model']

end
if args['manufacturer'] then
wikitext = wikitext .. '\n\n|-\n\n|Manufacturer\n\n|' .. args['manufacturer']
if args['trim'] then
end
wikitext = wikitext .. '\n|-\n|Trim\n|' .. args['trim']

end
if args['form_factor'] then
wikitext = wikitext .. '\n\n|-\n\n|Form factor\n\n|' .. args['form_factor']
if args['model_year'] then
end
wikitext = wikitext .. '\n|-\n|Model year\n|' .. args['model_year']
end
wikitext = wikitext .. '\n\n|}\n\n|-|Performance=\n\n{|class="wikitable vehicle-specifications-table'
if args['top_speed'] then
if args['vehicle_id'] then
wikitext = wikitext .. '\n\n|-\n\n|Top speed\n\n|' .. args['top_speed'] .. ' <small>MPH</small>'
wikitext = wikitext .. '\n|-\n|Vehicle ID\n|' .. args['vehicle_id']
end
end
if args['team'] then
wikitext = wikitext .. '\n\n|}\n\n|-|Structure=\n\n{|class="wikitable vehicle-specifications-table'
wikitext = wikitext .. '\n|-\n|Team\n|' .. args['team']
end
if args['health'] then
wikitext = wikitext .. '\n\n|-\n\n|Manufacturer\n\n|' .. args['health'] .. ' HP'
if args['form_factor'] then
end
wikitext = wikitext .. '\n|-\n|Form factor\n|' .. args['form_factor']
end
wikitext = wikitext .. '\n\n|}\n\n|-|Frame=\n\n{|class="wikitable vehicle-specifications-table'
if args['seats'] then
if args['type'] then
wikitext = wikitext .. '\n\n|-\n\n|Seats\n\n|' .. args['seats']
wikitext = wikitext .. '\n|-\n|Type\n|' .. args['type']
end
end
if args['class'] then -- Fixed case from 'Class' to 'class' for consistency
wikitext = wikitext .. '\n\n|}'
wikitext = wikitext .. '\n|-\n|Class\n|' .. args['class']
end
if args['price'] then
wikitext = wikitext .. '\n|-\n|Price\n|' .. args['price']
end
if args['discounted_price'] then
wikitext = wikitext .. '\n|-\n|Discounted price\n|' .. args['discounted_price']
end
if args['rank'] then
wikitext = wikitext .. '\n|-\n|Rank\n|' .. args['rank']
end
if not (args['form_factor'] == 'Trailer') then
wikitext = wikitext .. '\n|}\n|-|Performance=\n{|class="wikitable vehicle-specifications-table'
end
if args['top_speed'] then
wikitext = wikitext .. '\n|-\n|Top speed\n|' .. args['top_speed'] .. ' <small>MPH</small>'
end
if args['top_reverse_speed'] then
wikitext = wikitext .. '\n|-\n|Top reverse speed\n|' .. args['top_reverse_speed'] .. ' <small>MPH</small>'
end
if args['acceleration'] then
wikitext = wikitext .. '\n|-\n|Acceleration <small>(0-60)</small>\n|' .. args['acceleration'] .. ' <small>seconds</small>'
end
if args['deceleration'] then
wikitext = wikitext .. '\n|-\n|Deceleration <small>(60-0)</small>\n|' .. args['deceleration'] .. ' <small>seconds</small>'
end
if not (args['form_factor'] == 'Trailer') then
wikitext = wikitext .. '\n|}\n<div class="vehicle-charts-tabber">{{#tag:tabber|Acceleration={{#chart:' .. title .. '_acceleration.chart|data=' .. title .. '_acceleration.tab}}{{!}}-{{!}}Deceleration={{#chart:' .. title .. '_deceleration.chart|data=' .. title .. '_deceleration.tab}}}}</div>'
end
if not (args['form_factor'] == 'Trailer') then
wikitext = wikitext .. '\n|-|Structure=\n{|class="wikitable vehicle-specifications-table'
end
if args['transmission'] then
wikitext = wikitext .. '\n|-\n|Transmission\n|' .. args['transmission'] .. '<small>-speed automatic/sequential</small>'
end
if args['fuel_capacity'] then
wikitext = wikitext .. '\n|-\n|Fuel capacity\n|' .. args['fuel_capacity'] .. ' <small>gallons</small>'
end
if args['battery_size'] then
wikitext = wikitext .. '\n|-\n|Battery size\n|' .. args['battery_size'] .. ' <small>kWh</small>'
end
if args['drivetrain'] then
wikitext = wikitext .. '\n|-\n|Drivetrain\n|' .. args['drivetrain'] .. '<small>-wheel drive</small>'
end
if args['health'] then
wikitext = wikitext .. '\n|-\n|Health\n|' .. args['health'] .. ' <small>HP</small>'
end
wikitext = wikitext .. '\n|}\n|-|Frame=\n{|class="wikitable vehicle-specifications-table'
if args['seats'] then
wikitext = wikitext .. '\n|-\n|Seats\n|' .. args['seats']
end
if args['wheels'] then
wikitext = wikitext .. '\n|-\n|Wheels\n|' .. args['wheels']
end
if args['inspired_by'] and args['inspired_by_url'] then
wikitext = wikitext .. '\n|-\n|Inspired by\n|[' .. args['inspired_by_url'] .. ' ' .. args['inspired_by'] .. ']'
else
if args['inspired_by'] then
wikitext = wikitext .. '\n|-\n|Inspired by\n|' .. args['inspired_by']
end
end
wikitext = wikitext .. '\n|}'
-- Bulk semantic setting at the end: Always include all properties, setting to args value or '' (to trigger removal if previously set)
local properties = {}
local prop_map = {
{arg = 'manufacturer', prop = 'Manufacturer'},
{arg = 'model', prop = 'Model'},
{arg = 'trim', prop = 'Trim'},
{arg = 'model_year', prop = 'Model year'},
{arg = 'vehicle_id', prop = 'Vehicle ID'},
{arg = 'team', prop = 'Team'},
{arg = 'form_factor', prop = 'Form factor'},
{arg = 'type', prop = 'Type'},
{arg = 'class', prop = 'Class'},
{arg = 'price', prop = 'Price'},
{arg = 'discounted_price', prop = 'Discounted price'},
{arg = 'rank', prop = 'Rank'},
{arg = 'top_speed', prop = 'Top speed'},
{arg = 'top_reverse_speed', prop = 'Top reverse speed'},
{arg = 'acceleration', prop = 'Acceleration'},
{arg = 'deceleration', prop = 'Deceleration'},
{arg = 'transmission', prop = 'Transmission'},
{arg = 'fuel_capacity', prop = 'Fuel capacity'},
{arg = 'battery_size', prop = 'Battery size'},
{arg = 'drivetrain', prop = 'Drivetrain'},
{arg = 'health', prop = 'Health'},
{arg = 'seats', prop = 'Seats'},
{arg = 'wheels', prop = 'Wheels'},
{arg = 'inspired_by', prop = 'Inspired by'},
{arg = 'inspired_by_url', prop = 'Inspired by URL'}
}
for _, mapping in ipairs(prop_map) do
properties[mapping.prop] = args[mapping.arg] or ''
end
mw.smw.set(properties)


return wikitext
return wikitext

Latest revision as of 13:46, 12 April 2026

Module documentation[view][edit][history][purge]
This documentation is transcluded from Module:Vehicle specifications/doc. Changes can be proposed in the talk page.
Function list
L 3 — p.main

local p = {}

function p.main(frame)
    local getArgs = require('Module:Arguments').getArgs
    local args = getArgs(frame)
    local title = mw.uri.encode(mw.title.getCurrentTitle().text, 'WIKI');
    
    local wikitext = '|-|General=\n{|class="wikitable vehicle-specifications-table'
    
    if args['manufacturer'] then
        wikitext = wikitext .. '\n|-\n|Manufacturer\n|' .. args['manufacturer']
    end
    
    if args['model'] then
        wikitext = wikitext .. '\n|-\n|Model\n|' .. args['model']
    end
    
    if args['trim'] then
        wikitext = wikitext .. '\n|-\n|Trim\n|' .. args['trim']
    end
    
    if args['model_year'] then
        wikitext = wikitext .. '\n|-\n|Model year\n|' .. args['model_year']
    end
    
    if args['vehicle_id'] then
        wikitext = wikitext .. '\n|-\n|Vehicle ID\n|' .. args['vehicle_id']
    end
    
    if args['team'] then
        wikitext = wikitext .. '\n|-\n|Team\n|' .. args['team']
    end
    
    if args['form_factor'] then
        wikitext = wikitext .. '\n|-\n|Form factor\n|' .. args['form_factor']
    end
    
    if args['type'] then
        wikitext = wikitext .. '\n|-\n|Type\n|' .. args['type']
    end
    
    if args['class'] then  -- Fixed case from 'Class' to 'class' for consistency
        wikitext = wikitext .. '\n|-\n|Class\n|' .. args['class']
    end
    
    if args['price'] then
        wikitext = wikitext .. '\n|-\n|Price\n|' .. args['price']
    end
    
    if args['discounted_price'] then
        wikitext = wikitext .. '\n|-\n|Discounted price\n|' .. args['discounted_price']
    end
    
    if args['rank'] then
        wikitext = wikitext .. '\n|-\n|Rank\n|' .. args['rank']
    end
    
    if not (args['form_factor'] == 'Trailer') then
        wikitext = wikitext .. '\n|}\n|-|Performance=\n{|class="wikitable vehicle-specifications-table'
    end
    
    if args['top_speed'] then
        wikitext = wikitext .. '\n|-\n|Top speed\n|' .. args['top_speed'] .. ' <small>MPH</small>'
    end
    
    if args['top_reverse_speed'] then
        wikitext = wikitext .. '\n|-\n|Top reverse speed\n|' .. args['top_reverse_speed'] .. ' <small>MPH</small>'
    end
    
    if args['acceleration'] then
        wikitext = wikitext .. '\n|-\n|Acceleration <small>(0-60)</small>\n|' .. args['acceleration'] .. ' <small>seconds</small>'
    end
    
    if args['deceleration'] then
        wikitext = wikitext .. '\n|-\n|Deceleration <small>(60-0)</small>\n|' .. args['deceleration'] .. ' <small>seconds</small>'
    end
    
    if not (args['form_factor'] == 'Trailer') then
    	wikitext = wikitext .. '\n|}\n<div class="vehicle-charts-tabber">{{#tag:tabber|Acceleration={{#chart:' .. title .. '_acceleration.chart|data=' .. title .. '_acceleration.tab}}{{!}}-{{!}}Deceleration={{#chart:' .. title .. '_deceleration.chart|data=' .. title .. '_deceleration.tab}}}}</div>'
    end
    
    if not (args['form_factor'] == 'Trailer') then
        wikitext = wikitext .. '\n|-|Structure=\n{|class="wikitable vehicle-specifications-table'
    end
    
    if args['transmission'] then
        wikitext = wikitext .. '\n|-\n|Transmission\n|' .. args['transmission'] .. '<small>-speed automatic/sequential</small>'
    end
    
    if args['fuel_capacity'] then
        wikitext = wikitext .. '\n|-\n|Fuel capacity\n|' .. args['fuel_capacity'] .. ' <small>gallons</small>'
    end
    
    if args['battery_size'] then
        wikitext = wikitext .. '\n|-\n|Battery size\n|' .. args['battery_size'] .. ' <small>kWh</small>'
    end
    
    if args['drivetrain'] then
        wikitext = wikitext .. '\n|-\n|Drivetrain\n|' .. args['drivetrain'] .. '<small>-wheel drive</small>'
    end
    
    if args['health'] then
        wikitext = wikitext .. '\n|-\n|Health\n|' .. args['health'] .. ' <small>HP</small>'
    end
    
    wikitext = wikitext .. '\n|}\n|-|Frame=\n{|class="wikitable vehicle-specifications-table'
    
    if args['seats'] then
        wikitext = wikitext .. '\n|-\n|Seats\n|' .. args['seats']
    end
    
    if args['wheels'] then
        wikitext = wikitext .. '\n|-\n|Wheels\n|' .. args['wheels']
    end
    
    if args['inspired_by'] and args['inspired_by_url'] then 
        wikitext = wikitext .. '\n|-\n|Inspired by\n|[' .. args['inspired_by_url'] .. ' ' .. args['inspired_by'] .. ']'
    else
    	if args['inspired_by'] then
    		wikitext = wikitext .. '\n|-\n|Inspired by\n|' .. args['inspired_by']
    	end
    end
    
    wikitext = wikitext .. '\n|}'
    
    -- Bulk semantic setting at the end: Always include all properties, setting to args value or '' (to trigger removal if previously set)
    local properties = {}
    local prop_map = {
        {arg = 'manufacturer', prop = 'Manufacturer'},
        {arg = 'model', prop = 'Model'},
        {arg = 'trim', prop = 'Trim'},
        {arg = 'model_year', prop = 'Model year'},
        {arg = 'vehicle_id', prop = 'Vehicle ID'},
        {arg = 'team', prop = 'Team'},
        {arg = 'form_factor', prop = 'Form factor'},
        {arg = 'type', prop = 'Type'},
        {arg = 'class', prop = 'Class'},
        {arg = 'price', prop = 'Price'},
        {arg = 'discounted_price', prop = 'Discounted price'},
        {arg = 'rank', prop = 'Rank'},
        {arg = 'top_speed', prop = 'Top speed'},
        {arg = 'top_reverse_speed', prop = 'Top reverse speed'},
        {arg = 'acceleration', prop = 'Acceleration'},
        {arg = 'deceleration', prop = 'Deceleration'},
        {arg = 'transmission', prop = 'Transmission'},
        {arg = 'fuel_capacity', prop = 'Fuel capacity'},
        {arg = 'battery_size', prop = 'Battery size'},
        {arg = 'drivetrain', prop = 'Drivetrain'},
        {arg = 'health', prop = 'Health'},
        {arg = 'seats', prop = 'Seats'},
        {arg = 'wheels', prop = 'Wheels'},
        {arg = 'inspired_by', prop = 'Inspired by'},
        {arg = 'inspired_by_url', prop = 'Inspired by URL'}
    }
    
    for _, mapping in ipairs(prop_map) do
        properties[mapping.prop] = args[mapping.arg] or ''
    end
    
    mw.smw.set(properties)

    return wikitext
end

return p
🍪 Cookies help us deliver our services. By using our site, you agree to our use of cookies.