View unanswered posts | View active topics It is currently Fri Dec 27, 2024 8:12 am



Reply to topic  [ 24 posts ]  Go to page 1, 2  Next
 Need someone who knows quite a bit of LUA 
Author Message
User avatar

Joined: Thu Jul 15, 2010 1:52 pm
Posts: 165
Reply with quote
Post Need someone who knows quite a bit of LUA
Alright, again i'm back with needed help

I've tried many things and I can't get the LUA code to do as I need

First off: I made a thread asking about invisibility without lua, and I see this is impossible so, I searched around the mod releases and at like page 8-11
I encounter the ghillie suit actor for CC and I checked it out and saw that it had a invisibility script, and I do credit him greatly, but I can't get the code to make myself invisibility instead of changing teams, so can anyone help?

Code:
function Create(self)
   self.curteam = self.Team
   self.shottimer = Timer();
end

function Update(self)
   if self:GetController():IsState(Controller.BODY_CROUCH) then
      self.Team = 1 - self.curteam
   end
   if self:GetController():IsState(Controller.WEAPON_FIRE) then
      self.Team = self.curteam
      self.shottimer:Reset()
   end
   if self:GetController():IsState(Controller.MOVE_LEFT) then
      self.Team = self.curteam
   end
   if self:GetController():IsState(Controller.MOVE_RIGHT) then
      self.Team = self.curteam
   end
   if self:GetController():IsState(Controller.BODY_JUMP) then
      self.Team = self.curteam
   end
   if not(self.shottimer:IsPastRealMS(2000)) then
      self.Team =  self.curteam
   end
   if self.Health <= .5 then
      self.Team = self.curteam
   end
end

function Destroy(self)
   self.Team = self.curteam
end


I took about the flashwhite coding line cause it just made my guy completely white :V


Sun Aug 29, 2010 7:28 am
Profile
User avatar

Joined: Wed Jan 07, 2009 10:26 am
Posts: 4074
Location: That quaint little British colony down south
Reply with quote
Post Re: Need someone who knows quite a bit of LUA
The code for actual invisibility is incredibly different and complicated. Aim lower.


Sun Aug 29, 2010 8:17 am
Profile WWW
User avatar

Joined: Fri Dec 22, 2006 4:20 am
Posts: 4772
Location: Good news everyone!
Reply with quote
Post Re: Need someone who knows quite a bit of LUA
Instead of looking through the mod releases thread so tediously just use the Search function. It's on the red bar near the top of the forum site.

viewtopic.php?f=61&t=14644&hilit=invisibility
Quote:
Stealth Chip
This is a stealth module that allows your units to cloak when not excessively moving or shooting.
Do note that hp damage will disable the cloak.


Looking at the code for it I smashed together something.
Code:
function Visiblize()
   for i = 1,MovableMan:GetMOIDCount() - 1 do
      if MovableMan:GetMOFromID(i).RootID == self.ID then
         MovableMan:GetMOFromID(i).Scale = 1
      end
   end
end

function Create(self)
   self.LastShot = Timer()
   self.Hurt = Timer()
   self.HP = self.Health
end

function Update(self)
   if self:GetController():IsState(Controller.BODY_CROUCH) then
      for i = 1,MovableMan:GetMOIDCount() - 1 do
         if MovableMan:GetMOFromID(i).RootID == self.ID then
            MovableMan:GetMOFromID(i).Scale = 0
         end
      end
   end
   if self.HP ~= self.Health then
      self.Hurt:Reset()
   end
   self.HP = self.Health
   if self:GetController():IsState(Controller.WEAPON_FIRE) then
      self.LastShot:Reset()
   end
   if not(self.LastShot:IsPastRealMS(2000)) or not(self.Hurt:IsPastRealMS(2000)) or self:GetController():IsState(Controller.BODY_JUMP) or self:GetController():IsState(Controller.MOVE_RIGHT) or self:GetController():IsState(Controller.MOVE_LEFT) then
      Visiblize()
   end
end

function Destroy(self)
   Visiblize()
end

Basically what this does is it shrinks the size of the actor down to nothing to make it invisible. The HUD thing above the actor will still be visible, so this might not be everything you were hoping for.


Last edited by CrazyMLC on Sun Aug 29, 2010 8:51 am, edited 4 times in total.



Sun Aug 29, 2010 8:18 am
Profile WWW
User avatar

Joined: Thu Jul 15, 2010 1:52 pm
Posts: 165
Reply with quote
Post Re: Need someone who knows quite a bit of LUA
CrazyMLC wrote:
Instead of looking through the mod releases thread so tediously just use the Search function. It's on the red bar near the top of the forum site.

viewtopic.php?f=61&t=14644&hilit=invisibility
Quote:
Stealth Chip
This is a stealth module that allows your units to cloak when not excessively moving or shooting.
Do note that hp damage will disable the cloak.


Looking at the code for it I smashed together something.
Code:
function Visiblize()
   for i = 1,MovableMan:GetMOIDCount() do
      if MovableMan:GetMOFromID(i).RootID == self.ID then
         MovableMan:GetMOFromID(i).Scale = 1
      end
   end
end

function Create(self)
   self.LastShot = Timer()
   self.Hurt = Timer()
   self.HP = self.Health
end

function Update(self)
   if self:GetController():IsState(Controller.BODY_CROUCH) then
      for i = 1,MovableMan:GetMOIDCount() do
         if MovableMan:GetMOFromID(i).RootID == self.ID then
            MovableMan:GetMOFromID(i).Scale = 0
         end
      end
   end
   if self.HP ~= self.Health then
      self.Hurt:Reset()
   end
   self.HP = self.Health
   if self:GetController():IsState(Controller.WEAPON_FIRE) then
      self.LastShot:Reset()
   end
   if not(self.LastShot:IsPastRealMS(2000)) or not(self.Hurt:IsPastRealMS(2000)) or self:GetController():IsState(Controller.BODY_JUMP) or self:GetController():IsState(Controller.MOVE_RIGHT) or self:GetController():IsState(Controller.MOVE_LEFT) then
      Visiblize()
   end
