Littlefat1213 Posted April 16, 2023 Share Posted April 16, 2023 function InvSlot:Click(stack_mod) local slot_number = self.num local character = ThePlayer local inventory = character and character.replica.inventory or nil local active_item = inventory and inventory:GetActiveItem() or nil local container = self.container local container_item = container and container:GetItemInSlot(slot_number) or nil if active_item ~= nil or container_item ~= nil then if container_item == nil then --Put active item into empty slot if container:CanTakeItemInSlot(active_item, slot_number) then if active_item.replica.stackable ~= nil and active_item.replica.stackable:IsStack() and (stack_mod or not container:AcceptsStacks()) then --Put one only container:PutOneOfActiveItemInSlot(slot_number) else --Put entire stack container:PutAllOfActiveItemInSlot(slot_number) end TheFocalPoint.SoundEmitter:PlaySound("dontstarve/HUD/click_object") else TheFocalPoint.SoundEmitter:PlaySound("dontstarve/HUD/click_negative") end elseif active_item == nil then --Take active item from slot if stack_mod and container_item.replica.stackable ~= nil and container_item.replica.stackable:IsStack() then --Take one only container:TakeActiveItemFromHalfOfSlot(slot_number) else --Take entire stack container:TakeActiveItemFromAllOfSlot(slot_number) end TheFocalPoint.SoundEmitter:PlaySound("dontstarve/HUD/click_object") elseif container:CanTakeItemInSlot(active_item, slot_number) then if container_item.prefab == active_item.prefab and container_item.AnimState:GetSkinBuild() == active_item.AnimState:GetSkinBuild() and container_item.replica.stackable ~= nil and container:AcceptsStacks() then --active_item.prefab and container_item.skinname (this does not work on clients, so we're going to use the AnimState hack instead) --Add active item to slot stack if stack_mod and active_item.replica.stackable ~= nil and active_item.replica.stackable:IsStack() and not container_item.replica.stackable:IsFull() then --Add only one container:AddOneOfActiveItemToSlot(slot_number) else --Add entire stack container:AddAllOfActiveItemToSlot(slot_number) end TheFocalPoint.SoundEmitter:PlaySound("dontstarve/HUD/click_object") elseif active_item.replica.stackable ~= nil and active_item.replica.stackable:IsStack() and not container:AcceptsStacks() then container:SwapOneOfActiveItemWithSlot(slot_number) elseif container:AcceptsStacks() or not (active_item.replica.stackable ~= nil and active_item.replica.stackable:IsStack()) then --Swap active item with slot item container:SwapActiveItemWithSlot(slot_number) TheFocalPoint.SoundEmitter:PlaySound("dontstarve/HUD/click_object") else TheFocalPoint.SoundEmitter:PlaySound("dontstarve/HUD/click_negative") end else TheFocalPoint.SoundEmitter:PlaySound("dontstarve/HUD/click_negative") end end end i just wanna adjust the activeitem count via mouse wheeling. yeah i think zoom in and zoom out is less usage most of time specially get focus on the invslot widget .I think it's easy to understand ,take one when sliding up and decrease when sliding down .But i realized the TakeActiveItemFromOneOfSlot method is not available in inventory or container although the code comments preserved.(as above code in InvSlot, the comments write "take one only" but use "TakeActiveItemFromHalfOfSlot", and the key is that we have takehalf function but no takeone function) is it hopeful to add this method by dear klei ?so that i can make it a client mod Link to comment https://forums.kleientertainment.com/forums/topic/147187-takeactiveitemfromoneofslot-is-not-available/ Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now