Jump to content

Recommended Posts

I added a mod that increases sanity when character A and character B together.

 

local function checkaura(inst, observer)
    if observer:HasTag("characterB") then
        return TUNING.SANITYAURA_LARGE
    end    
end

 

local common_postinit = function(inst) 
    inst:AddTag("characterB")
    
    inst:AddComponent("sanityaura")
    inst.components.sanityaura.aurafn = checkaura
    
    
    return inst

end

 

local master_postinit = function(inst)

    -- characterA
    
    return inst
end

 

 

I added that code to each character's lua, and the interaction worked well.

But, when characterA met characterA or other characters not in the HasTag, there is a mod conflict as shown in that photo.

image.png.7458a72f9be7e67c18b8c7d16c4558fa.png

(Error : attempt to perform arithmetic on a nil value LUA ERROR stack traceback)

 

 

I couldn't solve this problem because I was a beginner.

I hope that someone can help me with this problem.

Edited by unya_10
On 9/3/2024 at 5:15 PM, Baguettes said:

Can I have the full crash logs? I want to look deeper into this.

I'm so sorry I checked late.
Are these the log files you're talking about?
If not, please let me know!
And thank you for your help.

client_log_2024-09-02-02-04-00.txt client_log_2024-09-02-03-01-58.txt

I'm afraid these logs do not contain the crash; if you want to make sure it's the correct one, you can load your game, replicate your crash and use the client_log.txt in your current game session.

You can use Ctrl + F to look through contents of the text file; type in LUA ERROR in the search box, and if your log has it, that's the correct one.

Hello. Can I also get some help? I'm experiencing exactly the same problem. However, I don't know much about coding, so I couldn't figure out a solution by looking at the logs...

This is my crash logs. You can use Ctrl + F to find them.

client_log_2024-10-26-20-10-03.txt

1 hour ago, 5sam said:

Hello. Can I also get some help? I'm experiencing exactly the same problem. However, I don't know much about coding, so I couldn't figure out a solution by looking at the logs...

This is my crash logs. You can use Ctrl + F to find them.

client_log_2024-10-26-20-10-03.txt

Your logs say you're trying to do maths on a nil value. This probably has something to do with your aura fn in your character's Lua file.
Is your sanity aura fn returning a value for the game to work with?

Edited by Baguettes
local function checkaura(inst, observer)
	if observer:HasTag("tagA") then
		return TUNING.SANITYAURA_HUGE
	end	
end
	
	
local function common_postinit (inst) 

	inst.soundsname = "willow"
	inst.MiniMapEntity:SetIcon( "characterA_mapicon.tex" )

	inst:AddTag("tagA")
	
	inst:AddComponent("sanityaura")
	inst.components.sanityaura.aurafn = checkaura
	
	
	return inst

end

Here’s the Lua script for characterA that I wrote. Is there something wrong with it? I want to apply the sanityaura effect only to characters assigned with "tagA". Therefore, I added the observer code to the Lua script of characterA. Additionally, I assigned the AddTag("tagA") code to characterA, characterB, and characterC so they would receive the sanityaura effect.

Baguettes is right: In your code it only returns TUNING.SANITYAURA_HUGE if the character has your tag. You need to define what happens if a character does not have the tag:

local function checkaura(inst, observer)
  if observer:HasTag("tagA") then
    return TUNING.SANITYAURA_HUGE
  else
    return 0 -- Presuming 0 is the right number for no aura
  end
end

 

Edited by summerscorcher
  • Like 1
4 hours ago, summerscorcher said:

Baguettes is right: In your code it only returns TUNING.SANITYAURA_HUGE if the character has your tag. You need to define what happens if a character does not have the tag:

local function checkaura(inst, observer)
  if observer:HasTag("tagA") then
    return TUNING.SANITYAURA_HUGE
  else
    return 0 -- Presuming 0 is the right number for no aura
  end
end

 

I was able to solve the problem. Thank youuuu!!

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