Module:AocUtils and Template:Isdef: Difference between pages

From ZeldaMods (Breath of the Wild)
(Difference between pages)
Jump to navigation Jump to search
imported>Leoetlino
No edit summary
 
imported>Leoetlino
mNo edit summary
 
Line 1: Line 1:
local pack = {}
{{#ifeq:{{{var|+}}}|{{{var|-}}}|{{{0|}}}|{{{1|}}}}}<noinclude>
 
<templatedata>
aoc_resource_prefixes = {
{
  "^Terrain/A/AocField",
"params": {
  "^UI/StaffRollDLC/",
"0": {
  "^Map/MainField/",
"label": "Value if true",
  "^Map/MainFieldDungeon/",
"type": "string",
  "^Map/AocField/",
"suggested": true
  "^Physics/StaticCompound/AocField/",
},
  "^Physics/StaticCompound/MainFieldDungeon/",
"1": {
  "^Movie/Demo6",
"label": "Value if false",
  "^Game/AocField/",
"type": "string",
  "^NavMesh/AocField/",
"suggested": true
  "^NavMesh/MainFieldDungeon/",
},
  "^Physics/TeraMeshRigidBody/AocField/",
"var": {
  "^Voice/.*/Stream_Demo6.*/.*\.bfstm$",
"label": "Variable to test",
  "^System/AocVersion\.txt$",
"type": "string",
  "^Pack/RemainsWind.pack$",
"required": true
  "^Pack/RemainsElectric.pack$",
}
  "^Pack/RemainsWater.pack$",
},
  "^Pack/RemainsFire.pack$",
"description": "Tests if a variable is defined"
  "^Pack/FinalTrial.pack$",
}
}
 
</templatedata>
function has_aoc_dungeon_num(s)
[[Category:ZeldaMods templates]]
  local dungeon_num_str = string.match(s, "Dungeon(%d%d%d)")
</noinclude>
  if dungeon_num_str == nil then
  return false
  end
  local dungeon_num = tonumber(dungeon_num_str)
  return dungeon_num > 119
end
 
function should_use_aoc_file_device(path)
  for i, p in ipairs(aoc_resource_prefixes) do
    if string.find(path, p) then
      return true
    end
  end
  if string.find(path, "^Pack/") and string.find(path, "\.pack$") and has_aoc_dungeon_num(path) then
return true
  end
  if string.find(path, "^Map/CDungeon/") and has_aoc_dungeon_num(path) then
return true
  end
  if string.find(path, "^Physics/StaticCompound/") and has_aoc_dungeon_num(path) then
return true
  end
  if string.find(path, "^NavMesh/CDungeon/") and has_aoc_dungeon_num(path) then
return true
  end
  return false
end
 
function pack.get_aoc_canonical_path(frame)
  local path = frame.args.path
  local aoc_only = not not frame.args.aoc_only
  if not path then
  return "(unknown)"
  end
  if aoc_only or should_use_aoc_file_device(path) then
  return "Aoc/0010/" .. path
  end
  return path
end
 
return pack

Latest revision as of 20:14, 8 September 2018

Tests if a variable is defined

Template parameters

ParameterDescriptionTypeStatus
Value if true0

no description

Stringsuggested
Value if false1

no description

Stringsuggested
Variable to testvar

no description

Stringrequired