Skip to content

Other Primitive Functions

ρMain edited this page Feb 27, 2018 · 5 revisions

Wanna perform a script like in a PQR way?

You can make a script that's going to be called in a loop, like PQR does.
Simply use the function below

  • Callback prototype: none
function RegisterSimpleCallback(enabled, filters, callback);

RegisterSimpleCallback(true, nil,
    function()
        --your script here

        RunMacroText("/party this is a flood ;)")

        --script end
    end
)

Want to iterate objects and perform a custom script?

That's too possible. All maps objects can be iterated and used into a callback you can define!

  • Callback prototype: function(object, name, x, y, z);
-- Take a callback(object, name, position) that gonna be called for each map object.
-- Return true in the callback to break the loop, false otherwise
-- /!\ This function doesnt hold the callback, it performs only one loop
function IterateObjects(enabled, callback)

-- This example is going to print all objects on the map
IterateObjects(true,
	function(object, name, x, y, z)
		print("found the following object on the map: "..name.." with position: " ..x.. " " ..y.. " " ..z)
		return false -- always return false if you dont want to break the iteration
	end
)

Clone this wiki locally