Data Realms Fan Forums

Pie Menu
Page 1 of 1

Author:  Asklar [ Sun Sep 18, 2011 2:50 am ]
Post subject:  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?


Healing.rte.rar [4.17 KiB]
Downloaded 72 times

PS: It has my best sprite ever :D

Author:  Abdul Alhazred [ Sun Sep 18, 2011 6:45 am ]
Post subject:  Re: Pie Menu

I think the problem is that you try to convert the TDExplosive to an actor. Try this:

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)

Author:  Asklar [ Sun Sep 18, 2011 6:55 am ]
Post subject:  Re: Pie Menu

Tried to what?!



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

Author:  Grif [ Sun Sep 18, 2011 6:41 pm ]
Post subject:  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.

Author:  Asklar [ Mon Sep 19, 2011 12:57 am ]
Post subject:  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.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group