end

function Destroy(self)
   Visiblize()
end

Basically what this does is it shrinks the size of the actor down to nothing to make it invisible. The HUD thing above the actor will still be visible, so this might not be everything you were hoping for.


Actually that's what i've been hoping for but after then I need to work on my personal mods sprites :V


Sun Aug 29, 2010 8:28 am
Profile
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post Re: Need someone who knows quite a bit of LUA
all of the curteam stuff is just setting a team, what're you

Code:
function Create(self)
   self.shottimer = Timer();
   self.attachables = {};
   for i = 1, MovableMan:GetMOIDCount() - 1 do
      local mo = MovableMan:GetMOFromID(i)
      if mo.RootID == self.ID and i ~= self.ID then
         table.insert(self.attachables, ToAttachable(mo)); end
   end
end

function Update(self)
   for k,v in ipairs(self.attachables) do
      if not MovableMan:ValidMO(v) then
         table.remove(self.attachables,k); end
   end
   if self:GetController():IsState(Controller.BODY_CROUCH) and self.shottimer:IsPastSimMS(200) then
      self:setScale(0);
   end
   if self:GetController():IsState(Controller.WEAPON_FIRE) then
      self:setScale(1);
      self.shottimer:Reset()
   else if self:GetController():IsState(Controller.MOVE_LEFT) or self:GetController():IsState(Controller.MOVE_RIGHT) or self:GetController():IsState(Controller.BODY_JUMP) self.Health <= 10 then
      self:setScale(1);
   end
end

function setScale(self,size)
   self.Scale = size;
   for k,v in ipairs(self.attachables) do
      v.Scale = size;
   end
end
that's closer to what you want, I think, but it'll also make you invincible, so you'll need to do invisible frames for body and head most likely and then scale the limbs.

FFS should've posted this a million years ago <_< triple ninja'd or whatever.


Sun Aug 29, 2010 8:37 am
Profile WWW
User avatar

Joined: Thu Jul 15, 2010 1:52 pm
Posts: 165
Reply with quote
Post Re: Need someone who knows quite a bit of LUA
Image

This is what the script did :V
Also look at the file name :smug:

The 200 health was edited in the character.


Sun Aug 29, 2010 8:44 am
Profile
User avatar

Joined: Fri Dec 22, 2006 4:20 am
Posts: 4772
Location: Good news everyone!
Reply with quote
Post Re: Need someone who knows quite a bit of LUA
Small issue with the last script, looking at Geti's reminded me of it. I've updated the last post's script, try it again please... or try Geti's.


Sun Aug 29, 2010 8:51 am
Profile WWW
User avatar

Joined: Thu Jul 15, 2010 1:52 pm
Posts: 165
Reply with quote
Post Re: Need someone who knows quite a bit of LUA
Ill try both and see which one I like :V

Crazy, your script did the same thing as it did. before
Geti's, script didn't work either :V


Sun Aug 29, 2010 9:00 am
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Need someone who knows quite a bit of LUA
Get rid of the jetpack, feet and hand sprites. Lua can't touch them.
Maybe move the jetpack sprite to the body, the hand sprite to the arm and the feet to the leg.


Sun Aug 29, 2010 9:11 am
Profile
User avatar

Joined: Thu Jul 15, 2010 1:52 pm
Posts: 165
Reply with quote
Post Re: Need someone who knows quite a bit of LUA
I would take the stealth script from the darkstorm
But I don't know what to take and or edit :V

But of course I will credit whoever I get a script from.


Sun Aug 29, 2010 9:15 am
Profile
User avatar

Joined: Wed Jan 07, 2009 10:26 am
Posts: 4074
Location: That quaint little British colony down south
Reply with quote
Post Re: Need someone who knows quite a bit of LUA
Darkstorm's Yuurei script works by switching the sprites of everything.


Sun Aug 29, 2010 9:21 am
Profile WWW
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post Re: Need someone who knows quite a bit of LUA
411570N3 wrote:
Darkstorm's Yuurei script works by switching the sprites of everything.
Nope, scales the limbs cause we don't have frame overrides.
Also yeah you can't do much about the jet & hands than remove it


Sun Aug 29, 2010 9:33 am
Profile WWW
User avatar

Joined: Wed Jan 07, 2009 10:26 am
Posts: 4074
Location: That quaint little British colony down south
Reply with quote
Post Re: Need someone who knows quite a bit of LUA
Ah. I stand corrected. The rest of it is sprite changes though, to allow it to continue to be vulnerable. The scripts in this thread would leave the actor invulnerable to most things.


Sun Aug 29, 2010 10:10 am
Profile WWW
DRL Developer
DRL Developer

Joined: Fri May 15, 2009 10:29 am
Posts: 4107
Location: Russia
Reply with quote
Post Re: Need someone who knows quite a bit of LUA
You could still have leg sprites and hand sprites integrated into their apropriate limbs.
And jetpack on body sprite, or as an attachment.


Sun Aug 29, 2010 11:27 am
Profile
User avatar

Joined: Wed Jan 07, 2009 10:26 am
Posts: 4074
Location: That quaint little British colony down south
Reply with quote
Post Re: Need someone who knows quite a bit of LUA
Yeah, you really don't lose anything from integrating them in this way, seeing as they are barely visually dynamic in a way that is important.


Sun Aug 29, 2010 12:38 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 24 posts ]  Go to page 1, 2  Next

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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.066s | 14 Queries | GZIP : Off ]