View unanswered posts | View active topics It is currently Tue Apr 16, 2024 10:53 am



Reply to topic  [ 5 posts ] 
 Pie Menu 
Author Message
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Pie Menu
I was trying to make a mod, which is a little TDExplosive with a pie slice. When you use the pie menu option, it heals the parent for 25 HP and then gibs itself, but it's not working.

I'm not getting any kind of errors, could someone help me in this?

Thanks

Attachment:
Healing.rte.rar [4.17 KiB]
Downloaded 179 times


PS: It has my best sprite ever :D


Sun Sep 18, 2011 2:50 am
Profile
DRL Developer
DRL Developer

Joined: Tue Aug 11, 2009 5:09 am
Posts: 395
Reply with quote
Post Re: Pie Menu
I think the problem is that you try to convert the TDExplosive to an actor. Try this:

Code:
function AddHealth(Actor)
   local Parent = ToAHuman(Actor)
   if Parent.EquippedItem then   -- not sure of this check is necessary
      Parent.Health = math.min(Parent.Health + 25, 100)
      ToTDExplosive(Parent.EquippedItem):GibThis()
   end
end


Sun Sep 18, 2011 6:45 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Pie Menu
Tried to what?!

Seriously?

Where?

My lua can't be THAT bad. Or it can?


Sun Sep 18, 2011 6:55 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Pie Menu
local healpack = ToActor(actor).EquippedItem

Is a bit ambiguous. It's also unnecessary; there's no need to run ToActor twice. Much better to store it as a local variable, which is what the second line of Abdul's code does.

Then the check that the EquippedItem is there, which is just good form; CC generally does not like it when you try to modify nonexistent things.
In Abdul's code you'll notice the math.min; that very neatly replaces your if then statement. It decides between the lower value out of the two that you pass into it.
The ToTDExplosive is just a safety check/insurance that the class of .EquippedItem isn't wrong.


Sun Sep 18, 2011 6:41 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Pie Menu
Well, I have the doubt on pie menus. When I place it on a held device, where does the code work? I mean, it's like if the code was added to the actor? Or to the gun?
Because if the function is AddHealth(Actor), is the variable Actor defined as the parent of the held device? That's what confused me.


Mon Sep 19, 2011 12:57 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.054s | 20 Queries | GZIP : Off ]