Module:Cargo
From PCGamingWiki, the wiki about fixing PC games
Documentation for this module may be created at Module:Cargo/doc
local p = {} -- local cargo = mw.ext.cargo -- Cheating! :D --[[ Debug console call: =p.OutputTable{args={"Infobox game","",182118}} =p.OutputTable{args={"Infobox game","debug",182118}} =p.OutputTable{args={"StarForce","",182118}} =p.OutputTable{args={"Cloud","",182118}} =p.OutputTable{args={"Video","",182118}} =p.OutputTable{args={"Input","",182118}} =p.OutputTable{args={"Audio settings","",182118}} =p.OutputTable{args={"L10n","",182118}} =p.OutputTable{args={"Multiplayer","",182118}} =p.OutputTable{args={"VR support","",182118}} =p.OutputTable{args={"API","",182118}} =p.OutputTable{args={"Middleware","",182118}} =p.OutputTable{args={"Tags","",182118}} =p.OutputTable{args={"Availability","",182118}} --]] function p.OutputTable( frame ) local pageID = mw.title.getCurrentTitle().id local table = frame.args[1] local debug = (frame.args[2] == "debug" and true or false) local overrideID = frame.args[3] -- Replace all spaces with an underscore table = mw.ustring.gsub( table, " ", "_" ) if overrideID ~= nil and overrideID ~= "" then pageID = overrideID end local definedFields = {} definedFields["Infobox_game"] = 'Cover,Cover_URL,Developers,Porters_PC_booter,Porters_DOS,Porters_Windows_3x,Porters_Windows,Porters_Mac_OS,Porters_OS_X,Porters_Linux,Publishers,Engines,Available_on,Released,Released_PC_booter,Released_DOS,Released_Windows_3x,Released_Windows,Released_Mac_OS,Released_OS_X,Released_Linux,Wrappers,Wrappers_Windows_3x,Wrappers_Windows,Wrappers_OS_X,Wrappers_Linux,Monetization,Microtransactions,Modes,Pacing,Perspectives,Controls,Genres,Sports,Vehicles,Art_styles,Themes,Series,Steam_AppID,GOGcom_ID,StrategyWiki,Wikipedia,License' definedFields["StarForce"] = 'StarForce_compatible' definedFields["Cloud"] = 'Discord,Epic_Games_Launcher,GOG_Galaxy,EA_Desktop,OneDrive,Steam,Ubisoft_Connect,Xbox' definedFields["Video"] = 'WSGF_Link,Widescreen_WSGF_award,Multimonitor_WSGF_award,Ultrawidescreen_WSGF_award,4K_Ultra_HD_WSGF_award,Widescreen_resolution,Multimonitor,Ultrawidescreen,4K_Ultra_HD,Field_of_view,Windowed,Borderless_fullscreen_windowed,Anisotropic_filtering,Antialiasing,Vsync,60_FPS,120_FPS,HDR,Ray_tracing,Color_blind' definedFields["Input"] = 'Key_remapping,Mouse_acceleration,Mouse_sensitivity,Mouse_input_in_menus,Mouse_Y_axis_inversion,Touchscreen,Controller_support,Full_controller_support,Controller_support_level,Controller_remapping,Controller_sensitivity,Controller_Y_axis_inversion,XInput_controller_support,Xbox_prompts,Xbox_One_Impulse_Triggers,DualShock_4_controller_support,DualShock_prompts,DualShock_4_light_bar_support,DualShock_4_connection_modes,Tracked_motion_controllers,Tracked_motion_controller_prompts,Other_controller_support,Other_button_prompts,Controller_hotplugging,Controller_haptic_feedback,Simultaneous_input,Steam_Input_API_support,Steam_hook_input,Steam_Input_presets,Steam_Controller_prompts,Steam_Input_mouse_cursor_detection' definedFields["Audio_settings"] = 'Separate_volume_controls,Surround_sound,Subtitles,Closed_captions,Mute_on_focus_lost,EAX_support,Red_Book_CD_audio,General_MIDI_audio' definedFields["L10n"] = 'Language,Status,Interface,Audio,Subtitles,Notes' definedFields["Multiplayer"] = 'Local,Local_players,Local_modes,LAN,LAN_players,LAN_modes,Online,Online_players,Online_modes,Asynchronous' definedFields["VR_support"] = 'Native_3D,Nvidia_3D_Vision,vorpX,vorpX_modes,VR_only,HTC_Vive,Oculus_Rift,OSVR,Windows_Mixed_Reality,Keyboard_mouse,3RD_Space_Gaming_Vest,Novint_Falcon,TrackIR,Tobii_Eye_Tracking,Play_area_seated,Play_area_standing,Play_area_room_scale' definedFields["API"] = 'Direct3D_versions,DirectDraw_versions,WinG,OpenGL_versions,Glide_versions,Software_renderer,Mantle_support,Metal_support,Vulkan_versions,DOS_video_modes,Shader_Model_versions,Windows_16bit_executable,Windows_32bit_executable,Windows_64bit_executable,Windows_ARM_app,Mac_OS_X_PowerPC_app,macOS_Intel_32bit_app,macOS_Intel_64bit_app,macOS_ARM_app,Linux_PowerPC_app,Linux_32bit_executable,Linux_64bit_executable,Linux_ARM_app' definedFields["Middleware"] = 'Physics,Audio,Interface,Input,Cutscenes,Multiplayer,Anticheat' definedFields["Tags"] = 'Stub,Cleanup,Top,Warnings,GameSpy,Always_online,Available_digitally,Config_data,Save_data,Tickcross_unknown,Settings_screenshots,Video_screenshots,Input_screenshots,Audio_screenshots,Network_screenshots,VR_screenshots' definedFields["Availability"] = 'Available_from,Available_from_historically,Uses_DRM,Removed_DRM,Retail_DRM,Retail_keys,Developer_website_DRM,Developer_website_keys,Publisher_website_DRM,Publisher_website_keys,Official_website_DRM,Official_website_keys,Amazon_US_DRM,Amazon_US_keys,Amazon_UK_DRM,Amazon_UK_keys,Battlenet_DRM,Battlenet_keys,Bethesdanet_DRM,Bethesdanet_keys,Discord_DRM,Discord_keys,EA_Desktop_DRM,EA_Desktop_keys,Epic_Games_Store_DRM,Epic_Games_Store_keys,GamersGate_DRM,GamersGate_keys,Gamesplanet_DRM,Gamesplanet_keys,GOGcom_DRM,GOGcom_keys,Green_Man_Gaming_DRM,Green_Man_Gaming_keys,Humble_Store_DRM,Humble_Store_keys,itchio_DRM,itchio_keys,Mac_App_Store_DRM,Mac_App_Store_keys,Microsoft_Store_DRM,Microsoft_Store_keys,Oculus_Store_DRM,Oculus_Store_keys,Steam_DRM,Steam_keys,Twitch_DRM,Twitch_keys,Ubisoft_Store_DRM,Ubisoft_Store_keys,Viveport_DRM,Viveport_keys,Zoom_Platform_DRM,Zoom_Platform_keys,Apple_Arcade,EA_Play,EA_Play_Pro,EA_Play_Steam,Ubisoft_Plus,Xbox_Play_Anywhere,Xbox_Game_Pass,GFWL_type,GFWL_ZDPP,GFWL_local_profile' local fields = definedFields[table] -- optional parameters are grouped in one table -- you can omit any or all of them, except join if you use more than one table local args = { where = '_pageID="' .. pageID ..'"', --join = 'table1.fieldA = table2.fieldB,table2.fieldC=table3.fieldD, etc.', --groupBy = 'table1.fieldG', --having = 'table1.fieldG="some value", etc.', --orderBy = 'table2.fieldF, etc.' --limit = some number, --offset = some number, } if debug then mw.log() mw.logObject( pageID, "pageID" ) mw.log() mw.logObject( table, "table" ) mw.log() mw.logObject( fields, "fields" ) mw.log() mw.logObject( args, "args" ) mw.log() end local results = mw.ext.cargo.query( table, fields, args ) local count = 0 local list = mw.html.create( 'div' ) list:wikitext ( "'''" .. table .. "'''" ) list:tag( 'ul' ) for row = 1, #results do local columns = results[row] count = count + 1 for k,v in pairs(columns) do --mw.log(k) --mw.log(v) list:tag( 'li' ):wikitext ( "'''" .. k .. ":''' " .. v ) if table == "L10n" and k == "Interface" then list:tag( 'br' ) end end end if count == 0 then list:tag( 'li' ):wikitext ( "''No results''" ) end return list end -- For use on: -- Home function p.HomeDisplayNews( frame ) local pageID = mw.title.getCurrentTitle().id local table = 'News' local fields = 'Date,Title,Link1,Link2,Link3,Notes,Community,Pin' -- optional parameters are grouped in one table -- you can omit any or all of them, except join if you use more than one table local args = { --where = '_pageID="' .. pageID ..'"', --join = 'table1.fieldA = table2.fieldB,table2.fieldC=table3.fieldD, etc.', --groupBy = 'table1.fieldG', --having = 'table1.fieldG="some value", etc.', orderBy = 'Pin DESC, Date DESC', limit = 6 --offset = some number, } local results = mw.ext.cargo.query( table, fields, args ) local list = mw.html.create( 'ul' ) list :css( 'margin' , '0' ) :css( 'padding', '0' ) for row = 1, #results do local columns = results[row] local li = list:tag( 'li' ) li :addClass( 'news_li' ) :addClass( 'plainlinks' ) if columns['Pin'] == 'true' then li:addClass( 'news_icon_pin' ) else li:addClass( 'news_icon_info' ) end li :wikitext( "'''" .. mw.getContentLanguage():formatDate( 'F j' , columns['Date'] ) .. "'''" ) :wikitext( ' · ' .. columns['Title'] ) if nil ~= columns['Link1'] then li:tag( 'span' ):addClass( 'news_ref' ):wikitext('[' .. columns['Link1'] .. ' [1]]') end if nil ~= columns['Link2'] then li:tag( 'span' ):addClass( 'news_ref' ):wikitext('[' .. columns['Link2'] .. ' [2]]') end if nil ~= columns['Link3'] then li:tag( 'span' ):addClass( 'news_ref' ):wikitext('[' .. columns['Link3'] .. ' [3]]') end if nil ~= columns['Notes'] then li:tag( 'span' ):addClass( 'news_ref' ):wikitext('[{{Abbr|Notes|' .. columns['Notes'] .. '}}]') end if nil ~= columns['Community'] then li:tag( 'span' ):addClass( 'news_ref' ):wikitext('[[' .. columns['Community'] .. ' Thread]]') end end return list end return p