Rework auto pickup to auto item figurouter9000
This commit is contained in:
@@ -151,10 +151,10 @@ else
|
||||
quickreload.tryReloadCursorItem(PlayerInput.IsShiftDown())
|
||||
end, Hook.HookMethodType.After)
|
||||
|
||||
-- Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
-- if not PlayerInput.KeyHit(MyModGlobal.CONFIG.LOOT) then return end
|
||||
-- quickloot.tryLoot()
|
||||
-- end, Hook.HookMethodType.After)
|
||||
Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
if not PlayerInput.KeyHit(MyModGlobal.CONFIG.LOOT) then return end
|
||||
quickloot.tryLoot()
|
||||
end, Hook.HookMethodType.After)
|
||||
|
||||
Hook.Patch("Barotrauma.Character", "ControlLocalPlayer", function(instance, ptable)
|
||||
if not PlayerInput.KeyHit(MyModGlobal.CONFIG.SONAR) then return end
|
||||
|
@@ -33,32 +33,32 @@ local function getNearbyItems(source, distanceThreshold)
|
||||
-- log[#log + 1] = string.format("Item %s is in an inventory", tostring(item))
|
||||
goto continue
|
||||
end
|
||||
tags = tostring(item.Tags)
|
||||
if not string.find(tags, "item") then
|
||||
-- log[#log + 1] = string.format("Item %s is not an item (but a structure) - %s", tostring(item), tags)
|
||||
goto continue
|
||||
end
|
||||
for component in item.Components do
|
||||
-- For some God forsaken reason this does not work
|
||||
-- Not that it classifies the incorrect items
|
||||
-- But it just literally does not work
|
||||
-- The code does not execute
|
||||
-- Some of the items vanish into thin air, as if they never existed
|
||||
-- I have no idea why
|
||||
-- So we'll do this in 2 steps...
|
||||
-- if string.find(blacklistedComponents, component.Name) then
|
||||
-- log[#log + 1] = string.format("Item %s has blacklisted component %s - %s", tostring(item), component.Name, component.Name)
|
||||
-- goto continue
|
||||
-- end
|
||||
if string.find(whitelistedComponents, component.Name) then
|
||||
hasAnyOfComponent = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if not hasAnyOfComponent then
|
||||
-- log[#log + 1] = string.format("Item %s is not %s", tostring(item), whitelistedComponents)
|
||||
goto continue
|
||||
end
|
||||
-- tags = tostring(item.Tags)
|
||||
-- if not string.find(tags, "item") then
|
||||
-- -- log[#log + 1] = string.format("Item %s is not an item (but a structure) - %s", tostring(item), tags)
|
||||
-- goto continue
|
||||
-- end
|
||||
-- for component in item.Components do
|
||||
-- -- For some God forsaken reason this does not work
|
||||
-- -- Not that it classifies the incorrect items
|
||||
-- -- But it just literally does not work
|
||||
-- -- The code does not execute
|
||||
-- -- Some of the items vanish into thin air, as if they never existed
|
||||
-- -- I have no idea why
|
||||
-- -- So we'll do this in 2 steps...
|
||||
-- -- if string.find(blacklistedComponents, component.Name) then
|
||||
-- -- log[#log + 1] = string.format("Item %s has blacklisted component %s - %s", tostring(item), component.Name, component.Name)
|
||||
-- -- goto continue
|
||||
-- -- end
|
||||
-- if string.find(whitelistedComponents, component.Name) then
|
||||
-- hasAnyOfComponent = true
|
||||
-- break
|
||||
-- end
|
||||
-- end
|
||||
-- if not hasAnyOfComponent then
|
||||
-- -- log[#log + 1] = string.format("Item %s is not %s", tostring(item), whitelistedComponents)
|
||||
-- goto continue
|
||||
-- end
|
||||
|
||||
distance = getDistanceQuick(item.WorldPosition, source)
|
||||
if distance > distanceThreshold then
|
||||
@@ -74,8 +74,19 @@ local function getNearbyItems(source, distanceThreshold)
|
||||
-- print(table.concat(log, "\n"))
|
||||
|
||||
table.sort(items, function(a, b)
|
||||
return a.distance < b.distance
|
||||
return a.distance > b.distance
|
||||
end)
|
||||
local log = ""
|
||||
for _, item in pairs(items) do
|
||||
local components = ""
|
||||
for component in item.item.Components do
|
||||
components = components .. component.Name .. ", "
|
||||
end
|
||||
log = log ..
|
||||
string.format("%s d:%d t:%s c:%s\n", tostring(item.item), item.distance, tostring(item.item.Tags),
|
||||
components)
|
||||
end
|
||||
print(log)
|
||||
|
||||
-- local str = ""
|
||||
-- for _, item in pairs(items) do
|
||||
@@ -89,17 +100,17 @@ local function getNearbyItems(source, distanceThreshold)
|
||||
-- end
|
||||
-- print(str)
|
||||
|
||||
local filteredItems = {}
|
||||
for _, item in pairs(items) do
|
||||
for component in item.item.Components do
|
||||
if string.find(blacklistedComponents, component.Name) then
|
||||
goto continue
|
||||
end
|
||||
end
|
||||
filteredItems[#filteredItems + 1] = item.item
|
||||
::continue::
|
||||
end
|
||||
dump(filteredItems)
|
||||
-- local filteredItems = {}
|
||||
-- for _, item in pairs(items) do
|
||||
-- for component in item.item.Components do
|
||||
-- if string.find(blacklistedComponents, component.Name) then
|
||||
-- goto continue
|
||||
-- end
|
||||
-- end
|
||||
-- filteredItems[#filteredItems + 1] = item.item
|
||||
-- ::continue::
|
||||
-- end
|
||||
-- dump(filteredItems)
|
||||
|
||||
-- str = ""
|
||||
-- for _, item in pairs(filteredItems) do
|
||||
@@ -130,14 +141,14 @@ local function tryAoePickup()
|
||||
return
|
||||
end
|
||||
|
||||
local distanceThreshold = 2000
|
||||
local distanceThreshold = 500
|
||||
local characterPos = character.WorldPosition
|
||||
local nearbyItems = getNearbyItems(characterPos, distanceThreshold)
|
||||
|
||||
local errors = quickstack.tryMoveItems(nearbyItems, itemTree, true)
|
||||
for _, error in pairs(errors) do
|
||||
MyModGlobal.debugPrint(string.format("Error moving items: %s", error))
|
||||
end
|
||||
-- local errors = quickstack.tryMoveItems(nearbyItems, itemTree, true)
|
||||
-- for _, error in pairs(errors) do
|
||||
-- MyModGlobal.debugPrint(string.format("Error moving items: %s", error))
|
||||
-- end
|
||||
end
|
||||
|
||||
return {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<QuickInteractionsUI Absolute="[2,-457,,]" Anchor="[0,1]" BackgroundColor="255,255,255,255" BackgroundSprite="{ Path: CUI.png, SourceRect: [128,32,32,32] }" FitContent="[True,True]" IgnoreEvents="true" OutlineColor="0,0,0,0" Relative="[-0.5,0,,]" ResizibleLeft="false" ResizibleRight="false" Visible="false">
|
||||
<CUIVerticalList AKA="layout" BottomGap="0" BreakSerialization="true" FitContent="[True,True]" IgnoreEvents="true" Relative="[0,0,1,1]" Scrollable="true" Visible="false" />
|
||||
<QuickInteractionsUI Absolute="[2,-457,,]" Anchor="[0,1]" BackgroundColor="255,255,255,255" BackgroundSprite="{ Path: CUI.png, SourceRect: [128,32,32,32] }" FitContent="[True,True]" OutlineColor="0,0,0,0" Relative="[-0.5,0,,]" ResizibleLeft="false" ResizibleRight="false">
|
||||
<CUIVerticalList AKA="layout" BottomGap="0" BreakSerialization="true" FitContent="[True,True]" Relative="[0,0,1,1]" Scrollable="true" />
|
||||
</QuickInteractionsUI>
|
Reference in New Issue
Block a user