View unanswered posts | View active topics It is currently Thu Dec 26, 2024 6:21 pm



Reply to topic  [ 7 posts ] 
 Telekinesis 
Author Message

Joined: Sat Feb 03, 2007 7:11 pm
Posts: 1496
Reply with quote
Post 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").


Sun May 17, 2009 5:51 am
Profile WWW
User avatar

Joined: Fri Jan 26, 2007 3:22 am
Posts: 1451
Reply with quote
Post 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


Sun May 17, 2009 7:36 am
Profile
User avatar

Joined: Wed Jun 11, 2008 12:59 am
Posts: 27
Reply with quote
Post 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!


Sun May 17, 2009 12:49 pm
Profile
User avatar

Joined: Tue Dec 11, 2007 5:53 pm
Posts: 26
Location: Nevermore
Reply with quote
Post Re: Telekinesis
:shock:
Your going to release that.
or
I'm going to eat your head...
With a spork :D


Sun May 17, 2009 2:22 pm
Profile
User avatar

Joined: Fri Jan 26, 2007 3:22 am
Posts: 1451
Reply with quote
Post 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.


Sun May 17, 2009 3:29 pm
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Telekinesis
Maybe actor controllers would help?


Sun May 17, 2009 5:51 pm
Profile
User avatar

Joined: Wed Jun 11, 2008 12:59 am
Posts: 27
Reply with quote
Post Re: Telekinesis
i want it as much as i want this hat -> :cool:


Sun May 17, 2009 6:20 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

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.077s | 14 Queries | GZIP : Off ]