Jump to content

Recommended Posts

I know this is a beginner question, but since I saw literally hundred different ways it is done in several mods, I'm very confused at the moment =/

If I want code NOT executed for clients (cause they are missing the components), what do I write?

In the ShowMe mod I saw this code:
local CLIENT_SIDE =     _G.TheNet:GetIsClient() or (TheNet:GetIsServer() and not TheNet:IsDedicated())

In Iceflingomatic behaviour I saw:
if GLOBAL.TheNet:GetIsServer() or GLOBAL.TheNet:IsDedicated() then

Other mods only use GLOBAL.TheNet:GetIsServer.

I made a mod that just increases range/damage of explosive things like gunpowder. My code was:
 

if not (GLOBAL.TheNet:GetIsServer() or GLOBAL.TheNet:IsDedicated()) then 
	return
end

AddPrefabPostInit("gunpowder", function(inst)
    inst.components.explosive.explosiverange = inst.components.explosive.explosiverange + GetModConfigData("gunpowderrange")
    inst.components.explosive.explosivedamage = inst.components.explosive.explosivedamage + GetModConfigData("gunpowderdamage")
end)

AddPrefabPostInit("slurtleslime", function(inst)
    inst.components.explosive.explosiverange = inst.components.explosive.explosiverange + GetModConfigData("slurtleslimerange")
    inst.components.explosive.explosivedamage = inst.components.explosive.explosivedamage + GetModConfigData("slurtleslimedamage")
end)

But still someone got a crash, because of the missing "explosive" component. So I wonder how this is possible?!
Is it the Dedicated stuff that I should remove?
But if this is causing the trouble, why do other mods use this?

Edited by Serpens

Ah, thank you for pointing out the line!

One day before I released update 1.01. Cause in 1.00 I did not had that client check, that's why the explosive thing was in line 2.
So the solution to the problem is, that "keeper" did not update the mod :D

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