View unanswered posts | View active topics It is currently Sat Jan 11, 2025 11:06 pm



Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
 Toggleable hover code [solved] 
Author Message
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Toggleable hover code [solved]
Ok, so I think I have most of this figured out but the actual toggling is the problem.
I have a gun which spawns a particle with the following script attached
Attachment:
Floater.txt [886 Bytes]
Downloaded 204 times

And an actor with the following script attached.
Attachment:
Fly.txt [2.11 KiB]
Downloaded 216 times

In theory, when the actor activates the gun the hover code should kick in, yes? For some reason this is not the case. Any ideas on what I did wrong?

Further information: The actor's Goldvalue is set to 1337 (with the debug print) so perhaps I got the position of the timer reset wrong?
EDIT: With a bit of a print I found it does indeed reset every 50ms, so that's not it.


Mon Apr 05, 2010 8:10 pm
Profile
User avatar

Joined: Mon Jun 29, 2009 2:40 am
Posts: 610
Location: Deep below The Map of Mars
Reply with quote
Post Re: Toggleable hover code
I read your Lua, and I do not see where you would determine what actor fired the particle.
Pretty sure you need to do that in order to manipulate said actor.

Also, it's GoldValue, not GoldCost.
Also, checking that is only going to determine if the particle's value is 1337.
If my senior project had not literally caught fire (bad capacitor, no regulator, oops) I would have been working on a similar script.

-- Disregard that, I ignored the first DL.


Last edited by PhantomAGN on Mon Apr 05, 2010 11:31 pm, edited 1 time in total.



Mon Apr 05, 2010 10:48 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Toggleable hover code
I did #1, look at the section in floater beginning with "for actor in MovableMan.Actors do"
I have GoldValue in floater but not fly... If that's it I'm gonna be angry.

EDIT: And now it tells me that GoldValue is read only. Well then I suppose I have to use something else. iirc you can change InstanceName? Worth a shot.

Did not work and scale does not seem to work either, strangely enough. Maybe I'm just doing it wrong. Updated version.
Attachment:
Floater.txt [868 Bytes]
Downloaded 187 times

Attachment:
Fly.txt [2.1 KiB]
Downloaded 187 times


Mon Apr 05, 2010 11:03 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Toggleable hover code
PhantomAGN wrote:
Also, it's GoldValue, not GoldCost.


Nope. The lua property is Goldcost, specifically, not GoldValue, despite what the .ini property is labeled.

Duh, try "Goldcost" (without capitalizing cost!) in both scripts.


Mon Apr 05, 2010 11:26 pm
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Toggleable hover code
I've found there's something wrong in getting the actor, I put the printing of the Goldcost before changing it and it cannot find it. Hm. I don't see how it could be failing though...
For quick reference, here is the pertinent sections of floater.lua.
Code:
self.parent = nil;
   
   --Find out who shot the weapon by finding the closest actor within 50 pixels.
   local curdist = 500;
   for actor in MovableMan.Actors do
      local avgx = actor.Pos.X - self.Pos.X;
      local avgy = actor.Pos.Y - self.Pos.Y;
      local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
      if dist < curdist then
         curdist = dist;
         self.parent = actor;
      end
   end
   
   if MovableMan:IsActor(self.parent) then
      print("" .. self.parent.Goldcost);
      if not (self.parent.Goldcost == 1337) then


Mon Apr 05, 2010 11:46 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Toggleable hover code
Okay, I might be wrong, try GoldCost with a capital C.


Tue Apr 06, 2010 12:11 am
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Toggleable hover code
That's readonly, tried that.


Tue Apr 06, 2010 1:08 am
Profile
User avatar

Joined: Fri Dec 22, 2006 4:20 am
Posts: 4772
Location: Good news everyone!
Reply with quote
Post Re: Toggleable hover code
Fly.lua:
Code:
      if self.Scale == 1.01 then
         print "Flying!"; ------problem
         local ownController = self:GetController();
         if not(self:IsDead()) then ------problem
            if self.AngularVel > 0 or self.AngularVel < 0 then ------problem?

Code:
      if self.Scale == 1.01 then
         print("Flying!");
         local ownController = self:GetController();
         if not(self:IsDead() == true) then
            if self.AngularVel ~= 0 then


Last edited by CrazyMLC on Tue Apr 06, 2010 3:17 am, edited 1 time in total.



Tue Apr 06, 2010 3:13 am
Profile WWW
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: Toggleable hover code
Actually, that second one is fine as far as I can tell. If anything, you've made it worse - wouldn't this be easier?
Code:
      if self.Scale == 1.01 then
         print("Flying!");
         local ownController = self:GetController();
         if (self:IsDead() == false) then
            if self.AngularVel > 0 or self.AngularVel < 0 then


Tue Apr 06, 2010 3:17 am
Profile WWW
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Toggleable hover code
That might be a bit nicer, yes. I will correct and see if it fixes anything.

EDIT: Hm, nope, no fixing. I'm still wondering if it's grabbing the actor correctly, perhaps I'll add in a print for the ClassName.

EDIT2: Nope, it's getting an AHuman alright.

EDIT3: Oh yeah, here's the current state of the script.
Attachment:
Floater.txt [911 Bytes]
Downloaded 190 times

Attachment:
Fly.txt [2.11 KiB]
Downloaded 194 times


Tue Apr 06, 2010 3:18 am
Profile
User avatar

Joined: Fri Dec 22, 2006 4:20 am
Posts: 4772
Location: Good news everyone!
Reply with quote
Post Re: Toggleable hover code
Does this work?

ownController:IsState(Controller.HOLD_LEFT) -> UInputMan:KeyPressed(82) == true


Attachments:
Fly.txt [1.94 KiB]
Downloaded 248 times
Tue Apr 06, 2010 3:38 am
Profile WWW
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Toggleable hover code
That shouldn't make a difference, it's not printing the "Flying!" thing.


Tue Apr 06, 2010 3:43 am
Profile
User avatar

Joined: Fri Dec 22, 2006 4:20 am
Posts: 4772
Location: Good news everyone!
Reply with quote
Post Re: Toggleable hover code
D'oh.

if self.timer:IsPastSimMS(50) then ------> if self.timer:IsPastSimMS(50) == true then


Tue Apr 06, 2010 3:46 am
Profile WWW
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: Toggleable hover code
MLC, you don't have to waste your time doing that. It's not actually necessary. A lot of my scripts include it purely out of habit, but either way it's just going to return true.


Tue Apr 06, 2010 3:48 am
Profile WWW
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Toggleable hover code
Same thing, it returns a boolean so it doesn't matter. Ninja'd. I just tried removing the check for the toggle variable and it works fine without, so that's the problem. The toggle variable is for some reason not being set, even though it's saying it's being set and the target is an AHuman.


Tue Apr 06, 2010 3:49 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 18 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.046s | 14 Queries | GZIP : Off ]