Data Realms Fan Forums
http://45.55.195.193/

Telekinesis
http://45.55.195.193/viewtopic.php?f=73&t=14708
Page 1 of 1

Author:  zalo [ Sun May 17, 2009 5:51 am ]
Post subject:  Telekinesis

'k, I got a little too ambitious, and decided to try and make a Lua mod for telekinesis.

Sadly, nothing happens. Not even an error ;(


Here is the first Lua code I tried to use.
Code:
function Create(self)
   function lengthdir_x(dist,ang)
      return dist * math.cos(-ang);
   end
 
   function lengthdir_y(dist,ang)
      return dist * math.sin(-ang);
   end
   Holding = 0
        curdist = 80;
   IsHoldingSomething = 0
   avgx = 0
   avgy = 0
   dist = 0
end
 
function Update(self)

    if(UInputMan:KeyHeld(8)) then
   Holding = 1
    else
   Holding = 0
    end

    if Holding == 1 then
   for actor in MovableMan.Actors do
       avgx = actor.Pos.X - self.Pos.X + lengthdir_x(96,self:GetAimAngle(true));
       avgy = actor.Pos.Y - self.Pos.Y + lengthdir_y(96,self:GetAimAngle(true));
       dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
       if self.dist ~= nil then
      if dist < curdist then
          curdist = dist;
          actor = Held;
          IsHoldingSomething = 1
      else
          IsHoldingSomething = 0
      end
       end
   end
    end

    if IsHoldingSomething == 1 then
      Held.Pos.X = self.Pos.X + lengthdir_x(96,self:GetAimAngle(true));
      Held.Pos.Y = self.Pos.Y + lengthdir_y(96,self:GetAimAngle(true));
    end

end


Here is the second, using piipu's finding stuff code (though, they are essentially the same).
Code:
function Create(self)
   function lengthdir_x(dist,ang)
      return dist * math.cos(-ang);
   end
 
   function lengthdir_y(dist,ang)
      return dist * math.sin(-ang);
   end
   Holding = 0
        curdist = 80;
   IsHoldingSomething = 0
   avgx = 0
   avgy = 0
   dist = 0
end
 
function Update(self)

    if(UInputMan:KeyHeld(8)) then
   Holding = 1
    else
   Holding = 0
    end


    if Holding == 1 then
      for actor in MovableMan.Actors do
         local diff = math.sqrt(math.pow((actor.Pos.X-self.Pos.X + lengthdir_x(96,self:GetAimAngle(true))),2) + math.pow((actor.Pos.Y - self.Pos.Y + lengthdir_y(96,self:GetAimAngle(true))),2))
         if (diff < 80) and actor.PinStrength == 0 and IsHoldingSomething == 1 then
            actor.Pos.X = self.Pos.X + lengthdir_x(96,self:GetAimAngle(true));
            actor.Pos.Y = self.Pos.Y + lengthdir_y(96,self:GetAimAngle(true));
         end
      end
    end
end

These are both meant to be applied directly to an actor.

They come with the same result, nothing happens. Not even an error.

Help Please.

(By the way, the "8" in the UIInputMan is code for "H").

Author:  Daman [ Sun May 17, 2009 7:36 am ]
Post subject:  Re: Telekinesis

man this is an easy problem

if you want a hard problem look at grif's stuff

KEYRELEASED IS SO GARBAGE ARRRRRRRRRGH

Image


http://rafb.net/p/Ik7HNw57.html

with added leftclick throwing

Author:  Allarcan [ Sun May 17, 2009 12:49 pm ]
Post subject:  Re: Telekinesis

Daman wrote:
man this is an easy problem

if you want a hard problem look at grif's stuff

KEYRELEASED IS SO GARBAGE ARRRRRRRRRGH

Image


http://rafb.net/p/Ik7HNw57.html

with added leftclick throwing



DO WANT!

Author:  Nukes-For-All [ Sun May 17, 2009 2:22 pm ]
Post subject:  Re: Telekinesis

:shock:
Your going to release that.
or
I'm going to eat your head...
With a spork :D

Author:  Daman [ Sun May 17, 2009 3:29 pm ]
Post subject:  Re: Telekinesis

what do you want me to release

Zalo can release it but it'd be pretty boring with no corresponding actor that looks cool. It's pretty much just a quick snippet.

I'll release a decent gravity gun when we get access to held guns(attachables) again.

Author:  mail2345 [ Sun May 17, 2009 5:51 pm ]
Post subject:  Re: Telekinesis

Maybe actor controllers would help?

Author:  Allarcan [ Sun May 17, 2009 6:20 pm ]
Post subject:  Re: Telekinesis

i want it as much as i want this hat -> :cool:

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