Data Realms Fan Forums http://forums.datarealms.com/ |
|
Cortex Command Lua Scripting Tutorial http://forums.datarealms.com/viewtopic.php?f=73&t=17955 |
Page 2 of 3 |
Author: | Major [ Sun Aug 29, 2010 8:03 am ] |
Post subject: | Re: Cortex Command Lua Scripting Tutorial |
Quote: Code: local varA = 5 local varB = varA This would make variable "varB" equal to 5. Note how the word "local" was not used when recalling the variable "varA". It does use "local" when recalling variable "VarA". Quote: -- Statement checking if the distance check (variable "local distcheck") is less than 10. If so, then do the action... if distcheck < 30 then Two different values. |
Author: | TheLastBanana [ Sun Aug 29, 2010 8:48 am ] |
Post subject: | Re: Cortex Command Lua Scripting Tutorial |
Major, I'm pretty sure what he meant by the first one is that it shouldn't be written out as this: Code: local varB = local varA |
Author: | CaveCricket48 [ Sun Aug 29, 2010 5:29 pm ] |
Post subject: | Re: Cortex Command Lua Scripting Tutorial |
Major wrote: Quote: -- Statement checking if the distance check (variable "local distcheck") is less than 10. If so, then do the action... if distcheck < 30 then Two different values. Yeah fixed. Also, I added another example, which is for a missile. Check it out! |
Author: | Major [ Mon Aug 30, 2010 8:02 am ] |
Post subject: | Re: Cortex Command Lua Scripting Tutorial |
Quote: Major, I'm pretty sure what he meant by the first one is that it shouldn't be written out as this: Code: local varB = local varA Ahh, thanks. Could you add the documentation for functions and properties here, because the wiki is down, please? |
Author: | CrazyMLC [ Mon Aug 30, 2010 3:10 pm ] |
Post subject: | Re: Cortex Command Lua Scripting Tutorial |
Make sure to read every sticky. viewtopic.php?p=364463#p364463 |
Author: | Shook [ Fri Dec 03, 2010 2:59 pm ] |
Post subject: | Re: Cortex Command Lua Scripting Tutorial |
Quick question regarding tables; is there any easy way of checking whether something is in a given table? Or do i just have to "brute force" check? (as in, do a secondary for loop that checks every single entry for the variable i'm looking for) It would be supremely useful for making a decent railgun. |
Author: | Abdul Alhazred [ Fri Dec 03, 2010 3:24 pm ] |
Post subject: | Re: Cortex Command Lua Scripting Tutorial |
Shook wrote: Quick question regarding tables; is there any easy way of checking whether something is in a given table? Code: function Create(self) gAct = {} gLookup = {} gAct[1] = self gLookup[self] = 1 end function Update(self) print(gAct[gLookup[self]]) end If "self" is not a member of "gAct" the call "gLookup[self]" will return "nil". |
Author: | adwuga [ Mon Apr 25, 2011 9:07 am ] |
Post subject: | Re: Cortex Command Lua Scripting Tutorial |
how would I make a statement saying "if any enemy soldier is alive then..." ? |
Author: | Abdul Alhazred [ Mon Apr 25, 2011 12:27 pm ] |
Post subject: | Re: Cortex Command Lua Scripting Tutorial |
adwuga wrote: how would I make a statement saying "if any enemy soldier is alive then..." ? Assuming the player is team one: Code: for Act in MovableMan.Actors do if Act.Team ~= Activity.TEAM_1 then -- there are enemies in the scene -- do stuff here break -- stop looping end end |
Author: | adwuga [ Mon Apr 25, 2011 9:03 pm ] |
Post subject: | Re: Cortex Command Lua Scripting Tutorial |
thanks Abdul Alhazred. another thing(sorry) this is in my mission code. i want the player to kill all enemies and then kill the brain. for some reason it wont work. can someone tell me whats wrong? Code: ----------------------------------------------------------------------------------------- -- Update Activity ----------------------------------------------------------------------------------------- function Battle:UpdateActivity() -- Clear all objective markers, they get re-added each frame self:ClearObjectivePoints(); self:Killcheck(); self:DestroyBrain(); -- Check for defeat conditions self:DoBrainSelection(); self:YSortObjectivePoints(); end ----------------------------------------------------------------------------------------- -- Kill Everyone check ----------------------------------------------------------------------------------------- function Battle:Killcheck() if self.Killcomplete == false then print ("Kill Humans"); else print ("Complete"); end ----------------------------------------------------------------------------------------- -- Kill Everyone ----------------------------------------------------------------------------------------- function Battle:KillHumans() for Act in MovableMan.Actors do if Act.Team ~= Activity.TEAM_1 then self.Killcomplete = false; else self.Killcomplete = true; break -- stop looping end end end ----------------------------------------------------------------------------------------- -- Destroy Brain ----------------------------------------------------------------------------------------- function Battle:DestroyBrain() if self.Killcomplete == true then if MovableMan:IsActor(self.CPUBrain) then self:AddObjectivePoint("Destroy!", self.CPUBrain.AboveHUDPos, Activity.TEAM_1, GameActivity.ARROWDOWN); else self.WinnerTeam = Activity.TEAM_1; ActivityMan:EndActivity(); end end end |
Author: | Roast Veg [ Mon Apr 25, 2011 9:10 pm ] |
Post subject: | Re: Cortex Command Lua Scripting Tutorial |
Your KillHumans function is not being initiated in the Update function. |
Author: | adwuga [ Mon Apr 25, 2011 11:09 pm ] |
Post subject: | Re: Cortex Command Lua Scripting Tutorial |
there was something else wrong with it, since it still doesnt work. that prabably did help though so thanks. any other ideas as to what is wrong? |
Author: | Roast Veg [ Mon Apr 25, 2011 11:30 pm ] |
Post subject: | Re: Cortex Command Lua Scripting Tutorial |
You don't have a DoBrainSelection function. |
Author: | adwuga [ Tue Apr 26, 2011 3:16 am ] |
Post subject: | Re: Cortex Command Lua Scripting Tutorial |
that is further down, I didnt want to put my entire script in the post. what doesnt work is the mission objectives. the self:Killcheck(); and self:KillHumans(); dont work, and so self:DestroyBrain(); is never activated, and the mission cant be won. I could take out the kill functions, but I want the objective to be to kill every one, then kill the brain. |
Author: | Abdul Alhazred [ Tue Apr 26, 2011 6:08 am ] |
Post subject: | Re: Cortex Command Lua Scripting Tutorial |
Have you looked in the console for errors? KillChek is missing and end, and KillHumans will set self.Killcomplete to true if there are any actors on team one in the scene. Try doing it like this instead: Code: function Battle:KillHumans() self.Killcomplete = true for Act in MovableMan.Actors do if Act.Team ~= Activity.TEAM_1 then self.Killcomplete = false break -- stop looping end end end |
Page 2 of 3 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |