Jump to content

Recommended Posts

About the Tumbleweed, I'm not quite sure, but I can help with the wake up mobs feature.

This function should wake up everything in the selected range.

local CANT_TAGS =
{
	"test_tag", -- Having said tags will cause the function to fail. 
}
local RANGE = 8 -- The range.
local function WakeUp(source, range, cant_tags)
	local x, y, z = source.Transform:GetWorldPosition()
	local ents = TheSim:FindEntities(x, y, z, range, nil, cant_tags) -- Find all entities in said range, ignoring the ones with the CANT_TAGS.
	for i, v in ipairs(ents) do -- For each entity found, do:
		if v.components.sleeper ~= nil and v.components.sleeper:IsAsleep() then -- Sleeper is used for creatures such as Hounds, Pigs...
			v.components.sleeper:WakeUp()
		elseif v.components.grogginess ~= nil and v.components.grogginess:IsKnockedOut() then -- Grogginess is used mainly for players.
			v.components.grogginess:ComeTo()
		end
	end
end

You can call this function from inside the Lua file using:

WakeUp(inst, RANGE, CANT_TAGS)

(This example implies that you are trying to make a prefab with it. If it's not, then you would need to get an entity other than "inst" to serve as the focus point. You could also modify the function a bit to get world coordinates, rather than using another entity as the reference point.)

Edited by HarryPPP
  • Like 1

As an answer to your first question, you can have a look at this mod to see how they did. They copied the MakeLoot function and replaced the original with their version with more trinkets.

Another way to do it would be to change the inst.loot table after it was filled and then have a chance that one or more items are replaced by the item you want.

  • Like 2
38 minutes ago, HarryPPP said:

About the Tumbleweed, I'm not quite sure, but I can help with the wake up mobs feature.

This function should wake up everything in the selected range.


local CANT_TAGS =
{
	"test_tag", -- Having said tags will cause the function to fail. 
}
local RANGE = 8 -- The range.
local function WakeUp(source, range, cant_tags)
	local x, y, z = source.Transform:GetWorldPosition()
	local ents = TheSim:FindEntities(x, y, z, range, nil, cant_tags) -- Find all entities in said range, ignoring the ones with the CANT_TAGS.
	for i, v in ipairs(ents) do -- For each entity found, do:
		if v.components.sleeper ~= nil and v.components.sleeper:IsAsleep() then -- Sleeper is used for creatures such as Hounds, Pigs...
			v.components.sleeper:WakeUp()
		elseif v.components.grogginess ~= nil and v.components.grogginess:IsKnockedOut() then -- Grogginess is used mainly for players.
			v.components.grogginess:ComeTo()
		end
	end
end

You can call this function from inside the Lua file using:


WakeUp(inst, RANGE, CANT_TAGS)

(This example implies that you are trying to make a prefab with it. If it's not, then you would need to get an entity other than "inst" to serve as the focus point. You could also modify the function a bit to get world coordinates, rather than using another entity as the reference point.)

So do I use both of these? Where do I put them?

3 hours ago, HarryPPP said:

About the Tumbleweed, I'm not quite sure, but I can help with the wake up mobs feature.

This function should wake up everything in the selected range.


local CANT_TAGS =
{
	"test_tag", -- Having said tags will cause the function to fail. 
}
local RANGE = 8 -- The range.
local function WakeUp(source, range, cant_tags)
	local x, y, z = source.Transform:GetWorldPosition()
	local ents = TheSim:FindEntities(x, y, z, range, nil, cant_tags) -- Find all entities in said range, ignoring the ones with the CANT_TAGS.
	for i, v in ipairs(ents) do -- For each entity found, do:
		if v.components.sleeper ~= nil and v.components.sleeper:IsAsleep() then -- Sleeper is used for creatures such as Hounds, Pigs...
			v.components.sleeper:WakeUp()
		elseif v.components.grogginess ~= nil and v.components.grogginess:IsKnockedOut() then -- Grogginess is used mainly for players.
			v.components.grogginess:ComeTo()
		end
	end
end

You can call this function from inside the Lua file using:


WakeUp(inst, RANGE, CANT_TAGS)

(This example implies that you are trying to make a prefab with it. If it's not, then you would need to get an entity other than "inst" to serve as the focus point. You could also modify the function a bit to get world coordinates, rather than using another entity as the reference point.)

It's not working, I don't think I put it in the right spots.

Alright it does work, had to bump up range.

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