object.try_get_carrier

a.k.a. object.get_carrier

When called on a weapon or Armor Ability, this function returns the player carrying the item.

When Bungie and 343i use this function, they often manually clear the player variable they are assigning to before calling the function. That functionality is automated in this Megalo dialect: calling the function with the name get_carrier will compile in an assignment to no_player before the call, while calling the function with the name try_get_carrier will not.

This function returns player. Calling this function without storing its return value in a variable is an error.

Example

for each object with label "awful_gun" do
   global.player[0] = current_object.get_carrier()
   if global.player[0] != no_player then
      global.player[0].kill(false)
   end
end

See also