View unanswered posts | View active topics It is currently Sun Dec 01, 2024 4:25 am



Reply to topic  [ 44 posts ]  Go to page Previous  1, 2, 3
 Cortex Command Lua Scripting Tutorial 
Author Message

Joined: Fri Mar 19, 2010 4:14 am
Posts: 20
Reply with quote
Post Re: Cortex Command Lua Scripting Tutorial
I haven't tried it yet but that's probably it. Strangely enough there were no console errors. Thanks for all the help.

EDIT: It worked thanks, but is there any way to disable a teleporter until self.Killcomplete = true? If you kill the brain before killing all the humans then the game freezes.


Tue Apr 26, 2011 10:09 pm
Profile
DRL Developer
DRL Developer

Joined: Tue Aug 11, 2009 5:09 am
Posts: 395
Reply with quote
Post Re: Cortex Command Lua Scripting Tutorial
The game wasn't really made to be played without a brain, so it does not make much sense to have to kill all units controlled by a brain before being able to kill the brain. But I guess you could hide the real brain and then make a fake brain that is the target.

If you want to disable teleporters I think you must implement them in the activity script. Define areas with the area editor and if self.Killcomplete is true check if any actor is inside that area with the IsInside function (self.MyArea1:IsInside(Act.Pos)) and just move it to the destination (Act.Pos = self.MyArea2:GetCenterPoint()).


Wed Apr 27, 2011 9:08 am
Profile

Joined: Fri Mar 19, 2010 4:14 am
Posts: 20
Reply with quote
Post Re: Cortex Command Lua Scripting Tutorial
Abdul Alhazred wrote:
The game wasn't really made to be played without a brain, so it does not make much sense to have to kill all units controlled by a brain before being able to kill the brain.

The story of my level is that you are an old abandoned experiment left running, and the coalition was your scripted target, so your goal is to kill everyone. I'll Try the Teleporter, but it might be confusing. maybe I could make a fake objective there and then say "Its a trap!."


Wed Apr 27, 2011 12:57 pm
Profile
User avatar

Joined: Mon Oct 19, 2009 9:04 am
Posts: 302
Location: Under Your Bed
Reply with quote
Post Re: Cortex Command Lua Scripting Tutorial
I read this whole thing once, Going to read it a 2nd time soon but so far I understand literally nothing. It explains what each thing does pretty well but even seeing the examples I have no clue how I would set the stuff up for what I wanted to try...


Thu Aug 25, 2011 3:17 pm
Profile YIM

Joined: Thu Dec 22, 2011 9:10 am
Posts: 15
Reply with quote
Post Re: Cortex Command Lua Scripting Tutorial
Ok so i downloaded a template for a rocket launcher, then tried to connect its Emitter to the Lua code, but when the loader gets to
"Index on line 8 includes:
Rocket Launcher.ini on line 1"

Cortex command stops working, and suggestions?


Mon Dec 26, 2011 11:22 am
Profile

Joined: Sat Oct 01, 2011 9:06 pm
Posts: 125
Location: london
Reply with quote
Post Re: Cortex Command Lua Scripting Tutorial
I dont understand the bit about the two types of variable global and local (I thought you already told us the types E.g. vectors ''text'' boolean ect.) and I also do not understand your explanation on global and local it has confused me to the depths of my mind and has nearly caused me to go insane from reading those two paragraphs OVER AND OVER :roll:


Wed Jan 25, 2012 10:18 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Cortex Command Lua Scripting Tutorial
A global variable is one that can be read from any script, a local variable can only be read in the script it was created.
So, let's suppose I've got script "A.lua" and script "B.lua".

In script A I create the local variable X, which is a boolean (true or false) set to true.
In script B, I have an if that goes "if X == true then".

The if in B won't work because the X variable in A is a local variable and will only work for the script A.


Wed Jan 25, 2012 10:29 pm
Profile

Joined: Sat Oct 01, 2011 9:06 pm
Posts: 125
Location: london
Reply with quote
Post Re: Cortex Command Lua Scripting Tutorial
thank you asklar :grin: can you explain pointers and why you should use them?


Wed Jan 25, 2012 10:36 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Cortex Command Lua Scripting Tutorial
This is what I understand, and it's probably not a 100% accurate.

When you store an object (Any MO in Cortex Command, from MOPixels to Actors or Items) in a variable, that variable is the pointer of said object.

The most easy example is self.

When you attach a script to a MO, the variable "self" has stored the MO which has the script attached. For example, if you attach a script that doubles the mass of a MOPixel, the variable "self" would refer to said MOPixel.

Now, when you have a pointer you can access it's properties by using a period (.) and then the name of the proprety. For example, if you want to double the mass of a MOPixel, you would first have to get into the mass of the MOPixel with self.Mass (Mass is a property of the MOPixel, and the MOPixel is stored in the pointer "self").


Wed Jan 25, 2012 10:51 pm
Profile

Joined: Sat Oct 01, 2011 9:06 pm
Posts: 125
Location: london
Reply with quote
Post Re: Cortex Command Lua Scripting Tutorial
That has shed a little light tommorow asklar will you have time for a basic lesson on things just sum things up shortly *to not waste your time*....? please say no if you have no time because I have a very long time and am patient.


Wed Jan 25, 2012 11:09 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Cortex Command Lua Scripting Tutorial
Me too.

Well, tomorrow is some sort of "free day" for me, because even though I'm on holidays, I'm still studying.

And we can continue in this thread.


Wed Jan 25, 2012 11:12 pm
Profile

Joined: Sat Oct 01, 2011 9:06 pm
Posts: 125
Location: london
Reply with quote
Post Re: Cortex Command Lua Scripting Tutorial
Sadly it is.., however embarrasing, inevitably my bed time. :(


Wed Jan 25, 2012 11:22 pm
Profile

Joined: Thu Nov 10, 2011 3:55 pm
Posts: 9
Location: Trade star 20.1
Reply with quote
Post Re: Cortex Command Lua Scripting Tutorial
Too complicated for me, I am only 14 :/


Wed Feb 01, 2012 10:13 am
Profile

Joined: Sat Oct 01, 2011 9:06 pm
Posts: 125
Location: london
Reply with quote
Post Re: Cortex Command Lua Scripting Tutorial
Haha non :')


Thu Feb 02, 2012 6:31 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 44 posts ]  Go to page Previous  1, 2, 3

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.031s | 14 Queries | GZIP : Off ]