Check object action exists (Lua Script)

  • #10, by LebosteinWednesday, 16. September 2015, 13:56 9 years ago

    Key Killer

    621 Posts


  • #11, by darren-beckettWednesday, 16. September 2015, 14:14 9 years ago
    All done -- I've added an error check:
    function objectActionExists(obj, actionName)
    local strActionName = "'" .. actionName .. "' executed"
    
    	if obj:isEmpty() then
    		print("Object is null")
    		return false
    	end
    
    	local act = obj.ObjectActions
    
    	-- iterate through the object list with a for loop...
    	for i = 1, #act do
    		if act[i]:getName() == strActionName then
    		    return true
    		end
    	end
    	return false
    end
    

    Great Poster

    384 Posts

  • #12, by afrlmeWednesday, 16. September 2015, 14:49 9 years ago
    Nice one. wink

    Imperator

    7285 Posts