So, no quaternions this time. Can't really say where this idea came from but someone may find it useful.
I'll explain how it's used first then we can discuss the uses which it can be put.
First define a zone using waypoints, the zone can be any shape with as many sides as needed the only rule is that the 'end' point should be close to the 'start' point.
Second place an always active entity inside the zone close to one of the waypoints and attach the script zone.lua. Give the entity the name of the zone.
Simple isn't it.
So what does it do?
The script provides a bunch of Lua functions:
PointIsInZone(x, z, zone) -- returns true if the specified point is inside the specified zone (note that zone is the name of the zone)
PlayerIsInZone(zone) -- returns true is the player is currently in the specified zone
ZonesPlayerIn() -- returns a list of all the zones the player is currently in (note zones can be nested so player can be in more than one)
MonitorZoneOn(zone) -- turns on monitoring of specified zone, once monitored the following two commands can be used:
PlayerEnteredZone(zone) -- returns true if the player has entered the specified zone since the last call to this function
PlayerExitedZone(zone) -- returns true if the player has exited the specified zone since the last call to this function
MonitorZoneOff(zone) -- turns off monitoring for specified zone
WptInZoneDefinition(x, y) -- a bit specialised, this one returns true if the specified waypoint position is used within a zone specification.
(the reason for this function is to allow waypoint following code to be able to ignore zones)
So how can this be used, take a look at the zone_test.lua script for some clues *Added correct script now *
Been there, done that, got all the T-Shirts!