Xkow's editing problems

Status
Not open for further replies.

Xkower8181

Member
So I decided make this fancy editing help topic where I don't have to make a topic for every single tiny problem.
But now here's the first one:
So when I added an ammo and panel system to Match NPCs but ammo value thing is having this error all the time with all the weapons beside grenades that i managed to code when they collected it and no matter what.
Warnings from the log:

WARNING: betatest.wad|LUA_MAIN:245: attempt to perform arithmetic on field 'eoammo' (a nil value)

WARNING: betatest.wad|LUA_MAIN:254: attempt to perform arithmetic on field 'boammo' (a nil value)

So yeah here's the erroring codes along with grenade for comparison:
addHook("MobjMoveCollide", function(mo, ep)
if mo.z > (ep.z + ep.height) or ep.z > (mo.z + mo.height) or ep.health == 0 or mo.health == 0 or ep.type != MT_EXPLODEPICKUP then return end
[here is 245]mo.eoammo = $1 + 5
mo.ec = true
print("A NPC collected with a explode panel and got "+mo.eoammo" of ammo and the explode check is "+mo.ec)
P_KillMobj(ep)
S_StartSound(ep, sfx_ncitem)
end, MT_MATCHNPC)

addHook("MobjMoveCollide", function(mo, bp)
if mo.z > (bp.z + bp.height) or bp.z > (mo.z + mo.height) or bp.health == 0 or mo.health == 0 or bp.type != MT_BOUNCEPICKUP then return end
[here is 254]mo.boammo = $1 + 10
mo.bc = true
print("A NPC collected with a bounce panel and got "+mo.boammo" of ammo and the bounce check is "+mo.bc)
P_KillMobj(bp)
S_StartSound(bp, sfx_ncitem)
end, MT_MATCHNPC)

addHook("MobjMoveCollide", function(mo, gp)
if mo.z > (gp.z + gp.height) or gp.z > (mo.z + mo.height) or gp.health == 0 or mo.health == 0 or gp.type != MT_GRENADEPICKUP then return end
mo.goammo = $1 + 10
mo.gc = true
print("A NPC collected with a grenade panel and got "+mo.goammo" of ammo and the grenade check is "+mo.gc)
P_KillMobj(gp)
S_StartSound(gp, sfx_ncitem)
end, MT_MATCHNPC)

So yeah I think that can be fixed.
 
Last edited:
Check if mo.eammo and bammo exist in the first place?
Because you can't do maths on a nil value
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top