Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- belt = {}
- belt_id = {}
- belt_status = false
- local need_update = true
- local inventory_open = false
- local separator_spawned = false
- local separator = "separator"
- local debug = false
- local flag
- function update()
- if (need_update == false) then return end
- if debug == true and belt_status == true then get_console():execute("belt_status=false") end
- belt_status = false
- -- Ñïàâíèì ðàçäåëÿþùèé åëåìåíò
- if (separator_spawned == false) then
- alife():create(separator,
- db.actor:position(),
- db.actor:level_vertex_id(),
- db.actor:game_vertex_id(),
- db.actor:id())
- separator_spawned = true
- if debug == true then get_console():execute("separator_spawned") end
- return
- end
- belt = {}
- belt_id = {}
- flag = 0
- -- Ñêàíèðóåì èíâåíòàðü
- db.actor:inventory_for_each(scan_inv)
- need_update = false
- -- Óäàëÿåì ðàçäåëÿþùèé åëåìåíò
- db.actor:inventory_for_each(del_separator)
- separator_spawned = false
- if debug == true and belt_status == false then get_console():execute("belt_status=true") end
- belt_status = true
- if debug == true then
- for i,k in pairs(belt) do
- get_console():execute(i.."="..k)
- end
- end
- end
- -- Ïåðåáîð ïðåäìåòîâ èíâåíòàðÿ
- function scan_inv(item)
- local section = item:section()
- if section == separator then
- flag = 1
- return
- end
- if flag == 1 then
- if slot_item(item) ~= nil then
- flag = 2
- else
- insert_to_table(belt, section)
- belt_id[item:id()] = true
- end
- end
- end
- -- Äîáàâëåíèå â òàáëèöó
- function insert_to_table(tbl, section)
- if tbl[section] == nil then
- tbl[section] = 1
- else
- tbl[section] = tbl[section] + 1
- end
- end
- -- Óäàëåíèå ðàçäåëÿþùåãî ïðåäìåòà
- function del_separator(item)
- if item:section() == separator then
- local sobj = alife():object(item:id())
- if sobj then
- alife():release(sobj, true)
- end
- if debug == true then get_console():execute("separator_removed") end
- end
- end
- -- Îïðåäåëåíèå íàëå÷èÿ ïðåäìåòà â îäíîì èç ñëîòîâ
- function slot_item(item)
- for i=0,12 do
- local obj = db.actor:item_in_slot(i)
- if obj and item:id() == obj:id() then
- return i
- end
- end
- return nil
- end
- -- Ïîäíÿòèå ïðåäìåòà
- function on_item_take(item)
- if item:section() == separator then return end
- if (inventory_open == false) then
- if (separator_spawned == true) then
- db.actor:inventory_for_each(del_separator)
- separator_spawned = false
- end
- need_update = true
- if debug == true then get_console():execute("item_take") end
- end
- end
- -- Âûáðîñ ïðåäìåòà
- function on_item_drop(item)
- if item:section() == separator then return end
- if (inventory_open == false) then
- if (separator_spawned == true) then
- db.actor:inventory_for_each(del_separator)
- separator_spawned = false
- end
- need_update = true
- if debug == true then get_console():execute("item_drop") end
- end
- end
- -- Îòêðûòèå/çàêðûòèå èíâåíòàðÿ
- function on_inventory_info(info_id)
- if info_id == "ui_inventory" then
- inventory_open = true
- if debug == true then get_console():execute("inventory_open") end
- elseif info_id == "ui_inventory_hide" then
- inventory_open = false
- need_update = true
- if debug == true then get_console():execute("inventory_close") end
- end
- end
- function check_blood()
- -- if belt_status == true then
- if belt["af_blood"]~=nil and belt["af_blood"]>0 then -- òî åñòü êîãäà ïàðàìåòð ïîÿñà[af_blood] ðàâåí 1, 2, 3.. Ñêîëüêî íàâåñèøü Êàìíåé.
- amk.send_tip("Êðîâü Êàìíÿ íà ïîÿñå")
- end
- -- end
- end
- function check_backpack()
- if belt["backpack"]~=nil and belt["backpack"]>0 then
- return true
- else
- return false
- end
- end
- function check_backpackempty()
- if belt["backpack"]==nil then
- return true
- else
- return false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement