Data Realms Fan Forums
http://45.55.195.193/

Lua Coding Help (Random Spinning Directions)
http://45.55.195.193/viewtopic.php?f=1&t=15574
Page 1 of 1

Author:  Some_stranger [ Fri Jun 26, 2009 8:29 am ]
Post subject:  Lua Coding Help (Random Spinning Directions)

Ok, So for my Silly Federation I want the Rocket Launcher to be powerful, but go up and down randomly. Not just ---\__Crash but like /\/\/\/\/\/\----Crash So its like Up down curves and random

If anybody at all can refer me to a Wiki For the Lua i'd be grateful. Also if maximdude is on here i ♥♥♥♥ love you man.

Author:  Grif [ Fri Jun 26, 2009 8:32 am ]
Post subject:  Re: Lua Coding Help (Random Spinning Directions)

Code:
function Create(self)
    function sinewave(amplitude,wavenumber,angvel,phase)
        return amplitude * math.sin(wavenumber - angvel + phase / 30);
    end
   
   function sawtooth(x,range,slope)
      return (x % range) * slope
   end

   self.initialy = self.Pos.Y - 20;
end

function Update(self)
   --self.Pos.Y = self.initialy + sinewave(30,1,math.pi,self.Pos.X);
   self.Pos.Y = self.initialy + sawtooth(self.Pos.X,100,0.5);
end


Code:
function Create(self)
    function sinewave(amplitude,wavenumber,angvel,phase)
        return amplitude * math.sin(wavenumber - angvel + phase / 20);
    end
   self.initialy = self.Pos.Y;
end

function Update(self)
      self.Pos.Y = self.initialy + sinewave(40,1,math.pi / 2,self.Pos.X);
end


Try these out, see what you think.

They're not exactly random, but they do go up and down in a fixed way. Adding an element of random-ness would be fairly easy, as well.

Author:  Some_stranger [ Fri Jun 26, 2009 8:33 am ]
Post subject:  Re: Lua Coding Help (Random Spinning Directions)

Well ♥♥♥♥ that was fast. And yeah, i just learned to look at stickies so i don't really need anymore lua help. Glad you Could help Greatly though, man your the best around, nothings gonna ever bring you doooowwwnnn.

Author:  Some_stranger [ Fri Jun 26, 2009 8:53 am ]
Post subject:  Re: Lua Coding Help (Random Spinning Directions)

Alright Yeah, that works decently except Its now what i'm looking for. I want it to rotate the missile not move it up and down, so basically the rocket will OrienttoVel and just look good.

How would i do that, Lua Docs don't Seem to help, however i'm new to lua and cant really understand.

Author:  mail2345 [ Fri Jun 26, 2009 8:55 am ]
Post subject:  Re: Lua Coding Help (Random Spinning Directions)

Lua Docs are for the functions.
To learn lua itself, the offical lua site has some good tutorials.

Author:  mail2345 [ Fri Jun 26, 2009 8:56 am ]
Post subject:  Re: Lua Coding Help (Random Spinning Directions)

Lua Docs are for the functions.
To learn lua itself, the offical lua site has some good tutorials.
EDIT:
Also you need to look at the function dump, and read some code, as the lua docs are half arsed.

Author:  Some_stranger [ Fri Jun 26, 2009 9:25 am ]
Post subject:  Re: Lua Coding Help (Random Spinning Directions)

Well hey, thanks guys. I've Been Messing with some things and i figure i'll have the thruster rotate on an offset at random. You guys really helped, so thanks.

Author:  Some_stranger [ Fri Jun 26, 2009 9:42 am ]
Post subject:  Re: Lua Coding Help (Random Spinning Directions)

Sorry for Double Double Posting, I dont know if thats a problem here, But i guess i Should Show Some of my errm, 'Crap'.

Here are my Weapons

Its Known as the Badgers Federation, Simply because all of the Cool Animals are taken (Like Bears)

Weapons:

Image

That would be it for now. Well, Thanks for the help, this can be closed.

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