MinchinWeb's MetaLibrary  v.9
Library functions of OpenTTD AI writers.
_MinchinWeb_SW_ Class Reference

Spiral Walker. More...

Public Member Functions

function Start (Tile)
 Sets the starting tile for SpiralWalker. More...
 
function Reset ()
 Resets the variables for the SpiralWalker. More...
 
function Restart ()
 Moves the SpiralWalker to the original starting position. More...
 
function Walk ()
 'Walks' the SpiralWalker one tile at a tile More...
 
function GetStart ()
 Returns the tile the SpiralWalker is starting on. More...
 
function GetStage ()
 Returns the Stage the SpiralWalker is on. More...
 
function GetTile ()
 Returns the Tile the SpiralWalker is on. More...
 
function GetStep ()
 Returns the number of steps the SpiralWalker has done. More...
 

Private Member Functions

 constructor ()
 

Private Attributes

 _start = null
 start tile More...
 
 _startx = null
 x value of start tile More...
 
 _starty = null
 y value of start tile More...
 
 _x = null
 x value of current tile More...
 
 _y = null
 y value of current tile More...
 
 _current_tile = null
 current tile More...
 
 _dx = null
 
 _dy = null
 
 _Steps = null
 see GetStep() More...
 
 _Stage = null
 see GetStage() More...
 
 _StageMax = null
 
 _StageSteps = null
 

Detailed Description

Spiral Walker.

Version
v.3 (2012-01-28)
Author
W. Minchin (MinchinWeb)
Since
MetaLibrary v.4

The SpiralWalker class allows you to define a starting point, and then 'walk' all the tiles in a spiral outward. It was originally used to find a build-able spot for my HQ in WmDOT, but is useful for many other things as well.

Note
SpiralWalker is designed to be a persistent class.
See also
_MinchinWeb_LW_
Todo:
add image showing the walk out pattern

Definition at line 44 of file Spiral.Walker.nut.

Member Function Documentation

_MinchinWeb_SW_::constructor ( )
inlineprivate

Definition at line 58 of file Spiral.Walker.nut.

function _MinchinWeb_SW_::GetStage ( )
inline

Returns the Stage the SpiralWalker is on.

Basically, the line segments its completed plus one; it takes four stages to complete a revolution.

Returns
stage number
See also
GetStep()
Todo:
Add an image showing how stages are counted

Definition at line 104 of file Spiral.Walker.nut.

function _MinchinWeb_SW_::GetStart ( )
inline

Returns the tile the SpiralWalker is starting on.

Returns
The tile the SpiralWalker is starting on
See also
Start()

Definition at line 94 of file Spiral.Walker.nut.

function _MinchinWeb_SW_::GetStep ( )
inline

Returns the number of steps the SpiralWalker has done.

Returns
The number of steps the SpiralWalker has done.
See also
GetStage()
Todo:
Add an image showing how steps are counted

Definition at line 118 of file Spiral.Walker.nut.

function _MinchinWeb_SW_::GetTile ( )
inline

Returns the Tile the SpiralWalker is on.

Returns
the Tile the SpiralWalker is on.
See also
GetStep()
GetStage()

Definition at line 111 of file Spiral.Walker.nut.

function _MinchinWeb_SW_::Reset ( )

Resets the variables for the SpiralWalker.

See also
Restart()

Definition at line 140 of file Spiral.Walker.nut.

function _MinchinWeb_SW_::Restart ( )

Moves the SpiralWalker to the original starting position.

See also
Reset()

Definition at line 149 of file Spiral.Walker.nut.

function _MinchinWeb_SW_::Start ( Tile  )

Sets the starting tile for SpiralWalker.

See also
Restart()

Definition at line 123 of file Spiral.Walker.nut.

function _MinchinWeb_SW_::Walk ( )

'Walks' the SpiralWalker one tile at a tile

Returns
the tile that the SpiralWalker is now "standing on"
Note
This is where (most) of the action is!
Before calling this function, you need to set the Start().

Definition at line 162 of file Spiral.Walker.nut.

Member Data Documentation

_MinchinWeb_SW_::_current_tile = null
private

current tile

Definition at line 50 of file Spiral.Walker.nut.

_MinchinWeb_SW_::_dx = null
private

Definition at line 51 of file Spiral.Walker.nut.

_MinchinWeb_SW_::_dy = null
private

Definition at line 52 of file Spiral.Walker.nut.

_MinchinWeb_SW_::_Stage = null
private

see GetStage()

Definition at line 54 of file Spiral.Walker.nut.

_MinchinWeb_SW_::_StageMax = null
private

Definition at line 55 of file Spiral.Walker.nut.

_MinchinWeb_SW_::_StageSteps = null
private

Definition at line 56 of file Spiral.Walker.nut.

_MinchinWeb_SW_::_start = null
private

start tile

Definition at line 45 of file Spiral.Walker.nut.

_MinchinWeb_SW_::_startx = null
private

x value of start tile

Definition at line 46 of file Spiral.Walker.nut.

_MinchinWeb_SW_::_starty = null
private

y value of start tile

Definition at line 47 of file Spiral.Walker.nut.

_MinchinWeb_SW_::_Steps = null
private

see GetStep()

Definition at line 53 of file Spiral.Walker.nut.

_MinchinWeb_SW_::_x = null
private

x value of current tile

Definition at line 48 of file Spiral.Walker.nut.

_MinchinWeb_SW_::_y = null
private

y value of current tile

Definition at line 49 of file Spiral.Walker.nut.


The documentation for this class was generated from the following file: