Hello,
I’m trying to rotate some props when a conditional button is activated. I have multiple buttons, and I don’t want to make a single variable for each button, so I have the buttons and props tagged with escape_cond
and escape_prop
, respectively. I get both the buttons and props using the GetCreativeObjectsWithTag
and save each of them to an array. Then, for each button, I subscribe to it’s ActivatedEvent
event using the .Subscribe()
method.
Here comes the problem: the .Subscribe()
method takes a handler function that takes only one parameter of the type agent
and returns void
. However, when the button gets activated, I want the key’s item score, as that will be needed to reference the respective prop for that button, and I don’t have any way to get that item score if I’ll be using the handler function since I only get the data about the player that activated it, not the device itself.
Code:
escape_cond := class(tag){}
escape_prop := class(tag){}
item_rotator := class(creative_device):
var EscapeConditionalButtons : creative_object_interface = array{}
var EscapeProps : creative_object_interface = array{}
OnBegin():void=
set RotatingObjects = GetCreativeObjectsWithTag(stage_01{})
set EscapeConditionalButtons = GetCreativeObjectsWithTag(escape_cond{})
set EscapeProps = GetCreativeObjectsWithTag(escape_prop{})
for (CondBtnObj : EscapeConditionalButtons):
if (CondBtn := conditional_button_device[CondBtnObj]):
itemScore : int = CondBtn.GetItemScore(1)
if(PropItem := EscapeProps[itemScore - 1]):
if (escapeProp := creative_prop[PropItem]):
CondBtn.ActivatedEvent.Subscribe(OnConditonalActivation)
OnConditonalActivation(InAgent:agent):void=
{}
SmoothRotate(Prop : creative_prop, Degree : float, Angle : string) : void =
{}