Page 1 of 1

Change object's team through LUA [Solved]

Posted: Sun Jan 02, 2011 8:08 pm
by CressAlbane
Search returned few relavent topics so....
Here's the situation:
I have an object that I want to switch between team 1 and team 2. I want this to occur based on the destruction of a nearby panel. If a member of Team 1 destroys the panel than the object should change to team 1. If a member of team 2 destroys the panel than the object should change to team 2.
Is this possible through LUA? If so, where does the code go? I want to solve this mainly by myself but a few tips (like functions to enter) would be great.

I found these, but since I'm not familiar with LUA syntax, I don't know how to implement them:
GetCharacterTeam
GetTeamMember
SetObjectTeam

EDIT: These lines from the dea1c_con LUA look helpful:
OnObjectRespawnName(PlayAnimExtend, "Panel-Chasm");
OnObjectKillName(PlayAnimRetract, "Panel-Chasm");

If I'm right, then OnObjectKillName(SetProperty("bridgeturret_1", Team, 1), "bridgeconsole1")
would set bridge turret #1 to team 1 on the destruction of bridgeconsole 1.

But, how to make this change depend on the team of the killer?
I think it would be easy if I knew how the syntax.

Re: Change object's team through LUA

Posted: Sun Jan 02, 2011 10:58 pm
by asleeponduty
Try something like this:
Set the objects team to 0 initially

Code: Select all

-- In the code put this here
SetProperty ("object","Team",2)

	OnObjectKill(
    function(object,killer)
    if GetEntityName(object) == "thethingyoukill" then
		    SetProperty ("object","Team",1)
    end
    end
    )

Re: Change object's team through LUA

Posted: Mon Jan 03, 2011 1:08 am
by Firefang
That doesn't specify the killer's team.

Code: Select all

SetProperty ("object","Team",2)

   OnObjectKill(
     function(object,killer)
       if GetEntityName(object) == "object" and GetCharacterTeam(killer) == 1 then
       SetProperty ("object","Team",1)
      end
    end
   )
That ensures that the killer is on team 1

Re: Change object's team through LUA

Posted: Mon Jan 03, 2011 7:52 am
by CressAlbane
This script returned an error, "=" expected near Object.
Looking through it now...
Ok, something I added to the script had an extra space.
It works now, thanks!