|
|
| (20 intermediate revisions by 4 users not shown) |
| Line 1: |
Line 1: |
| local p = {}
| | This page is protected from editing. Please see [[Deadlock:User pages]]. |
| local items_data = mw.loadJsonData("Data:ItemData.json")
| |
| | |
| -- {{#invoke:Sandbox|get_item_key|item name}}
| |
| function p.get_item_key(frame)
| |
| local item_name_input = frame.args[1] -- Get the item name from the template argument
| |
| if not item_name_input then
| |
| return "Error: Item name not specified."
| |
| end
| |
| | |
| item_name_input = item_name_input:lower() -- For case-independent search
| |
| | |
| -- Go through all the items and look for a name match.
| |
| for item_key, item_data in pairs(items_data) do
| |
| if item_data and item_data["Name"] then
| |
| local current_item_name = item_data["Name"]:lower()
| |
| if current_item_name == item_name_input then
| |
| return item_key -- Return the key if the name matches
| |
| end
| |
| end
| |
| end
| |
| | |
| return "Item not found." -- If nothing is found
| |
| end
| |
| | |
| return p
| |
Latest revision as of 21:01, 30 July 2026
This page is protected from editing. Please see Deadlock:User pages.