Dictionary; GameRule - HWRM/KarosGraveyard GitHub Wiki

Game Rule

The terms 'game rule' and 'rule' are interchangeable.

Quote from "HW2_SCAR.pdf":

"A Rule is simply a user-defined function that, once "added", is then evaluated by the game every interval. The Rule is added by using the Rule_Add( "name of Rule" ) function, and passing in the name of the Rule that you wish to add. The interval that the Rule is evaluated at can either be the default (every frame) or can be set (every x seconds), using the Rule_AddInterval function in place of the Rule_Add. The interval can be defined on a per-Rule basis, allowing you to specify a different interval for every Rule that you have."

For example:

function myRuleFunction()
  print("Hello! Gametime is now: " .. Universe_GameTime());
end

Rule_AddInterval("myRuleFunction", 1); -- call it every 1 second

💡 Using Rule_Add can be expensive, and you will rarely need to call a function as fast as possible; for this reason its generally preferred to use Rule_AddInterval.

Related Pages