Changes

Jump to navigation Jump to search
→‎Events (SMAPI 3.0): + Game loop events
Line 260: Line 260:  
{{SMAPI upcoming|3.0}}
 
{{SMAPI upcoming|3.0}}
 
SMAPI 3.0 will introduce a new event system that's much more powerful, flexible, and consistent. You can try these events now in SMAPI 2.6+, but '''these are preview prototypes and may change at any time'''. See [[Modding:Migrate to SMAPI 3.0]] for details.
 
SMAPI 3.0 will introduce a new event system that's much more powerful, flexible, and consistent. You can try these events now in SMAPI 2.6+, but '''these are preview prototypes and may change at any time'''. See [[Modding:Migrate to SMAPI 3.0]] for details.
 +
 +
===Game loop===
 +
<tt>this.Helper.Events.GameLoop</tt> has events linked to the game's update loop. The update loop runs roughly ≈60 times/second to run game logic like state changes, action handling, etc. These can be useful, but you should consider more semantic events like <tt>Input</tt> if possible.
 +
 +
{| class="wikitable"
 +
|-
 +
! event
 +
! summary
 +
{{/event
 +
|name = Launched
 +
|desc = Raised after the game is launched, right before the first update tick. This happens once per game session (unrelated to loading saves). All mods are loaded and initialised at this point, so this is a good time to set up mod integrations.
 +
}}
 +
{{/event
 +
|name = Updating<br />Updated
 +
|desc = Raised before/after the game performs its overall update tick (≈60 times per second).
 +
 +
|arg name 1 = <tt>e.Ticks</tt>
 +
|arg type 1 = <tt>int</tt>
 +
|arg desc 1 = The number of ticks elapsed since the game started, including the current tick.
 +
 +
|arg name 2 = <tt>e.IsOneSecond</tt>
 +
|arg type 2 = <tt>bool</tt>
 +
|arg desc 2 = Whether <tt>e.TicksElapsed</tt> is a multiple of 60, which happens approximately once per second.
 +
 +
|arg name 3 = <tt>e.IsMultipleOf(int number)</tt>
 +
|arg type 3 = ''method'' returns <tt>bool</tt>
 +
|arg desc 3 = Whether <tt>e.TicksElapsed</tt> is a multiple of the given number. This is mainly useful if you want to run logic intermittently (e.g. <code>e.IsMultipleOf(30)</code> for every half-second).
 +
}}
 +
|}
    
===Input===
 
===Input===
translators
8,441

edits

Navigation menu