Advertisement
BobMe

array map locator

Dec 24th, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. function cloneTable(original)
  2. local copy = {}
  3. for k, v in pairs(original) do
  4. if type(v) == "table" then
  5. v = cloneTable(v)
  6. end
  7. copy[k] = v
  8. end
  9. return copy
  10. end
  11.  
  12. local function findplaceonmap(tabll,location)
  13. local mp = {}
  14. local countup = 0
  15. local function find(tabl,name)
  16. for i,v in pairs(tabl) do
  17. countup = countup + 1
  18. if type(v) == "table" then
  19. table.insert(mp,{tabl,tabl[i-2]})
  20. find(v[4],name)
  21. elseif type(v) == "string" and v == name then
  22. --print(v)
  23. table.insert(mp,{tabl,v})
  24. print(countup)
  25. return cloneTable(mp)
  26. end
  27. if i == #tabl then
  28. print(mp[#mp][2])
  29. table.remove(mp,#mp)
  30. end
  31. end
  32. end
  33. local tab = find(tabll,location)
  34. local function printTable(tab)
  35. for i,v in pairs(tab) do
  36. print(v[1],v[2])
  37. end
  38. end
  39. print(#mp)
  40. printTable(mp)
  41. end
  42.  
  43.  
  44. findplaceonmap(map,"climb")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement