Destroy Object when A Different Objects is Killed
Moderator: Moderators
- Fierfek
- High General

- Posts: 805
- Joined: Wed Jul 01, 2009 4:38 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Somewhere in the Galaxy (Most Likely Scrapping Tinnies)
Destroy Object when A Different Objects is Killed
I have a shield in my map, which I want to be destroyed when a panel is killed. The player's job is to defend the panel, and when it is destroyed, the shield comes down.
I took a look at the mygeeto and hoth scripts, but it was completely gibberish to me.
What is the easiest way to do this?
I took a look at the mygeeto and hoth scripts, but it was completely gibberish to me.
What is the easiest way to do this?
- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
- Fierfek
- High General

- Posts: 805
- Joined: Wed Jul 01, 2009 4:38 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Somewhere in the Galaxy (Most Likely Scrapping Tinnies)
Re: Destroy Object when A Different Objects is Killed
I already looked at that. How would I set it up from there - that is still gibberish to me (and I want the AI to do the destroying, not humans).Frisbeetarian wrote:Wooo!! Another one from the FAQ
http://www.gametoast.com/forums/viewtop ... 27&t=12473
- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: Destroy Object when A Different Objects is Killed
I really directed you to excess stuff, I really just wanted to show you the function OnObjectKill() which is described in greater detail in the documentation.
I can tell that the Mygeeto script is harder though, as it's not as straight forward. Use liberal use of the search function. A programmer's rule of thumb is that variables are look like this thisIsAnExample, and functions look like this ThisIsAnExample.
This is the code that occurs when the first generator is destroyed. You could open ZE to find the name of the first generator and then search for it in the Lua script to find this. What this is saying is to execute the function ShieldDied upon the destruction of the object by the name "generator_01".
This is the function executed, again found through search. You can ignore all of the extra variables since they are just there in this case so that ShieldDied can be used for more than one thing; you'll just do something once. PlayShieldDown is just another function that goes through the animations and changes a couple objects. If you look in that function, it has KillObject(), which is the function you're going to want to use. The last couple things have to do with planning and barriers, which if you want a polished map, you'll include also.
No where in that first part is there anything specific to human players (why would you read the points part, you didn't want that?).Fierfek wrote:and I want the AI to do the destroying, not humans
This is your problem. I'm not sure if you use the mission scripter, but it leaves behind problems like this in its wake. You need to understand the scripts. I can understand if people have a hard time getting through the shell scripts, but individual campaign scripts are different. If it's giving you a hard time, play the mission, pause, look at the script, rinse and repeat.Fierfek wrote:it was completely gibberish to me
I can tell that the Mygeeto script is harder though, as it's not as straight forward. Use liberal use of the search function. A programmer's rule of thumb is that variables are look like this thisIsAnExample, and functions look like this ThisIsAnExample.
Code: Select all
OnObjectKillName(ShieldDied, "generator_01");Code: Select all
function ShieldDied(actor)
fullName = GetEntityName(actor);
numberStr = string.sub(fullName, -2, -1);
shieldName = "force_shield_" .. numberStr;
genName = "generator_" .. numberStr;
upAnim = "shield_up_" .. numberStr;
downAnim = "shield_down_" .. numberStr;
PlayShieldDown(shieldName, genName, upAnim, downAnim);
UnblockPlanningGraphArcs("shield_" .. numberStr);
DisableBarriers("shield_" .. numberStr);
end
Last edited by Frisbeetarian on Mon Aug 24, 2009 8:13 pm, edited 1 time in total.
- Fierfek
- High General

- Posts: 805
- Joined: Wed Jul 01, 2009 4:38 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Somewhere in the Galaxy (Most Likely Scrapping Tinnies)
Re: Destroy Object when A Different Objects is Killed
So, I would put this in the lua?
Code: Select all
OnObjectKill("shield_panel")
killobject("rep_shield")- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: Destroy Object when A Different Objects is Killed
No. You didn't use the function correctly (something Zerted and I talked to you about with the timers). I gave you a link to an FAQ topic that uses is correctly. Also, killobject() is not a function, KillObject() is.
- Fierfek
- High General

- Posts: 805
- Joined: Wed Jul 01, 2009 4:38 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Somewhere in the Galaxy (Most Likely Scrapping Tinnies)
Re: Destroy Object when A Different Objects is Killed
So like this?
Code: Select all
OnObjectKill
(function(object, killer)
if GetEntityName(object) == "shield_panel" then
KillObject("rep_shield")
end
end
)- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: Destroy Object when A Different Objects is Killed
Yes. That'll work just how you want it.
If you wanted to be a little more efficient, you could also have done this:
If you wanted to be a little more efficient, you could also have done this:
Code: Select all
OnObjectKillName(
function(object, killer)
KillObject("rep_shield")
end,
"shield_panel"
)
Last edited by Frisbeetarian on Mon Aug 24, 2009 8:41 pm, edited 1 time in total.
- Fierfek
- High General

- Posts: 805
- Joined: Wed Jul 01, 2009 4:38 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Somewhere in the Galaxy (Most Likely Scrapping Tinnies)
Re: Destroy Object when A Different Objects is Killed
So that part of my lus can look like this?Frisbeetarian wrote:Yes. That'll work just how you want it.
Hidden/Spoiler:
Hidden/Spoiler:
- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
- Fierfek
- High General

- Posts: 805
- Joined: Wed Jul 01, 2009 4:38 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Somewhere in the Galaxy (Most Likely Scrapping Tinnies)
Re: Destroy Object when A Different Objects is Killed
What about the munge errors? My munge output says that there is an error in the lua. Do I just ignore that?Frisbeetarian wrote:Yes
- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: Destroy Object when A Different Objects is Killed
Hidden/Spoiler:
Last edited by Frisbeetarian on Mon Aug 24, 2009 8:52 pm, edited 1 time in total.
- Fierfek
- High General

- Posts: 805
- Joined: Wed Jul 01, 2009 4:38 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Somewhere in the Galaxy (Most Likely Scrapping Tinnies)
Re: Destroy Object when A Different Objects is Killed
What part?Frisbeetarian wrote:NoFierfek wrote:Do I just ignore that?
I thought you were just asking about what we were working on. The munge error refers to part of your Lua script further down that has nothing to do with anything we've talked about in this topic.
Here is my lua:
Hidden/Spoiler:
- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: Destroy Object when A Different Objects is Killed
That's three times I've been editing when you posted.
Read my edit.
- Fierfek
- High General

- Posts: 805
- Joined: Wed Jul 01, 2009 4:38 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Somewhere in the Galaxy (Most Likely Scrapping Tinnies)
Re: Destroy Object when A Different Objects is Killed
What new line?Frisbeetarian wrote:Delete the newline and you should be fine.
Can you outline it in red?
Hidden/Spoiler:
EDIT: Never mind, figured it out.
Thanks a ton, Fris!
- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: Destroy Object when A Different Objects is Killed
Nah, if you learn something, I'm happy. I understand that it's hard to get in the habit of programming. If anything, the terminology can get you. For instance, a newline is the character that is inserted when you press the "Enter" key.
I was just telling you to delete the new line character, or, according to the name, remove the new line.
Goes to
EDIT: Sigh, and the edit wins again.
I was just telling you to delete the new line character, or, according to the name, remove the new line.
Code: Select all
OnObjectKill
(function(object, killer) Code: Select all
OnObjectKill(function(object, killer) - Fierfek
- High General

- Posts: 805
- Joined: Wed Jul 01, 2009 4:38 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Somewhere in the Galaxy (Most Likely Scrapping Tinnies)
Re: Destroy Object when A Different Objects is Killed
Yeah, thanks.
I really never would have gotten this far without your help. Thanks!
EDIT
Sorry for double post, but I didn't want to make a new topic.
When my object is destroyed, the other objects don't go away.
Here is the script I have for it:
What am I doing wrong?
I really never would have gotten this far without your help. Thanks!
EDIT
Sorry for double post, but I didn't want to make a new topic.
When my object is destroyed, the other objects don't go away.
Here is the script I have for it:
Hidden/Spoiler:
- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: Destroy Object when A Different Objects is Killed
Are you saying that the shields don't go away?
- Fierfek
- High General

- Posts: 805
- Joined: Wed Jul 01, 2009 4:38 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Somewhere in the Galaxy (Most Likely Scrapping Tinnies)
Re: Destroy Object when A Different Objects is Killed
Correct.Frisbeetarian wrote:Are you saying that the shields don't go away?
In ZE, the object is called "shield_panel", and the shields are called "rep_shield", "rep_shield2", etc.
Did a manual clean, and munging now.
- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: Destroy Object when A Different Objects is Killed
Stick print("some random saying") as the first thing after the then. Clean, remunge, run the map, then post the error log.
