Difference between revisions of "Module:DetectWeaponType"
Jump to navigation
Jump to search
(use this module for check weapon type) |
m (firerate doesn't exists.) |
||
Line 4: | Line 4: | ||
healing, [impactdelay|range|knockback] = medmelee | healing, [impactdelay|range|knockback] = medmelee | ||
impactdelay|range|knockback = melee | impactdelay|range|knockback = melee | ||
healing, [ | healing, [reload|minspread|maxspread] = medgun | ||
reload|minspread|maxspread = gun | |||
healing = medtool (if medmelee and medgun failed.) | healing = medtool (if medmelee and medgun failed.) | ||
Line 30: | Line 30: | ||
return "melee" | return "melee" | ||
-- The same as above, but if is a gun with healing. | -- The same as above, but if is a gun with healing. | ||
elseif frame.args["healing"] and (frame.args["firerate"] or frame.args[" | elseif frame.args["healing"] and (--[[frame.args["firerate"] or ]] frame.args["minspread"] or frame.args["reload"] or frame.args["maxspread"]) then | ||
return "medgun" | return "medgun" | ||
-- Check if is a gun. | -- Check if is a gun. | ||
elseif frame.args["firerate"] or frame.args[" | elseif --[[frame.args["firerate"] or ]] frame.args["minspread"] or frame.args["reload"]or frame.args["maxspread"] then | ||
return "gun" | return "gun" | ||
-- Since all conditions above haven been parsed, then it will check if repair | -- Since all conditions above haven been parsed, then it will check if repair |
Revision as of 17:53, 23 December 2021
This module is used by Template:Infobox_Weapon, this will return the weapon type if one of values if filled.
Usage
Parameter | Result |
---|---|
reload minspread maxspread |
gun |
impactdelay range knockback |
melee |
any gun value + healing | medgun |
any melee value + healing | medmelee |
healing (without healing values) | medtool |
repair | repairtool |
else (If any of values above fails) | unknown |
forcereturn | (the value of forcereturn is returned always.) |
--[[ Module for detecting weapon type Parameters: healing, [impactdelay|range|knockback] = medmelee impactdelay|range|knockback = melee healing, [reload|minspread|maxspread] = medgun reload|minspread|maxspread = gun healing = medtool (if medmelee and medgun failed.) repair = repairtool Others parameters: forcereturn: force the function to return the value inputted ; e.g.: p.GetWeaponType({args={healing=30,impactdelay=30,repair=30,forcereturn="medtool"}}) else: happens if all conditions fail; by default "unknown" ]] local p = {} -- p stands for package function p.GetWeaponType( frame ) -- Check if frame exists (to avoid errors) -- if not frame then return end if not frame.args then return end -- Check if "forcereturn" exists, if so, it will return itself. if frame.args["forcereturn"] then return frame.args["forcereturn"] end -- It should happen on starting, since it includes "and" comparison -- Check if is a melee with healing. if frame.args["healing"] and (frame.args["impactdelay"] or frame.args["range"] or frame.args["knockback"]) then return "medmelee" -- Check if is melee. elseif frame.args["impactdelay"] or frame.args["range"] or frame.args["knockback"] then return "melee" -- The same as above, but if is a gun with healing. elseif frame.args["healing"] and (--[[frame.args["firerate"] or ]] frame.args["minspread"] or frame.args["reload"] or frame.args["maxspread"]) then return "medgun" -- Check if is a gun. elseif --[[frame.args["firerate"] or ]] frame.args["minspread"] or frame.args["reload"]or frame.args["maxspread"] then return "gun" -- Since all conditions above haven been parsed, then it will check if repair elseif frame.args["repair"] then return "repairtool" elseif frame.args["healing"] then return "medtool" -- If all conditions fail, it will check "else". else return frame.args["else"] or "unknown" end end return p