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.

Editing Module:Yesno

From Emergency Response: Liberty County Wiki
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
-- Imported from: https://en.wikipedia.org/wiki/Module:Yesno
-- Copied from https://www.mediawiki.org/wiki/Module:Yesno
-- License: CC-BY-SA 4.0


-- Function allowing for consistent treatment of boolean-like wikitext input.
-- Function allowing for consistent treatment of boolean-like wikitext input.
Line 5: Line 6:


return function (val, default)
return function (val, default)
-- If your wiki uses non-ascii characters for any of "yes", "no", etc., you
-- If your wiki uses non-ascii characters for any of "yes", "no", etc., you
-- should replace "val:lower()" with "string.lower(val)" in the
-- should replace "val:lower()" with "mw.ustring.lower(val)" in the
-- following line.
-- following line.
val = type(val) == 'string' and val:lower() or val
val = type(val) == 'string' and val:lower() or val
if val == nil then
if val == nil then
return nil
return nil
elseif val == true
elseif val == true
or val == 'yes'
or val == 'yes'
or val == 'y'
or val == 'y'
or val == 'true'
or val == 'true'
or val == 't'
or val == 't'
or val == 'on'
or val == 'on'
or val == 'ja'
or tonumber(val) == 1
then
or tonumber(val) == 1
return true
then
elseif val == false
return true
elseif val == false
or val == 'no'
or val == 'no'
or val == 'n'
or val == 'n'
or val == 'false'
or val == 'false'
or val == 'f'
or val == 'f'
or val == 'off'
or val == 'off'
or tonumber(val) == 0
then
or val == 'nein'
return false
or tonumber(val) == 0
else
then
return false
return default
end
else
return default
end
end
end
Please note that all contributions to Emergency Response: Liberty County Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see Meta:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)

Template used on this page:

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