Jump to content

Recommended Posts

So, I'm making an item that after x amount of time gives you another item using the rot mechanic. Basically when the item rots, instead of giving you rot it gives you a random item, but I wanted to make it so the item is infinite. I need to know how to make it so when the item rots, it gives to you 2 items. The random item, and the item that rotted "into" the random item (sorry if that wording is complicated >.>, if it helps with clarification you could use the word "perish" instead of "rot")

Edited by Scoobie101
Link to comment
https://forums.kleientertainment.com/forums/topic/68829-all-about-rotting/
Share on other sites

17 hours ago, DarkXero said:

Here.

480 is a day's duration in seconds.

That's the kind of time you pass on to perishable.

test.lua

That was SUPER helpful and detailed, thanks! But, while we're on the topic of rotting, y'know how when wet goop gets wet it turns into "Wetter Goop" and cooked durian is "Extra Smelly Durian", and how stale ice cream is "Melting Ice Cream", is there a way I can do that with this item? So the different states of rotting are named something different (instead of stale/spoiled)?

 

EDIT: On a completely unrelated note, I'm trying to make beehive's "pickable" for players with a specific tag, and I'm trying to use:

AddPrefabPostInit("beehive", function(inst)

   
end    
end)

But no matter what I put inside the function, it tells me to put ")" near "end" (I know it's pretty off topic, but I might as well kill 2 birds with 1 post :T)

Edited by Scoobie101

All the stuff you mentioned works differently.

4 hours ago, Scoobie101 said:

when wet goop gets wet it turns into "Wetter Goop"

This uses a system that provides prefixes to strings. And it's "Very Wet Goop".

4 hours ago, Scoobie101 said:

cooked durian is "Extra Smelly Durian"

That's the full string name for durian_cooked. And durian_cooked and durian are two different prefabs.

4 hours ago, Scoobie101 said:

how stale ice cream is "Melting Ice Cream"

Handled by the GetAdjective method of EntityScript, which is the way to go here.

 

local EntityScript = GLOBAL.EntityScript
local _GetAdjective = EntityScript.GetAdjective
function EntityScript:GetAdjective()
	if self:HasTag("specialrot") then
		local ret = nil
		if self:HasTag("stale") then
			ret = "Yellow"
		elseif self:HasTag("spoiled") then
			ret = "Red"
		end
		return ret
	end
	return _GetAdjective(self)
end

And you give your item the specialrot tag to make it different from the rest.

 

4 hours ago, Scoobie101 said:

AddPrefabPostInit("beehive", function(inst)

   
end    
end)

It's either

AddPrefabPostInit("beehive", function(inst)
	-- Stuff
end)

or

local myfunction = function(inst)
	-- Stuff
end

AddPrefabPostInit("beehive", myfunction)

 

 

On 7/14/2016 at 3:24 PM, DarkXero said:

local myfunction = function(inst)

-- Stuff

end

AddPrefabPostInit("beehive", myfunction)

heheh, sorry to bug you again, but for "--stuff", to make beehives pickable I put in:

    inst:AddComponent("pickable")
    inst.components.pickable.picksound = "dontstarve/wilson/pickup_reeds"
    
    inst.components.pickable:SetUp("honey", TUNING.GRASS_REGROW_TIME)

And it works, but how would I go about making it only pickable to players with a certain tag? I've tried messing with this line I found: if GLOBAL.GetPlayer():HasTag("beewhisperer") then. But I'm not sure how to put all of this stuff into one thing...

On 16/7/2016 at 3:09 PM, Scoobie101 said:

if GLOBAL.GetPlayer():HasTag("beewhisperer") then

Useless. Think about it for a multiplayer context. Who is GetPlayer? Which player?

local ACTIONS = GLOBAL.ACTIONS
local TUNING = GLOBAL.TUNING

local function MakeItForBeeWhisperer(inst)
	local _Pick = inst.components.pickable.Pick
	inst.components.pickable.Pick = function(self, picker)
		if picker and not picker:HasTag("beewhisperer") then
			return
		end
		return _Pick(self, picker)
	end

	inst:AddTag("forbeewhisperer")
end

AddPrefabPostInit("beehive", function(inst)
	if not GLOBAL.TheWorld.ismastersim then
		return
	end

	inst:AddComponent("pickable")
	inst.components.pickable.picksound = "dontstarve/wilson/pickup_reeds"
	inst.components.pickable:SetUp("honey", TUNING.GRASS_REGROW_TIME)

	MakeItForBeeWhisperer(inst)
end)

local function RemovePickableActionFrom(t)
	local k = 0
	local pickact = ACTIONS.PICK
	for i, v in ipairs(t) do
		if v.action == pickact then
			k = i
			break
		end
	end
	if k ~= 0 then
		table.remove(t, k)
	end
end

local EntityScript = GLOBAL.EntityScript

AddComponentPostInit("playeractionpicker", function(self)
	local _SortActionList = self.SortActionList
	self.SortActionList = function(self, actions, target, useitem)
		local ret = _SortActionList(self, actions, target, useitem)
		if target and target:is_a(EntityScript) and target:HasTag("forbeewhisperer") and not self.inst:HasTag("beewhisperer") then
			RemovePickableActionFrom(ret)
		end
		return ret
	end
end)

 

Edited by DarkXero
25 minutes ago, DarkXero said:

Useless. Think about it for a multiplayer context. Who is GetPlayer? Which player?

The way I was trying to use it, I assumed it would think the person picking the beehive would be "GetPlayer", but none of the ways I tried it worked, so I guess that shows my knowledge of things ;-;.

2 hours ago, DarkXero said:

if target and target:HasTag("forbeewhisperer") and not self.inst:HasTag("beewhisperer") then

Attempt to call method 'HasTag' (a nil value), on this line. Happened when equipping Willow's Lighter as Willow (or any equipment after retest) ;3;

21 minutes ago, Scoobie101 said:

Attempt to call method 'HasTag' (a nil value), on this line. Happened when equipping Willow's Lighter as Willow (or any equipment after retest) ;3;

local EntityScript = GLOBAL.EntityScript

AddComponentPostInit("playeractionpicker", function(self)
	local _SortActionList = self.SortActionList
	self.SortActionList = function(self, actions, target, useitem)
		local ret = _SortActionList(self, actions, target, useitem)
		if target and target:is_a(EntityScript) and target:HasTag("forbeewhisperer") and not self.inst:HasTag("beewhisperer") then
			RemovePickableActionFrom(ret)
		end
		return ret
	end
end)

Replace with this.

I updated the code.

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...