Advertisement
chekalin87

Anti-Radiation locker

Nov 23rd, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.80 KB | None | 0 0
  1. local com = require("component")
  2. local pim = com.pim
  3. local inv = pim.getInventorySize() - 4
  4. local name
  5. local count
  6. local head = pim.getStackInSlot(40)
  7.  
  8. local CH_SIDE = "north"                  -- Сторона, с которой стоит сундук
  9.  
  10. local radiation = {
  11.     "reactorUraniumSimple",
  12.     "reactorUraniumDual",
  13.     "reactorUraniumQuad",
  14.     "reactorUraniumSimpledepleted",
  15.     "reactorUraniumDualdepleted",
  16.     "reactorUraniumQuaddepleted",
  17.     "reactorMOXSimple",
  18.     "reactorMOXDual",
  19.     "reactorMOXQuad",
  20.     "reactorMOXSimpledepleted",
  21.     "reactorMOXDualdepleted",
  22.     "reactorMOXQuaddepleted",
  23.     "reactorLithiumCell",
  24.     "itemTritiumCell",
  25.     "itemUran",
  26.     "itemUran235",
  27.     "itemUran235small",
  28.     "itemUran238",
  29.     "itemMOX",
  30.     "itemPlutonium",
  31.     "itemPlutoniumSmall",
  32.     "itemRTGPellet"
  33. }
  34.  
  35. local function simile(name_item)             -- Сравнение с таблицей опасных предметов
  36.     for i = 1, #radiation do
  37.         if name_item == radiation[i] then
  38.             return true
  39.         end
  40.     end
  41.     return false
  42. end
  43.  
  44. if head ~= nil and head.name == "itemArmorHazmatHelmet" then
  45.    
  46.     for i = 1, inv do
  47.         name = pim.getStackInSlot(i)
  48.         if name ~= nil and simile(name.name) then
  49.             count = name.qty                              -- Количество итемов в слоте инвентаря
  50.             local shest_slot = 8                            -- Кууда будет помещён итем
  51.             local sum = count
  52.             repeat  
  53.                 shest_slot = shest_slot + 1            
  54.                 count = count - pim.pushItemIntoSlot(CH_SIDE, i, 64, shest_slot)
  55.             until  count == 0
  56.             print(name.display_name .. " " .. sum .. " шт. было сброшено в сундук.")      
  57.         end
  58.     end
  59.    
  60.     pim.pushItemIntoSlot(CH_SIDE, 40, 1, 1)         -- Снимаем защитный костюм, одеваем свою бронь
  61.     pim.pushItemIntoSlot(CH_SIDE, 39, 1, 2)
  62.     pim.pushItemIntoSlot(CH_SIDE, 38, 1, 3)
  63.     pim.pushItemIntoSlot(CH_SIDE, 37, 1, 4)
  64.    
  65.     pim.pullItemIntoSlot(CH_SIDE, 5, 1, 40)
  66.     pim.pullItemIntoSlot(CH_SIDE, 6, 1, 39)
  67.     pim.pullItemIntoSlot(CH_SIDE, 7, 1, 38)
  68.     pim.pullItemIntoSlot(CH_SIDE, 8, 1, 37)
  69. else                                                -- Снимаем бронь, одеваем защитный костюм
  70.     pim.pushItemIntoSlot(CH_SIDE, 40, 1, 5)
  71.     pim.pushItemIntoSlot(CH_SIDE, 39, 1, 6)
  72.     pim.pushItemIntoSlot(CH_SIDE, 38, 1, 7)
  73.     pim.pushItemIntoSlot(CH_SIDE, 37, 1, 8)
  74.    
  75.     pim.pullItemIntoSlot(CH_SIDE, 1, 1, 40)
  76.     pim.pullItemIntoSlot(CH_SIDE, 2, 1, 39)
  77.     pim.pullItemIntoSlot(CH_SIDE, 3, 1, 38)
  78.     pim.pullItemIntoSlot(CH_SIDE, 4, 1, 37)
  79. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement