Search the Community
Showing results for tags 'insert object'.
-
Back in the day (before build 33) I had a simple little log sled. A container that only allowed logs to be stored in it. I accomplished this by basically making a container that had 0 capacity and using a function to put the logs in the sled. Which worked great. But after build 33 this function seemed to die. Let me include the full scripts. first the script for the log sled and putting logs into it. There is a "Placebo" item as the result, it is removed automatically. Also LogSledTest is called to verify the player really has a Log Sled so I don't have to use it as part of the recipe. item LogSled { WeightReduction = 99, Weight = 9, Type = Container, Capacity = 0, DisplayName = Wooden Log Sled, Icon = LogSled, } /************************RECIPES************************/ recipe Put Log In Sled { Log, SkillRequired:Woodwork=1, Result:Placebo, OnTest:LogSledTest, CanBeDoneFromFloor:true, OnCreate:PutLogInSled, Category:Carpentry, } Next the functions (No laughing) function PutLogInSled() local player = getSpecificPlayer(0); MaxLogSledCount = player:getPerkLevel(Perks.Woodwork) * 4; print("MaxLogSledCount: " .. MaxLogSledCount); LogSledCount = 0; for i = 0, getPlayer():getInventory():getItems():size() - 1 do if getPlayer():getInventory():getItems():get(i) ~= nil and getPlayer():getInventory():getItems():get(i):getType() == "LogSled" then BagID = getPlayer():getInventory():getItems():get(i) for t = 0, BagID:getInventory():getItems():size() - 1 do if BagID:getInventory():getItems():get(t):getType() == "Log" then LogSledCount = LogSledCount + 1; end end end end LogInventoryCount = 0; for i = 0, getPlayer():getInventory():getItems():size() - 1 do if getPlayer():getInventory():getItems():get(i):getType() == "Log" then LogInventoryCount = LogInventoryCount + 1; end end print("LogSledCount: " .. LogSledCount); print("LogInventoryCount: " .. LogInventoryCount); while LogInventoryCount > 0 and LogSledCount < MaxLogSledCount do for i = 0, getPlayer():getInventory():getItems():size() - 1 do if getPlayer():getInventory():getItems():get(i) ~= nil and getPlayer():getInventory():getItems():get(i):getType() == "LogSled" then print("Made it this far"); container = getPlayer():getInventory():getItems():get(i); container:getInventory():AddItem("Base.Log"); LogSledCount = LogSledCount + 1; end end if getPlayer():getInventory():contains("Log") then getPlayer():getInventory():Remove("Log"); LogInventoryCount = LogInventoryCount - 1; end print("LogSledCount: " .. LogSledCount); print("LogInventoryCount: " .. LogInventoryCount); end if LogInventoryCount > 0 then player:Say("I can't figure out how to add more logs") end end function LogSledTest() if getPlayer():getInventory():contains("LogSled") ~= false then return true else return false end end function DLH_Functions.ErasePlacebo() if getPlayer():getInventory():contains("Placebo") then getPlayer():getInventory():Remove("Placebo"); end end Events.OnTick.Add(DLH_Functions.ErasePlacebo); All the prints kick off EXCEPT for the "Made it this far" which shows that I am somehow not able to get the id of the logsled or something to that effect. Long winded and likely an easy fix, but the poo I am throwing at the wall isn't sticking yet.