View unanswered posts | View active topics It is currently Thu Apr 27, 2017 2:28 am



Reply to topic  [ 4 posts ] 
 Anyone still around to help with LUA scripting for scenes? 
Author Message
User avatar

Joined: Wed Jul 06, 2011 5:11 pm
Posts: 205
Reply with quote
Post Anyone still around to help with LUA scripting for scenes?
Forums seem pretty dead, hopefully someone is around to help out? TBH my knowledge of LUA is abysmal. If any experienced modders could help me out I would appreciate it very much.

EDIT: Re-wrote the activites from scratch, mission starts without errors. No funds, have to add them yourself at this point. Destroying enemy brain doesn't cause win, I believe i removed this section of code... Tried to make it work somehow, check out CPUbrainCheck funtion. Entering trigger areas doesn't cause dropships to spawn, probably something to do with spawn timer so at this point not sure if LZs or loadouts work properly. Doors commented out, not sure if properly implemented.

A few questions:

How to use lua to add doors to scene. I took a look at the Zombie Cave mission code and came up with this but I'm getting errors.
Code:
   self.KeyDoor1 = CreateTerrainObject("Door Cliff");
   self.KeyDoor1.Pos = Vector(2976, 900);
   self.KeyDoor1.Team = self.EnemyTeam;
   self.KeyDoor1:EnableEmission(false);  -- probably don't need this right?
   MovableMan:AddParticle(self.KeyDoor1); --Errors here


How can I set the doors to change team to player team when player picks up the control chip? I have no code for this, absolutley no clue what to do here.
I'm also getting some formatting errors (expecting then here, expecting eof here etc...)

EDIT: Ship spawn code, not sure if this works properly...
Code:
function CliffBaseAssault:PhaseOne()
   -- Loop through all actors to find an actor from our team. Be cautious with this loop and use it wiseley as it
   -- may add signifiant lag if used many times especially when you have many actors.
   for actor in MovableMan.Actors do
      -- Check if an actor is from our team
      if actor.Team == self.PlayerTeam then
         -- Check if an actor from our team is inside an area, if it is spawn ship
         if self.caveArea:IsInside(actor.Pos) then
            local ship = RandomACDropship("Any", self.CPUTechName);
            local actor = nil;
            local weapon = nil;
            for i = 0, 1 do
               if math.random() >= self:GetCrabToHumanSpawnRatio(PresetMan:GetModuleID(Self.CPUTechName)) then
                  actor = CreateAHuman("Any", self.CPUTechName);
               else
                  actor = RandomACrab("Any", self.CPUTechName);
               end
               if IsAHuman(actor) then
                  actor:AddInventoryItem(RandomHDFirearm("Primary Weapons", self.CPUTechName));
                  actor:AddInventoryItem(RandomHDFirearm("Secondary Weapons", self.CPUTechName));
                  if PosRand() < 0.5 then
                     actor:AddInventoryItem(RandomHDFirearm("Diggers", self.CPUTechName));
                  end
               end
               actor.AIMode = Actor.AIMODE_BRAINHUNT;
               actor.Team = self.CPUTeam;
               ship:AddInventoryItem(actor);
            end
            
            ship.Pos = Vector(self.DummyLZ:GetRandomPoint().X,0);
            ship.Team = self.CPUTeam;
            ship:SetControllerMode(Controller.CIM_AI, -1);
            MovableMan:AddActor(ship);
            self:AdvanceToTwo();
         end
      end
   end
end


CPUBrainCheck Function - I know this is wrong but it's all I got.
Code:
function CliffBaseAssault:DoCPUBrainCheck()
   if MovableMan:IsActor(self.CPUBrain) then
      self:AddObjectivePoint("Destroy!", self.CPUBrain.AboveHUDPos+Vector(0,-16), Activity.TEAM_1, GameActivity.ARROWDOWN)
   else
      self.WinnerTeam = Activity.TEAM_1
      ActivityMan:EndActivity()
   end
end

I'll upload RTE with all lua and inis included so if anyone wants to take a look feel free!
EDIT: Updated RTE uploaded.


Attachments:
Scene Template.rte.rar [126.24 KiB]
Downloaded 6 times
File comment: Updated RTE
Scene Template.rte.rar [132.85 KiB]
Downloaded 6 times
Sat Dec 24, 2016 3:48 pm
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 609
Location: Halifax, Canada
Reply with quote
Post Re: Anyone still around to help with LUA scripting for scenes?
Been quite a while since I've done any of this but let's see what help I can give.

I believe doors themselves are actors, so if you just want to add the door without the frame you'd use CreateActor("door name", "door rte") and MovableMan:AddActor(doorActor). If you want the frame and stuff then adding the whole thing as a scene object should be the way to do it, and in that case you don't need to use MovableMan for it since it'll automatically be added to the Movable Object manager.

As for changing door's teams, once you have the door actor set as a variable you can just do door.Team = Team_Number_Here. Selecting the door is a different question though - if you add the door actor through scripts then you can save it in a variable when you add it. Otherwise you'll have to do something along the lines of:
Code:
for a in MovableMan.Actors do
  if (a.ClassName == "ADoor") then
    a.Team = Team_Number_Here;
  end
end

The latter is probably the only way to do it if you're adding the whole door as a scene object.

I haven't downloaded your rte to look at exactly what your issue is but at a glance I see that you have Self instead of self at the line that calls GetCrabToHumanSpawnRatio. Case matters so you have to be careful there. In that regard console errors are probably your friend. I don't quite recall your previous question about spawn areas, but yes, you can have as many spawn areas for a team as you want - area names are entirely up to you - as long as your code handles them. You can also, of course, just use a lot of boxes instead of multiple areas, whatever is more useful in the situation.

Your brain checking stuff looks okay I think, as long as self.CPUBrain is actually defined somewhere else and DoCPUBrainCheck() is actually being called somewhere. But since you've got an issue in your spawning function that's probably breaking everything else from working.

But yeah, keep at it, making missions is a ton of fun, though it's got a bit of a learning curve. If you haven't already I'd suggest looking at weegee's scene making tutorials; they're how I learned lua and how to make scenes and they'll have a lot of useful stuff for ya. You can find them here: viewtopic.php?f=8&t=16219

Let me know if this stuff helps and, if it doesn't, if you'd like me to download the rte and poke through it properly sometime when I get the chance or if you'd rather try to figure this out with hints. Good luck!


Sun Dec 25, 2016 12:30 am
Profile
User avatar

Joined: Wed Jul 06, 2011 5:11 pm
Posts: 205
Reply with quote
Post Re: Anyone still around to help with LUA scripting for scenes?
Thanks for the help, I've been making progress and just figure out the doors :)


Mon Dec 26, 2016 6:11 am
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 609
Location: Halifax, Canada
Reply with quote
Post Re: Anyone still around to help with LUA scripting for scenes?
No problem, happy to help. Good luck :)


Mon Dec 26, 2016 7:57 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 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.026s | 18 Queries | GZIP : Off ]