Jump to content

Recommended Posts

I have a small problem that i need tweaking, right now I used Koma's Friendship mod and edited it so that it also works on my custom chester. Basically what it does is make it impossible for anyone to rummage the chester without the eyebone in the characters inventory.

 

But someone earlier today told me that they can still access the custom chester as long as you hover an item over the chester to put an item inside it. Turns out to be true, is there a fix for this?

 

 

The code:

local old_RUMMAGE = GLOBAL.ACTIONS.RUMMAGE.fn GLOBAL.ACTIONS.RUMMAGE.fn = function(act)    if act.target and act.target.prefab == "personal_dogoo" then          print("GLOBAL.ACTIONS.RUMMAGE--"..tostring(act.doer.components.inventory))        result = act.doer.components.inventory:FindItem(function(item)            if item.prefab == "personal_dogoo_eyebone" then                print("GLOBAL.ACTIONS.RUMMAGE--"..tostring(item).."--ok--")                return true            end        end)        if result then             return old_RUMMAGE(act)        else            print("GLOBAL.ACTIONS.RUMMAGE--"..tostring(item).."--fail--")             act.doer:DoTaskInTime(1, function ()                act.doer.components.talker:Say("No Can Do!")            end)            return false        end    else        return old_RUMMAGE(act)    endend

 

This is for my character mod Plutia

Edited by rons0n

@rons0n

That's because opening a chest isn't the same as storing an item in it. So what you want to do is to modify STORE instead of RUMMAGE.

Try with this:

local function HasDogooBone(doer)	if doer.components.inventory and doer.components.inventory:FindItem(function(item)            if item.prefab == "personal_dogoo_eyebone" then return true end		end) ~= nil then		return true	else		return false	endendlocal oldACTIONSTORE = GLOBAL.ACTIONS.STORE.fnGLOBAL.ACTIONS.STORE.fn = function(act)	if act.target and act.target.prefab == "personal_dogoo" and act.target.components.container ~= nil and act.invobject.components.inventoryitem ~= nil and act.doer.components.inventory ~= nil then		print(act.doer.name,"is trying to do something with a Dogoo")		if HasDogooBone(act.doer) then			print(act.doer.name,"has Dogoo Bone, proceed")			return oldACTIONSTORE(act)		else			print(act.doer.name,"doesn't has the Dogoo Bone, exit")			if act.doer.components.talker then act.doer.components.talker:Say("No Can Do!") end                        return true		end    else		return oldACTIONSTORE(act)    endend
Edited by Ryuushu

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...