View unanswered posts | View active topics It is currently Fri Apr 19, 2024 6:04 am



Reply to topic  [ 25 posts ]  Go to page 1, 2  Next
 Halp with some code 
Author Message
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Halp with some code
Ok, so, I have a gun that shoots a shell with 'poison'.
The shell travels and hits a target (Must be a live human to work), then it gibs and then the lua part must kick in. Sadly, this ♥♥♥♥ ain't workin'.

I've put the code together with some copypasta and editing from other mods (Cause I fail at lua, obviously >_<)

Code:
function Create(self)
   self.hurtTimer = Timer();
   self.hurtInterval = 10;
end

function Update(self)
   for actor in MovableMan.Actors do
      if actor.PresetName == "Browncoat Light" or actor.PresetName == "Browncoat Heavy" or actor.PresetName == "Soldier Light" or actor.PresetName == "Soldier Heavy" or actor.PresetName == "Dafred" or actor.PresetName == "Mia" or actor.PresetName == "Dimitri" or actor.PresetName == "Brutus" or actor.PresetName == "Sandra" or actor.PresetName == "Gordon" then
         if self.hurtTimer:IsPastSimMS(self.hurtInterval) then
            actor.Health = actor.Health - 3;
            self.hurtTimer:Reset();
         end
      end
   end
end


What is wrong?


Tue Jun 02, 2009 8:08 pm
Profile
Banned
User avatar

Joined: Tue Feb 27, 2007 4:05 pm
Posts: 2527
Reply with quote
Post Re: Halp with some code
I'll help you when you spell right. Intentional grammatical and spelling errors are not witty or humorous.


Tue Jun 02, 2009 8:33 pm
Profile YIM
User avatar

Joined: Wed Jan 14, 2009 7:12 pm
Posts: 1525
Location: In between your sister's legs, showing her how to use a... PS3 controller!
Reply with quote
Post Re: Halp with some code
Intentional refusal to help over such a tiny thing as intentional misspells is not witty or humorous. Don't flame him for a choice he made intentionally for effect.


Tue Jun 02, 2009 8:42 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Halp with some code
ProjektTHOR wrote:
I'll help you when you spell right. Intentional grammatical and spelling errors are not witty or humorous.


Don't be an ass, if you aren't willing to help, don't even post.

Wait, let me fix that.

Don't be an ass, if aren't willing to hAlp, don't even post.


Tue Jun 02, 2009 8:47 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Halp with some code
MaximDude wrote:
Don't be an ass, if you aren't willing to help, don't even post.

Wait, let me fix that.

Don't be an ass, if aren't willing to hAlp, don't even post.


If you need help don't be an ass about accepting it?


Wed Jun 03, 2009 12:53 am
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Halp with some code
Grif wrote:
MaximDude wrote:
Don't be an ass, if you aren't willing to help, don't even post.

Wait, let me fix that.

Don't be an ass, if aren't willing to hAlp, don't even post.


If you need help don't be an ass about accepting it?


If you're not offereing help, don't try proving somebody else is an ass and don't post?

Seriously people.


Wed Jun 03, 2009 5:00 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Halp with some code
What's wrong is that you haven't designated any actor to do it to.

Either on update or destroy copy the target finding code from the coalition missile launcher, then do whatever you need to to it. Also, to designate a holy ♥♥♥♥ of things at once, try using a list rather than individually listing all of them. It's faster and neater.


Wed Jun 03, 2009 5:57 am
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Halp with some code
Grif wrote:
What's wrong is that you haven't designated any actor to do it to.

Either on update or destroy copy the target finding code from the coalition missile launcher, then do whatever you need to to it. Also, to designate a holy ♥♥♥♥ of things at once, try using a list rather than individually listing all of them. It's faster and neater.


Ok, thanks, i'll ty that. :D
Also, mind explaining how to make a list?


Wed Jun 03, 2009 11:58 am
Profile
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post Re: Halp with some code
Code:
actorlist = {"ActorName", "AnotherActorName", etc}


Wed Jun 03, 2009 12:17 pm
Profile WWW
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Halp with some code
Geti wrote:
Code:
actorlist = {"ActorName", "AnotherActorName", etc}


Ok... Simple enough...

How do I define it in the 'if' part?

'if actor.PresetName' and then?


Wed Jun 03, 2009 12:19 pm
Profile
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post Re: Halp with some code
Code:
actorlist = {list of strings}
for actor in MovableMan.Actors do
   if string.find (table.concat(actorlist),actor.PresetName) then
      --stuff
   end
end


Wed Jun 03, 2009 1:10 pm
Profile WWW
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Halp with some code
Ok, thank you very much, good sir.
Hopefully, i'll manage to get it working.


Wed Jun 03, 2009 1:20 pm
Profile
User avatar

Joined: Fri Jan 26, 2007 3:22 am
Posts: 1451
Reply with quote
Post Re: Halp with some code
Geti wrote:
Code:
 string.find (table.concat(actorlist),actor.PresetName)



I really can't tell if you're copypasting the code you post from somewhere else or what, because there's always a mistake like this~


Last edited by Daman on Thu Jun 04, 2009 3:01 am, edited 1 time in total.



Wed Jun 03, 2009 7:04 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Halp with some code
What is wrong with it?


Wed Jun 03, 2009 7:18 pm
Profile
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post Re: Halp with some code
looking at my post, and then back to yours, it looks like you're seeing color tags for some reason.. i cant see them in my post though, so im thinking its something your end. i am copypasting from notepad++, so i can indent easily. no idea why that would lead to color tags in your quote of my post without them though.


Wed Jun 03, 2009 9:12 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 25 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.091s | 15 Queries | GZIP : Off ]