Data Realms Fan Forums http://45.55.195.193/ |
|
Toggleable hover code [solved] http://45.55.195.193/viewtopic.php?f=73&t=18367 |
Page 1 of 2 |
Author: | Duh102 [ Mon Apr 05, 2010 8:10 pm ] |
Post subject: | 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: And an actor with the following script attached. Attachment: 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. |
Author: | PhantomAGN [ Mon Apr 05, 2010 10:48 pm ] |
Post subject: | 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. |
Author: | Duh102 [ Mon Apr 05, 2010 11:03 pm ] |
Post subject: | 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: Attachment: |
Author: | Grif [ Mon Apr 05, 2010 11:26 pm ] |
Post subject: | 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. |
Author: | Duh102 [ Mon Apr 05, 2010 11:46 pm ] |
Post subject: | 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 |
Author: | Grif [ Tue Apr 06, 2010 12:11 am ] |
Post subject: | Re: Toggleable hover code |
Okay, I might be wrong, try GoldCost with a capital C. |
Author: | Duh102 [ Tue Apr 06, 2010 1:08 am ] |
Post subject: | Re: Toggleable hover code |
That's readonly, tried that. |
Author: | CrazyMLC [ Tue Apr 06, 2010 3:13 am ] |
Post subject: | 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 |
Author: | TheLastBanana [ Tue Apr 06, 2010 3:17 am ] |
Post subject: | 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 |
Author: | Duh102 [ Tue Apr 06, 2010 3:18 am ] |
Post subject: | 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: Attachment: |
Author: | CrazyMLC [ Tue Apr 06, 2010 3:38 am ] | ||
Post subject: | Re: Toggleable hover code | ||
Does this work? ownController:IsState(Controller.HOLD_LEFT) -> UInputMan:KeyPressed(82) == true
|
Author: | Duh102 [ Tue Apr 06, 2010 3:43 am ] |
Post subject: | Re: Toggleable hover code |
That shouldn't make a difference, it's not printing the "Flying!" thing. |
Author: | CrazyMLC [ Tue Apr 06, 2010 3:46 am ] |
Post subject: | Re: Toggleable hover code |
D'oh. if self.timer:IsPastSimMS(50) then ------> if self.timer:IsPastSimMS(50) == true then |
Author: | TheLastBanana [ Tue Apr 06, 2010 3:48 am ] |
Post subject: | 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. |
Author: | Duh102 [ Tue Apr 06, 2010 3:49 am ] |
Post subject: | Re: Toggleable hover code |
Page 1 of 2 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |