Jump to content

Need little help


Recommended Posts

local function friendsFOREVER(inst)

local pt = inst:GetPosition()
local range = 10  -- range of ability
local hps = 5 -- sanity amount per tick
local frens = { "wilson" }

	local targets = TheSim:FindEntities(pt.x,pt.y,pt.z, range, frens)
		for _,ent in ipairs(targets) do
			inst.components.sanity:DoDelta(hps)		
		end          
end

local function BFFs(inst)
 	if not inst.components.health:IsDead() and not inst:HasTag("playerghost") then				
		friendsFOREVER(inst)	
	end
end


This part below needs to be placed inside master_postinit


local toim = 2 -- time interval between every sanity tick (seconds-ish, it's not 100% accurate)
inst:DoPeriodicTask(toim, BFFs, nil, inst)

 

Try this inside [character's.name].lua

Edited by Yakuzashi
Link to comment
Share on other sites

When you enter the server, the game freezes, and then disconnects

52 minutes ago, Yakuzashi said:

 


   
  
   

	
		 		
		          


 
 	    	
	


Эту часть ниже необходимо поместить в master_postinit.



   

 

Попробуйте это внутри [имя персонажа] .lua

 

Everything is fine, but when you enter the server, the game freezes, and then disconnects

Link to comment
Share on other sites

I put this part in "master_postinit"

local toim = 2
inst:DoPeriodicTask(toim, BFFs, nil, inst)

 

I put this part in Code

local function friendsFOREVER(inst)

local pt = inst:GetPosition()
local range = 10  -- range of ability
local hps = 5 -- sanity amount per tick
local frens = { "wilson" }

	local targets = TheSim:FindEntities(pt.x,pt.y,pt.z, range, frens)
		for _,ent in ipairs(targets) do
			inst.components.sanity:DoDelta(hps)		
		end          
end

local function BFFs(inst)
 	if not inst.components.health:IsDead() and not inst:HasTag("playerghost") then				
		friendsFOREVER(inst)	
	end
end

 

But it doesn't work, I noticed errors where Friends are written as FRENS

Im new to Modding and I don't understand much :)

Link to comment
Share on other sites

Probably Wilson doesn't have his own tag, so you need to swap "wilson" with "character". And add

Quote

inst:AddTag( "yourcharacter'snamehere" )

inside common_postinit. Then add this line

Quote

local notag = {"yourcharacter'snamehere"}

under

Quote

local frens = {"character"}

 

and modifiy

Quote

local targets = TheSim:FindEntities(pt.x,pt.y,pt.z, range, frens)

for something like this

Quote

local targets = TheSim:FindEntities(pt.x,pt.y,pt.z, range, frens, notag)

 

Link to comment
Share on other sites

local function onbecamehuman(inst)
    -- Set speed when not a ghost (optional)
    inst.components.locomotor:SetExternalSpeedMultiplier(inst, "wuk_speed_mod", 1)
end

inst:AddTag( "wuk" )

local function friendsFOREVER(inst)

local pt = inst:GetPosition()
local range = 10  -- range of ability
local hps = 6 -- sanity amount per tick
local friends = { "webber" }

    local targets = TheSim:FindEntities(pt.x,pt.y,pt.z, range, friends , notag)
        for _,ent in ipairs(targets) do
            inst.components.sanity:DoDelta(hps)        
        end          
end

local function BFFs(inst)
     if not inst.components.health:IsDead() and not inst:HasTag("playerghost") then                
        friendsFOREVER(inst)    
    end
end

 

 

local common_postinit = function(inst) 
    local notag = {"wuk"}
    local frens = {"webber"}
    -- Minimap icon
    inst.MiniMapEntity:SetIcon( "wuk.tex" )
end

 

 is everything right?

Edited by Ghost_starved
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...