Jump to content

Character Affecting Plant Growth Rate


Recommended Posts

As the title says, I was wondering if it's possible to make a character that has the ability to affect the growth rate of plants such as berries/farms/etc. within a certain range but only affect the client (or host if the host is using that character).

 

I tried making a mod to test out a few things (before seeing if it can be implemented into a character) like changing things such as "GLOBAL.TUNING.BERRY_REGROW_TIME" but it seems to affect all players if the host has it enabled.

 

Any possible help?

Link to comment
Share on other sites

All the Lua is really flexable.
And if you based it on the way Auras work and proximity
Its probly possible....

...BUT, I think that may be something that would have to be on bushes rather than the character.
and that might be the problem.

Also since it a direct effect on the plants its might be better if it was host side.
dont worry about Host vs Client. it being Host side will not make it suddely effect all character.
...unless you wite it that way.

 but only affect the client (or host if the host is using that character).

 


Also Take a look at the prefab of this character
http://steamcommunity.com/sharedfiles/filedetails/?id=373847037

local master_postinit = function(inst)	TUNING.SEEDS_GROW_TIME = 4*TUNING.SEEDS_GROW_TIME/6	TUNING.FARM1_GROW_BONUS = TUNING.FARM1_GROW_BONUS/2	TUNING.FARM2_GROW_BONUS = TUNING.FARM1_GROW_BONUS/2	TUNING.FARM3_GROW_BONUS = TUNING.FARM1_GROW_BONUS/2	TUNING.POOP_FERTILIZE = TUNING.POOP_FERTILIZE*1.5	TUNING.POOP_SOILCYCLES = TUNING.POOP_SOILCYCLES*1.5	TUNING.GUANO_FERTILIZE = TUNING.GUANO_FERTILIZE*1.5	TUNING.GUANO_SOILCYCLES = TUNING.GUANO_SOILCYCLES*1.5end

What happens here is when 'SHE' uses or biulds or fertilizes the effect is hightened.

Stuff she plants take 33% less time.
when she fertilizes a plant the efect is 50% greater.
Not sure what "FARM1_GROW_BONUS" is but im sure you can find out in the tuning.lua


Sounds intresting.
Good luck!

Link to comment
Share on other sites

@DerpTime, no, that code what it does is the following:

 

When a Coraline prefab gets initialized, the master_postinit gets ran to create the prefab, and modifies the tuning table values.

Each Coraline that joins will make the values shorter, given the recursive definition there.

 

This effect is not wanted.

 

@FreeSpirit, what do you mean by plant growth?

When your character runs near a bush, berries pop, or if it stands near a bush, berries will pop up in 2 days instead of 3?

 

Also, what is the complete list of things affected by this?

Because farms have the grower component, and bushes the pickable one.

Link to comment
Share on other sites

When a Coraline prefab gets initialized, the master_postinit gets ran to create the prefab, and modifies the tuning table values.

Each Coraline that joins will make the values shorter, given the recursive definition there.

 

This effect is not wanted.

Dark is probly right. Im still new at this.

@DarkXero

Ok but if that true is it the 'inst.' or instance that holds stuff unique to the character?

would it be posible to ingect the edited valuse on ineraction form the character

in to the farms instance?

Maybe with the valuse in the farms

"inst.components.grower.growrate = rates[level]" ?

Link to comment
Share on other sites

@DerpTime, the inst inside the master_postinit refers to the entity created.

The only things "unique" to the character are the components that get assigned on entity generation.

 

It is possible to modify the farm/player interaction to modify the grower component of the farm inst entity. By modifying the actions related to fertilizing, for example, in actions.lua and making a special case for your character prefab.

 

It is also possible to make a special aura for the character (a function that looks for nearby entities), that interacts with nearby entities, looks if they can be grown into something (they have a pickable component, like the berrybushes, or a grower component, like the farms).

Link to comment
Share on other sites

@DerpTime, no, that code what it does is the following:

 

When a Coraline prefab gets initialized, the master_postinit gets ran to create the prefab, and modifies the tuning table values.

Each Coraline that joins will make the values shorter, given the recursive definition there.

 

This effect is not wanted.

 

@FreeSpirit, what do you mean by plant growth?

When your character runs near a bush, berries pop, or if it stands near a bush, berries will pop up in 2 days instead of 3?

 

Also, what is the complete list of things affected by this?

Because farms have the grower component, and bushes the pickable one.

 

Something like that. Think of it as how rain gives a bonus to plant growth and makes takes them less time to grow. I want the character to give off like an "aura" that gives a bonus to plants near it within a certain range, much like having "night vision" where you can change how large the circle of light can be but have a circle of effect that affect plants in this case.

 

I was also contemplating on having this character also have the ability to negate the effect of replanting stuff, making for example replanted berry bushes still act as if they haven't been replanted through the use a custom item only it can make.

Edited by FreeSpirit
Link to comment
Share on other sites

@FreeSpirit,

Rain only makes crops from farms grow faster.

It doesn't affect berry bushes.

Rain is necessary for mushrooms to grow back.

 

