47
edits
Lazy Warlock (talk | contribs) No edit summary |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
__FORCETOC__ | __FORCETOC__ | ||
{{GameVersion|1.9}} | |||
= Introduction = | = Introduction = | ||
Line 50: | Line 50: | ||
<syntaxhighlight lang="c#"> | <syntaxhighlight lang="c#"> | ||
public void | public void OnTick(float par) | ||
{ | { | ||
Line 62: | Line 62: | ||
{ | { | ||
base.Initialize(api); | base.Initialize(api); | ||
RegisterGameTickListener( | RegisterGameTickListener(OnTick, 20); | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 69: | Line 69: | ||
<syntaxhighlight lang="c#"> | <syntaxhighlight lang="c#"> | ||
public void | public void OnTick(float par) | ||
{ | { | ||
timer++; | timer++; | ||
if(timer > 60) | if(timer > 60) | ||
{ | { | ||
Block block = | Block block = Api.World.BlockAccessor.GetBlock(Pos); | ||
if (block.Code.Path.EndsWith("-on")) | if (block.Code.Path.EndsWith("-on")) | ||
block = | { | ||
block = Api.World.GetBlock(block.CodeWithParts("off")); | |||
} | |||
else | else | ||
block = | { | ||
block = Api.World.GetBlock(block.CodeWithParts("on")); | |||
} | |||
Api.World.BlockAccessor.SetBlock(block.BlockId, Pos); | |||
} | } | ||
} | } | ||
Line 130: | Line 135: | ||
= Mod Download = | = Mod Download = | ||
* for VS 1.12 (Source only): [https://github.com/anegostudios/vsmodexamples/tree/ac7eeaed597b8a25dcfc2366b9c51cd92850d2b9/Mods/Ticking GitHub] | |||
* for VS 1.9: [https://wiki.vintagestory.at/images/8/80/Ticking_v1.0.0.zip Ticking_v1.0.0.zip] | * for VS 1.9: [https://wiki.vintagestory.at/images/8/80/Ticking_v1.0.0.zip Ticking_v1.0.0.zip] | ||
* for VS 1.6: [https://wiki.vintagestory.at/images/6/65/Ticking.zip Ticking.zip] | * for VS 1.6: [https://wiki.vintagestory.at/images/6/65/Ticking.zip Ticking.zip] |
edits