View unanswered posts | View active topics It is currently Tue Dec 03, 2024 1:55 am



Reply to topic  [ 9 posts ] 
 Putting Actors In the Game with Lua 
Author Message

Joined: Thu Aug 16, 2007 10:09 am
Posts: 163
Reply with quote
Post Putting Actors In the Game with Lua
This is a tutorial on how to place actors with the Console. If you are reading it, read it thoroughly to prevent mistakes. Capitalization is extremely important.




The generic code is like this:
Code:
<variablename> = CreateActor( "<presetname in INI file>" , "<Mod .rte, can leave blank to look in all folders>")


So, to add a Light Soldier (in ram, I'll discuss plopping it ingame later) , you would logically have to do this:

Code:
myActor = CreateActor( "Soldier Light" , "Base.rte" )


However, this does not work because a Soldier is an AHuman. So you do this instead;

Code:
myActor = CreateAHuman( "Soldier Light" , "Base.rte" )


Does that mean to place him in game, all you have to do is this?
Code:
MovableMan:AddActor(myActor);


Not yet! We haven't given him any X Y co-ordinates yet! To do that, we write this:

Code:
myPos = Vector()

This sets up a vector for X,Y positioning.
Code:
myPos:SetXY(200,100)

This will set the X and Y co-ordinates to somewhere in the sky, on the tutorial map, this places him in the little valley area with the crab.

Code:
myActor.Pos = myPos

Now to set the team.
Code:
myActor.Team = 0 (for player one)


Then we can do this:

Code:
MovableMan:AddActor(myActor);



Tadaah! You've just made an actor and placed him! You can repeat the last command to place a copy of him as many times as you want. I'll figure out other stuff later.

I'll try and get a gif of this in action if you want, but you have my guarantee, this works.


Last edited by robowurmz on Sat Aug 23, 2008 8:35 pm, edited 4 times in total.



Sat Aug 23, 2008 8:09 pm
Profile
Reply with quote
Post Re: Putting Actors In the Game with Lua
Oh you are cool.


Sat Aug 23, 2008 8:24 pm
User avatar

Joined: Sat Nov 03, 2007 9:44 pm
Posts: 1916
Location: Flint Hills
Reply with quote
Post Re: Putting Actors In the Game with Lua
These exact commands in this order, just to make it completely clear.
Code:
myActor = CreateAHuman( "Soldier Light" , "Base.rte" )
Code:
myPos = Vector()
Code:
myPos:SetXY(200,100)
Code:
myActor.Pos = myPos
Code:
myActor.Team = 0
Code:
MovableMan:AddActor(myActor);


Anywho, pretty cool.

I wonder if there's any combination of commands that can add a certain device to the selected actor's inventory?

Or to pause and unpause the game, without exiting to the menu.


Sat Aug 23, 2008 9:10 pm
Profile

Joined: Thu Aug 16, 2007 10:09 am
Posts: 163
Reply with quote
Post Re: Putting Actors In the Game with Lua
This command might work:
Code:
myWeapon = CreateHDFirearm("Pistol")


And then this one:
Code:
myActor:AddToInventory(myWeapon)


These commands must be done before spawning.


Sat Aug 23, 2008 9:13 pm
Profile
User avatar

Joined: Sat Nov 03, 2007 9:44 pm
Posts: 1916
Location: Flint Hills
Reply with quote
Post Re: Putting Actors In the Game with Lua
Apparently not, unless I did something wrong.
Image

Hard to tell with the minuscule text.


Sat Aug 23, 2008 9:24 pm
Profile

Joined: Mon Dec 04, 2006 3:34 am
Posts: 2378
Reply with quote
Post Re: Putting Actors In the Game with Lua
myActor:AddInventoryItem("Pistol");


PS: Post threads like this in the lua section next time.


Sat Aug 23, 2008 9:32 pm
Profile
User avatar

Joined: Sun Apr 15, 2007 5:56 am
Posts: 1191
Location: outside the shithole called the University in the Forest
Reply with quote
Post Re: Putting Actors In the Game with Lua
And how do I pause the game without the menu coming up, and how do I gib an actor/add to it's velocity?


Sat Aug 23, 2008 9:38 pm
Profile

Joined: Thu Aug 16, 2007 10:09 am
Posts: 163
Reply with quote
Post Re: Putting Actors In the Game with Lua
The Fat Sand Rat wrote:
And how do I pause the game without the menu coming up, and how do I gib an actor/add to it's velocity?

To gib an actor, I think you'll have to do something like this:

Code:
myGibActor = MovableMan:GetMOFromID(<i.d of MO object>)


Where the ID is the number of a unit: i think it's in order of spawning.

Then, you do this:

Code:
myGibActor.Vel = Vector(100, 0)

Where those two variables are the X and the Y speed in Metres Per Second.

To sum up, this code creates a new variable called myGibActor and assigns a living actor to it. Then the living actor's stuff can be edited.


Sat Aug 23, 2008 9:50 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Putting Actors In the Game with Lua
Damn, we don't have lua on bunkermodules yet. Otherwise I'd be doing tons of stuff.


Sat Aug 23, 2008 10:59 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

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.027s | 13 Queries | GZIP : Off ]