"Plants" is ambiguous, because they grow differently.

Berry bushes don't need light to replenish berries.

Farms do need light to grow the crop.

 

So, which plants are you talking about?

Link to comment
Share on other sites

@FreeSpirit,

Rain only makes crops from farms grow faster.

It doesn't affect berry bushes.

Rain is necessary for mushrooms to grow back.

 

"Plants" is ambiguous, because they grow differently.

Berry bushes don't need light to replenish berries.

Farms do need light to grow the crop.

 

So, which plants are you talking about?

 

I was referring saying how when you have night vision, you spawn a light that has a radius of how far the light illuminates. For the ability I want this character to have, I want to have the effect be in a radius of space around it than say have it affect the entire world (like say within 30 feet from your character).

 

As for "plants", I am just pointing to all things that grow over time, that being: Grass, Saplings, Reeds, etc.

 

For example, if I want a few of things to grow twice as fast, I could put it as:

GLOBAL.TUNING.BERRY_REGROW_TIME = (GLOBAL.TUNING.BERRY_REGROW_TIME * 0.5)GLOBAL.TUNING.GRASS_REGROW_TIME = (GLOBAL.TUNING.GRASS_REGROW_TIME * 0.5)GLOBAL.TUNING.SAPLING_REGROW_TIME = (GLOBAL.TUNING.SAPLING_REGROW_TIME * 0.5)GLOBAL.TUNING.REEDS_REGROW_TIME = (GLOBAL.TUNING.REEDS_REGROW_TIME * 0.5)GLOBAL.TUNING.FLOWER_SPAWN_TIME = (GLOBAL.TUNING.FLOWER_SPAWN_TIME * 0.5)

I want this as an ability for a character that only affect "plants" around it within a set distance near it, and not the entire world.

Edited by FreeSpirit
Link to comment
Share on other sites

	inst:DoPeriodicTask(20, function()		local x, y, z = inst.Transform:GetWorldPosition()		local ents = TheSim:FindEntities(x, y, z, 20, nil, {"player", "FX", "NOCLICK", "DECOR", "INLIMBO"}, nil)		if #ents > 0 then			for k, v in pairs(ents) do				if (v.prefab == "berrybush") or (v.prefab == "berrybush2") or (v.prefab == "grass") or (v.prefab == "sapling") or (v.prefab == "reeds") then					v.components.pickable:LongUpdate(20)				end			end		end	end)	inst:DoPeriodicTask(160, function()		local x, y, z = inst.Transform:GetWorldPosition()		x = x + math.random(31) - 16		z = z + math.random(31) - 16		local flower = SpawnPrefab("flower")		flower.Transform:SetPosition(x, y, z)	end)

Every 20 seconds, character checks for most entities on screen and updates 20 seconds on their timers, effectively doubling the times.

 

The character also spawns a flower near him every 1/3 of a day.

TUNING.FLOWER_SPAWN_TIME affects the flowerspawner component, a component that schedules flowers spawning near players on rainy days, pointless to touch it. Another alternative would be to make it so that if the character is near flowers, they multiply.

 

This doesn't affect farm crops.

Link to comment
Share on other sites

On 5/10/2015 at 8:05 PM, DarkXero said:

	inst:DoPeriodicTask(20, function()		local x, y, z = inst.Transform:GetWorldPosition()		local ents = TheSim:FindEntities(x, y, z, 20, nil, {"player", "FX", "NOCLICK", "DECOR", "INLIMBO"}, nil)		if #ents > 0 then			for k, v in pairs(ents) do				if (v.prefab == "berrybush") or (v.prefab == "berrybush2") or (v.prefab == "grass") or (v.prefab == "sapling") or (v.prefab == "reeds") then					v.components.pickable:LongUpdate(20)				end			end		end	end)	inst:DoPeriodicTask(160, function()		local x, y, z = inst.Transform:GetWorldPosition()		x = x + math.random(31) - 16		z = z + math.random(31) - 16		local flower = SpawnPrefab("flower")		flower.Transform:SetPosition(x, y, z)	end)

 

Tag this part into your if-else statement for farm plants

elseif (v.prefab == "farm_plant_potato" or v.prefab == "farm_plant_randomseed" or v.prefab == "farm_plant_carrot" or v.prefab == "farm_plant_corn" or v.prefab == "farm_plant_tomato" or v.prefab == "farm_plant_asparagus" or v.prefab == "farm_plant_eggplant" or v.prefab == "farm_plant_pumpkin" or v.prefab == "farm_plant_watermelon" or v.prefab == "farm_plant_dragonfruit" or v.prefab == "farm_plant_durian" or v.prefab == "farm_plant_garlic" or v.prefab == "farm_plant_onion" or v.prefab == "farm_plant_pepper" or v.prefab == "farm_plant_pomegranate") then
					v.components.growable:LongUpdate(20)
				end
---This is very long winded, I know, I am in the process of finding a simpiler method



"Wait, why are you commenting on a 7 year old pos-" SHUSH

Edited by Earthyburt
Link to comment
Share on other sites

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
 Share

×
  • Create New...