Trigger API Reference DCEI Functions Region0 - funovus/editor-wiki GitHub Wiki
Table of Contents
- [Trigger API Reference\DCEI Functions\Region](#trigger-api-referencedcei-functionsregion)
* [Region CreateRegion(float x, float z, float w, float h)](#region-createregionfloat-x-float-z-float-w-float-h)
* [void RemoveRegion(Region region)](#void-removeregionregion-region)
* [void RemoveRegionSync(Region region)](#void-removeregionsyncregion-region)
* [Region FindRegion(string name)](#region-findregionstring-name)
* [bool RegionExists(string name)](#bool-regionexistsstring-name)
* [string GetRegionName(Region region)](#string-getregionnameregion-region)
* [Float2 GetRandomPointInRegion(Region region)](#float2-getrandompointinregionregion-region)
* [Float2 GetCenterOfRegion(Region region)](#float2-getcenterofregionregion-region)
* [Float2 GetSizeOfRegion(Region region)](#float2-getsizeofregionregion-region)
* [bool CheckPointInRegion(Region region, float x, float z)](#bool-checkpointinregionregion-region-float-x-float-z)
* [object GetUnitsInRegion(Region region)](#object-getunitsinregionregion-region)
* [void HideRegion(Region region)](#void-hideregionregion-region)
* [void RevealRegion(Region region)](#void-revealregionregion-region)
* [void MoveRegion(Region region, float x, float z)](#void-moveregionregion-region-float-x-float-z)
|
Trigger API Reference\DCEI Functions\Region {Trigger-API-ReferenceDCEI-FunctionsRegion}
Region CreateRegion(float x, float z, float w, float h) {Region-CreateRegionfloat-x-float-z-float-w-float-h}
Region CreateRegion(float x, float z, float w, float h)
-
float
x
the x coordinate of the new region. -
float
z
the z coordinate of the new region. -
float
w
the width of the new region. -
float
h
the height of the new region.
local region = DCEI.CreateRegion(16, 16, 4, 4)
void RemoveRegion(Region region)
function OnRegionLeave()
local r = DCEI.TriggeringRegion
DCEI.RemoveRegion(r)
end
DCEI.TriggerAddUnitEnterRegionEvent(DCEI.UnitAny, region, OnRegionLeave)
void RemoveRegionSync(Region region)
function OnRegionLeave()
local r = DCEI.TriggeringRegion
DCEI.RemoveRegionSync(r)
end
DCEI.TriggerAddUnitEnterRegionEvent(DCEI.UnitAny, region, OnRegionLeave)
Region FindRegion(string name)
Returns a region by name. Currently only works for regions pre-placed in the terrain editor.
local region = DCEI.FindRegion("region_a")
bool RegionExists(string name)
Returns true if the region exists. Currently only works for regions pre-placed in the terrain editor.
function OnRegionEnter()
SCORE = SCORE + 1
end
local region = DCEI.FindRegion("region_a")
if DCEI.RegionExists(region) then
DCEI.TriggerAddUnitEnterRegionEvent(DCEI.UnitAny, region, OnRegionEnter)
string GetRegionName(Region region)
Returns the name of a region. Currently only works for regions pre-placed in the terrain editor.
function OnRegionEnter()
local u = DCEI.TriggeringUnit
local r = DCEI.TriggeringRegion
local region_name = DCEI.RegionName(r)
if region_name = "goal_region" then
SCORE = SCORE + 1
end
end
DCEI.TriggerAddUnitEnterRegionEvent(DCEI.UnitAny, DCEI.RegionAny, OnRegionEnter)
Float2 GetRandomPointInRegion(Region region)
Returns the coordinates of a random point in the region.
local region = DCEI.CreateRegion(16, 16, 4, 4)
local random_point = DCEI.GetRandomPointInRegion(region)
Float2 GetCenterOfRegion(Region region)
Returns the coordinates of the center point of the region.
local region = DCEI.CreateRegion(16, 16, 4, 4)
local center_point = DCEI.GetCenterOfRegion(region)
Float2 GetSizeOfRegion(Region region)
Returns the X and Y dimensions of the region.
local region = DCEI.CreateRegion(16, 16, 4, 4)
local region_size = DCEI.GetSizeOfRegion(region)
bool CheckPointInRegion(Region region, float x, float z) {bool-CheckPointInRegionRegion-region-float-x-float-z}
bool CheckPointInRegion(Region region, float x, float z)
Returns true if coordinates are within the region.
-
Region
region
the region to find the dimensions of. -
float
x
the x coordinate of the point. -
float
z
the z coordinate of the point.
local SCORE = 0
local region = DCEI.CreateRegion(16, 16, 4, 4)
if DCEI.CheckPointInRegion(region, 14, 18) then
SCORE = SCORE + 1
end
object GetUnitsInRegion(Region region)
Returns a table of the units within the region.
local region = DCEI.CreateRegion(16, 16, 4, 4)
local units_in_region = DCEI.GetUnitsInRegion(region)
void HideRegion(Region region)
Obscures the region on the map from the player.
local region = DCEI.CreateRegion(16, 16, 4, 4)
DCEI.HideRegion(region)
void RevealRegion(Region region)
Reveals a previously hidden region on the map to the player (clears fog of war).
local region = DCEI.CreateRegion(16, 16, 4, 4)
DCEI.HideRegion(region)
DCEI.RevealRegion(region)
void MoveRegion(Region region, float x, float z)
Moves the center of the region to the specified coordinates.
-
Region
region
the region to move. -
float
x
the x coordinate to move the region to. -
float
z
the z coordinate to move the region to.
local region = DCEI.CreateRegion(16, 16, 4, 4)
DCEI.MoveRegion(region, 10, 10)