Page 1 of 1

"KillObject()" Is not working [Solved! Yay!]

Posted: Tue Sep 29, 2009 4:29 pm
by General_Nate
Hey, I have yet another code problem.

Everything about this code works, save the KillObject function.

Code: Select all

OnObjectKill(
    function(object, killer)
        local name = GetEntityName(object)
        print("OnObjectKill():",name)
        if name == "panel" then
            ShowMessageText("mods.mymap.arefree")
            KillObject("fence1")
            KillObject("fence2")
        end
    end
)
(Ok, I know it's not very efficient, but I'll wait until everything works before I go down that path)
Help is greatly appreciated.

Re: "KillObject()" Is not working

Posted: Fri Oct 02, 2009 12:07 pm
by ForceMaster
Make sure that yours objects "fence1" and "fence2" are in the correct layer on ZE. :wink:

Re: "KillObject()" Is not working

Posted: Fri Oct 02, 2009 1:52 pm
by General_Nate
They are in the BASE layer. Is that why it won't work?

Re: "KillObject()" Is not working

Posted: Fri Oct 02, 2009 1:56 pm
by [RDH]Zerted
KillObject works fine on objects. Are the fences ingame objects? mods.mymap.arefree is being displayed right?

Re: "KillObject()" Is not working

Posted: Fri Oct 02, 2009 1:58 pm
by General_Nate
Yes, everything about this code works. Well everything but the KillObject(). And yes, "fence1" and 2 are both objects ingame in the BASE layer.

EDIT: If it helps, I also have this, which does not work, but....

Code: Select all

OnObjectKill(
    function(object, killer)
        local name = GetEntityName(object)
        print("OnObjectKill():",name)
        if name == "panel" then
            ShowMessageText("mods.mymap.arefree")
            local name2 = GetEntityName(object)
	    if name2 == "fence1" then
		KillObject("fence1")
	    end
            local name3 = GetEntityName(object)
	    if name3 == "fence2" then
		KillObject("fence2")
	    end

        end
    end
)

Re: "KillObject()" Is not working

Posted: Fri Oct 02, 2009 2:50 pm
by Aman/Pinguin
General_Nate wrote: EDIT: If it helps, I also have this, which does not work, but....

Code: Select all

OnObjectKill(
    function(object, killer)
        local name = GetEntityName(object)
        print("OnObjectKill():",name)
        if name == "panel" then
            ShowMessageText("mods.mymap.arefree")
            local name2 = GetEntityName(object)
	    if name2 == "fence1" then
		KillObject("fence1")
	    end
            local name3 = GetEntityName(object)
	    if name3 == "fence2" then
		KillObject("fence2")
	    end

        end
    end
)
That makes no sense. You're trying to kill something that got killed. Also you're creating 3 variables (name, name2, name3) for the same thing (the killed object).

Not sure why the code in your first post doesn't work though. Post your Errorlog.

Re: "KillObject()" Is not working

Posted: Wed Oct 07, 2009 9:51 am
by General_Nate
Woops, sorry for the late reply. Any ways, here is the log:
Hidden/Spoiler:
OnObjectKill(): panel

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(642)
Entity "Fence1" is EntityProp, but need GameObject

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(642)
Entity "Fence2" is EntityProp, but need GameObject

Re: "KillObject()" Is not working

Posted: Wed Oct 07, 2009 12:21 pm
by Aman/Pinguin
Not sure if that's the problem, but did you setup any health for your fences? I think they have to have health to be killable.

Re: "KillObject()" Is not working

Posted: Wed Oct 07, 2009 1:42 pm
by [RDH]Zerted
Entity "Fence1" is EntityProp, but need GameObject
Like I mentioned, it would only work on objects. You have your fences as props. Use objects instead and it will work.

Re: "KillObject()" Is not working

Posted: Wed Oct 07, 2009 1:58 pm
by General_Nate
Ok, here is my odf:
Hidden/Spoiler:
[GameObjectClass]
ClassLabel = "prop"
GeometryName = "gt1_build_fencebig_01.msh"

[Properties]
GeometryName = "gt1_build_fencebig_01"
FoleyFXGroup = "metal_foley"
What do I need to change?

Re: "KillObject()" Is not working

Posted: Wed Oct 07, 2009 2:00 pm
by Aman/Pinguin
Hidden/Spoiler:
[GameObjectClass]
ClassLabel = "destructablebuilding"
GeometryName = "gt1_build_fencebig_01.msh"

[Properties]
GeometryName = "gt1_build_fencebig_01"
FoleyFXGroup = "metal_foley"
IsNotTargetableByPlayer = "1"
MaxHealth = "99999999999"
AddHealth = "99999999999"

Re: "KillObject()" Is not working

Posted: Wed Oct 07, 2009 2:39 pm
by General_Nate
:eek: Yes! I finally works!! Have a cookie, all of you! (::)
Thanks guys.