Data Realms Fan Forums
http://45.55.195.193/

dofile help
http://45.55.195.193/viewtopic.php?f=73&t=14684
Page 1 of 1

Author:  Duh102 [ Sat May 16, 2009 3:45 pm ]
Post subject:  dofile help

Ok, so for a request for Gotcha! I want to make a one-use healing gun. After browsing the LuaDocs, I see two possible ways to do the self-gibbing. One, it looks like there's an "IsActivated" function on HeldDevices, so could I do this in Update()?
Code:
if IsActivated() then
   (stuff)
   self.GibThis();
end

Or, another way Grif said is the option, having a particle do the Lua in it's Create() function. Would the particle be able to access that which it was fired from, like self.Parent.GibThis()?

EDIT: Got that done.
NOW, how do I retrieve a method from a dofile? I tried dofile("file"):method(params);, but that failed mightily, as well as just plain dofile("file"); and later self:method(params);, and the same but without the self:.

Author:  411570N3 [ Sat May 16, 2009 4:04 pm ]
Post subject:  Re: Self gib help on HDFirearm

Couldn't you just give it a ridiculously high fire rate, fullauto, have the healing thing set as the tracer and a self destruct particle as the main round?
If you make the main round hitsmos and non-fireignoresthis with the muzzleoffset inside the gun the gun will self destruct after one use.

Author:  Duh102 [ Sat May 16, 2009 7:14 pm ]
Post subject:  Re: Self gib help on HDFirearm

Did it. It seems that the HDFirearm's update(self) is not called until it is out of an Actor's hands. I followed 411570N3's advice and made the particles do the work, both health-ing and gibbing.

NOW, how do I retrieve a method from a dofile? I tried dofile("file"):method(params);, but that failed mightily, as well as just plain dofile("file"); and later self:method(params);, and the same but without the self:.

Author:  Daman [ Sat May 16, 2009 8:08 pm ]
Post subject:  Re: Self gib help on HDFirearm

Duh102 wrote:
Did it. It seems that the HDFirearm's update(self) is not called until it is out of an Actor's hands. I followed 411570N3's advice and made the particles do the work, both health-ing and gibbing.

NOW, how do I retrieve a method from a dofile? I tried dofile("file"):method(params);, but that failed mightily, as well as just plain dofile("file"); and later self:method(params);, and the same but without the self:.


What? A function and a method are very different. Just dofile("myfile"); at the top, and any functions defined in that file will be loaded and usable.

Author:  Duh102 [ Sat May 16, 2009 8:46 pm ]
Post subject:  Re: dofile help

Got it now. Thanks Daman.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/