Page 1 of 1
Getting Teleported when you Kill Something [Solved]
Posted: Sun Aug 09, 2009 10:48 pm
by asleeponduty
Could someone with good lua knowledge help me?
In my space map I have tried to set up a teleporter that teleports you when you kill a green barrel.
(Yes I followed Penguins tut just changed a few things)
One small problem. I teleport when I kill anything.
Here is the lua tidbit thats causing me to teleport when I kill stuff

even the enemy.
This is a normal teleporter that uses a region
Note: my other teleporter that uses a region works fine
Re: Getting Teleported when you kill something problem
Posted: Sun Aug 09, 2009 10:53 pm
by Maveritchell
From the "Everything you need" thread:
http://www.gametoast.com/forums/viewtop ... 27&t=12473
The principle is the same whether you are animating an object or moving an entity.
Re: Getting Teleported when you kill something problem
Posted: Mon Aug 10, 2009 10:24 am
by Fiodis
Your problem is that you're not checking to see if the object killed is a green barrel or something else. You can do that by taking relative lines from that FAQ tutorial on triggering animations on the destruction of an object.
You also don't need any region, only a target object and a node.
Re: Getting Teleported when you kill something problem
Posted: Mon Aug 10, 2009 3:29 pm
by asleeponduty
So I should have something like this?
OnObjectKill(
function(object, killer)
if killer and GetEntityName(object) "greenbarrel" then
MoveEntityToNode(character,"secrethangar")
end
end
)
Thank you

Re: Getting Teleported when you kill something problem
Posted: Mon Aug 10, 2009 3:40 pm
by Frisbeetarian
First of all, what is "character" in your code? You can't just use variables that don't exist. It would be more like this:
Code: Select all
OnObjectKill(
function(object, killer)
if GetEntityName(object) == "greenbarrel" then
MoveEntityToNode(killer,"secrethangar")
end
end
)
Assuming you want to teleport anything that destroys the barrel and the barrel never self destructs.
Re: Getting Teleported when you kill something problem
Posted: Tue Aug 11, 2009 11:30 am
by asleeponduty
Thanks !
It works now