Jump to content

Recommended Posts

So, i've been making a mod that causes entities to shoot projectiles randomly when they die, for some reason none of my print statements work so I'm guessing i messed something up on the ListenForEvent

modmain.lua

It doesn't crash me or anything, it just does nothing. I'm not very good at modding so this is probably something very simple. Also i looked at the logs and nothing was wrong.

Edited by Boogiepop210
1 hour ago, Boogiepop210 said:

So, i've been making a mod that causes entities to shoot projectiles randomly when they die, for some reason none of my print statements work so I'm guessing i messed something up on the ListenForEvent

modmain.lua 2.16 kB · 2 downloads

It doesn't crash me or anything, it just does nothing. I'm not very good at modding so this is probably something very simple. Also i looked at the logs and nothing was wrong.

I would use AddPrefabPostInitAny in this case but it has wide scope and sometimes extraneous stuff, so be careful when using it
 

Spoiler

AddPrefabPostInitAny(function(inst)
if not GLOBAL.TheWorld.ismastersim then
   return inst
end
if inst:HasTag("_combat") then
   inst:ListenForEvent("death", function(inst) print("hello7") z_shootprojectiles("fire_projectile", inst, 15, 3, 1, math.random(0, 360), false, inst.Transform:GetWorldPosition()) end)
end

end)

 

Edited by Haruhi Kawaii
10 hours ago, Haruhi Kawaii said:

I would use AddPrefabPostInitAny in this case but it has wide scope and sometimes extraneous stuff, so be careful when using it
 

  Reveal hidden contents

AddPrefabPostInitAny(function(inst)
if not GLOBAL.TheWorld.ismastersim then
   return inst
end
if inst:HasTag("_combat") then
   inst:ListenForEvent("death", function(inst) print("hello7") z_shootprojectiles("fire_projectile", inst, 15, 3, 1, math.random(0, 360), false, inst.Transform:GetWorldPosition()) end)
end

end)

 

Thanks, the code worked perfectly. (after some fixes with globals on my function)

Edited by Boogiepop210

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