UDBScript: Exported the classes Linedef, Sector, Sidedef, Thing, and Vertex, so that they can be used with instanceof

UDBScript: Map class: the getSidedefsFromSelectedLinedefs() method now correctly only returns the Sidedefs of selected Linedefs in visual mode (and not also the highlighted one)
UDBScript: Map class: added a new getSidedefsFromSelectedOrHighlightedLinedefs() method as the equivalent to the other getSelectedOrHighlighted*() methods
UDBScript: Sector class: added new floorSelected, ceilingSelected, floorHighlighted, and ceilingHighlighted properties. Those are mostly useful in visual mode, since they always return true when the Sector is selected or highlighted in the classic modes. The properties are read-only
UDBScript: Sidedef class: added new upperSelected, middleSelected, lowerSelected, upperHighlighted, middleHighlighted, and lowerHighlighted properties. Those are mostly useful in visual mode, since they always return true when the parent Linedef is selected or highlighted in the classic modes. The properties are read-only
UDBScript: added new example to apply textures for floor/ceiling and upper/middle/lower texture for selected map elements
UDBScript: updated documentation
This commit is contained in:
biwa 2021-12-25 14:43:56 +01:00
parent ca7b9e8b7e
commit 634225b77b
26 changed files with 1066 additions and 6 deletions

View file

@ -0,0 +1,41 @@
`#name Apply textures to selected surfaces`;
`#description Applies LAVA1 to the selected floors/ceilings, and FIREBLU1 to the selected upper/middle/lower sidedefs. Mostly useful in visual mode`;
`#version 3`;
// Get all selected or highlighted sectors and sidedefs
let elements = Map.getSelectedOrHighlightedSectors().concat(Map.getSidedefsFromSelectedOrHighlightedLinedefs());
// Since the array might contain both selected sectors and highlighted sidedefs (or vice versa)
// we have to filter the array, so that we really only work on the correct map elements, i.e.
// either the single highlighted one, or all selected ones
elements.filter(e => {
if( elements.length == 1 ||
(e instanceof Sector && (e.floorSelected || e.ceilingSelected)) ||
(e instanceof Sidedef && (e.upperSelected || e.middleSelected || e.lowerSelected))
) return true;
return false;
}).forEach(e => {
// Check for each sector and sidedef which part is selected/highlighted and
// apply the textures accordingly
if(e instanceof Sector)
{
if(e.floorSelected || e.floorHighlighted)
e.floorTexture = 'LAVA1';
if(e.ceilingSelected || e.ceilingHighlighted)
e.ceilingTexture = 'LAVA1';
}
else if(e instanceof Sidedef)
{
if(e.lowerSelected || e.lowerHighlighted)
e.lowerTexture = 'FIREBLU1';
if(e.middleSelected || e.middleHighlighted)
e.middleTexture = 'FIREBLU1';
if(e.upperSelected || e.upperHighlighted)
e.upperTexture = 'FIREBLU1';
}
});

View file

@ -2248,6 +2248,25 @@ namespace CodeImp.DoomBuilder.BuilderModes
return sectors;
}
/// <summary>
/// Determines if the floor and/or ceiling of a sector is selected.
/// </summary>
/// <param name="sector">The sector to check</param>
/// <param name="floor">If floor is selected or not</param>
/// <param name="ceiling">If ceiling is selected or not</param>
public void GetSelectedSurfaceTypesBySector(Sector sector, out bool floor, out bool ceiling)
{
floor = ceiling = false;
foreach(IVisualEventReceiver i in selectedobjects)
{
if (i is VisualFloor && ((VisualFloor)i).Level.sector == sector)
floor = true;
else if (i is VisualCeiling && ((VisualCeiling)i).Level.sector == sector)
ceiling = true;
}
}
// This returns all selected linedefs, no doubles
public List<Linedef> GetSelectedLinedefs()
{
@ -2277,6 +2296,28 @@ namespace CodeImp.DoomBuilder.BuilderModes
return linedefs;
}
/// <summary>
/// Determines if the upper/middle/lower parts of a sidedef are selected.
/// </summary>
/// <param name="sidedef">The sidedef tzo check</param>
/// <param name="upper">If the upper part is selected</param>
/// <param name="middle">If the middle part is selected</param>
/// <param name="lower">If the lower part is selected</param>
public void GetSelectedSurfaceTypesBySidedef(Sidedef sidedef, out bool upper, out bool middle, out bool lower)
{
upper = middle = lower = false;
foreach(IVisualEventReceiver i in selectedobjects)
{
if (i is VisualUpper && ((VisualUpper)i).Sidedef == sidedef)
upper = true;
else if ((i is VisualMiddleSingle || i is VisualMiddleDouble || i is VisualMiddleBack) && ((BaseVisualGeometrySidedef)i).Sidedef == sidedef)
middle = true;
else if (i is VisualLower && ((VisualLower)i).Sidedef == sidedef)
lower = true;
}
}
// This returns all selected sidedefs, no doubles
public List<Sidedef> GetSelectedSidedefs()
{
@ -2293,11 +2334,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Add highlight?
/*
if((selectedobjects.Count == 0) && (target.picked is BaseVisualGeometrySidedef))
{
Sidedef sd = ((BaseVisualGeometrySidedef)target.picked).Sidedef;
if(!added.Contains(sd)) sidedefs.Add(sd);
}
*/
return sidedefs;
}

View file

@ -924,9 +924,10 @@ namespace CodeImp.DoomBuilder.UDBScript.Wrapper
/// <summary>
/// Gets all `Sidedef`s from the selected `Linedef`s.
/// In classic modes this will return both sidedefs of 2-sided lines, in visual mode it will only return the actually selected `Sidedef`.
/// </summary>
/// <param name="selected">`true` to get all `Sidedef`s of all selected `Linedef`s, `false` to get all `Sidedef`s of all unselected `Linedef`s</param>
/// <returns></returns>
/// <returns>`Array` of `Sidedef`</returns>
public SidedefWrapper[] getSidedefsFromSelectedLinedefs(bool selected = true)
{
List<SidedefWrapper> sidedefs = new List<SidedefWrapper>();
@ -948,6 +949,32 @@ namespace CodeImp.DoomBuilder.UDBScript.Wrapper
return sidedefs.ToArray();
}
/// <summary>
/// Gets the `Sidedef`s of the currently selected `Linedef`s *or*, if no `Linede`f`s are selected, the `Sidedef`s of the currently highlighted `Linedef`.
/// In classic modes this will return both sidedefs of 2-sided lines, in visual mode it will only return the actually selected `Sidedef`.
/// </summary>
/// <returns>`Array` of `Sidedef`s</returns>
/// <version>3</version>
public SidedefWrapper[] getSidedefsFromSelectedOrHighlightedLinedefs()
{
List<SidedefWrapper> sidedefs = new List<SidedefWrapper>(getSidedefsFromSelectedLinedefs(true));
if(sidedefs.Count > 0)
return sidedefs.ToArray();
// Nothing selected, so let's see if anything is highlighted
LinedefWrapper highlight = getHighlightedLinedef();
if (highlight != null)
{
if (highlight.front != null)
sidedefs.Add(highlight.front);
if (highlight.back != null)
sidedefs.Add(highlight.back);
}
return sidedefs.ToArray();
}
/// <summary>
/// Clears all selected map elements.
/// </summary>

View file

@ -27,8 +27,11 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Dynamic;
using CodeImp.DoomBuilder.BuilderModes;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.VisualModes;
#endregion
@ -199,6 +202,122 @@ namespace CodeImp.DoomBuilder.UDBScript.Wrapper
}
}
/// <summary>
/// If the `Sector`'s floor is selected or not. Will always return `true` in classic modes if the `Sector` is selected. Read-only.
/// </summary>
/// <version>3</version>
public bool floorSelected
{
get
{
if (sector.IsDisposed)
throw BuilderPlug.Me.ScriptRunner.CreateRuntimeException("Sector is disposed, the floorSelected property can not be accessed.");
if (General.Editing.Mode is BaseVisualMode)
{
bool f, c;
((BaseVisualMode)General.Editing.Mode).GetSelectedSurfaceTypesBySector(sector, out f, out c);
return f;
}
else
{
return sector.Selected;
}
}
}
/// <summary>
/// If the `Sector`'s floor is highlighted or not. Will always return `true` in classic modes if the `Sector` is highlighted. Read-only.
/// </summary>
/// <version>3</version>
public bool floorHighlighted
{
get
{
if (sector.IsDisposed)
throw BuilderPlug.Me.ScriptRunner.CreateRuntimeException("Sector is disposed, the floorHighlighted property can not be accessed.");
if (General.Editing.Mode is BaseVisualMode)
{
VisualGeometry vs = (VisualGeometry)((BaseVisualMode)General.Editing.Mode).Highlighted;
if (vs == null)
return false;
return (vs.Sector.Sector == sector && vs.GeometryType == VisualGeometryType.FLOOR);
}
else
{
Sector s = ((ClassicMode)General.Editing.Mode).HighlightedObject as Sector;
if(s == null)
return false;
return s == sector;
}
}
}
/// <summary>
/// If the `Sector`'s ceiling is selected or not. Will always return `true` in classic modes if the `Sector` is selected. Read-only.
/// </summary>
/// <version>3</version>
public bool ceilingSelected
{
get
{
if (sector.IsDisposed)
throw BuilderPlug.Me.ScriptRunner.CreateRuntimeException("Sector is disposed, the ceilingSelected property can not be accessed.");
if (General.Editing.Mode is BaseVisualMode)
{
bool f, c;
((BaseVisualMode)General.Editing.Mode).GetSelectedSurfaceTypesBySector(sector, out f, out c);
return c;
}
else
{
return sector.Selected;
}
}
}
/// <summary>
/// If the `Sector`'s ceiling is highlighted or not. Will always return `true` in classic modes if the `Sector` is highlighted. Read-only.
/// </summary>
/// <version>3</version>
public bool ceilingHighlighted
{
get
{
if (sector.IsDisposed)
throw BuilderPlug.Me.ScriptRunner.CreateRuntimeException("Sector is disposed, the ceilingHighlighted property can not be accessed.");
if (General.Editing.Mode is BaseVisualMode)
{
VisualGeometry vs = (VisualGeometry)((BaseVisualMode)General.Editing.Mode).Highlighted;
if (vs == null)
return false;
return (vs.Sector.Sector == sector && vs.GeometryType == VisualGeometryType.CEILING);
}
else
{
Sector s = ((ClassicMode)General.Editing.Mode).HighlightedObject as Sector;
if (s == null)
return false;
return s == sector;
}
}
}
/// <summary>
/// If the `Sector` is marked or not. It is used to mark map elements that were created or changed (for example after drawing new geometry).
/// </summary>

View file

@ -27,8 +27,11 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Dynamic;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.BuilderModes;
using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.VisualModes;
#endregion
@ -321,6 +324,180 @@ namespace CodeImp.DoomBuilder.UDBScript.Wrapper
}
}
/// <summary>
/// If the `Sidedef`'s upper part is selected or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
/// </summary>
/// <version>3</version>
public bool upperSelected
{
get
{
if (sidedef.IsDisposed)
throw BuilderPlug.Me.ScriptRunner.CreateRuntimeException("Sidedef is disposed, the upperSelected property can not be accessed.");
if(General.Editing.Mode is BaseVisualMode)
{
bool u, m, l;
((BaseVisualMode)General.Editing.Mode).GetSelectedSurfaceTypesBySidedef(sidedef, out u, out m, out l);
return u;
}
else
{
return sidedef.Line.Selected;
}
}
}
/// <summary>
/// If the `Sidedef`'s upper part is highlighted or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
/// </summary>
/// <version>3</version>
public bool upperHighlighted
{
get
{
if (sidedef.IsDisposed)
throw BuilderPlug.Me.ScriptRunner.CreateRuntimeException("Sidedef is disposed, the upperHighlighted property can not be accessed.");
if (General.Editing.Mode is BaseVisualMode)
{
VisualGeometry vs = (VisualGeometry)((BaseVisualMode)General.Editing.Mode).Highlighted;
if (vs == null)
return false;
return (vs.Sidedef == sidedef && vs.GeometryType == VisualGeometryType.WALL_UPPER);
}
else
{
Linedef ld = ((ClassicMode)General.Editing.Mode).HighlightedObject as Linedef;
if (ld == null)
return false;
return (ld.Front == sidedef || (ld.Back != null && ld.Back == sidedef));
}
}
}
/// <summary>
/// If the `Sidedef`'s middle part is selected or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
/// </summary>
/// <version>3</version>
public bool middleSelected
{
get
{
if (sidedef.IsDisposed)
throw BuilderPlug.Me.ScriptRunner.CreateRuntimeException("Sidedef is disposed, the middleSelected property can not be accessed.");
if (General.Editing.Mode is BaseVisualMode)
{
bool u, m, l;
((BaseVisualMode)General.Editing.Mode).GetSelectedSurfaceTypesBySidedef(sidedef, out u, out m, out l);
return m;
}
else
{
return sidedef.Line.Selected;
}
}
}
/// <summary>
/// If the `Sidedef`'s middle part is highlighted or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
/// </summary>
/// <version>3</version>
public bool middleHighlighted
{
get
{
if (sidedef.IsDisposed)
throw BuilderPlug.Me.ScriptRunner.CreateRuntimeException("Sidedef is disposed, the middleHighlighted property can not be accessed.");
if (General.Editing.Mode is BaseVisualMode)
{
VisualGeometry vs = (VisualGeometry)((BaseVisualMode)General.Editing.Mode).Highlighted;
if (vs == null)
return false;
return (vs.Sidedef == sidedef && (vs.GeometryType == VisualGeometryType.WALL_MIDDLE || vs.GeometryType == VisualGeometryType.WALL_MIDDLE_3D));
}
else
{
Linedef ld = ((ClassicMode)General.Editing.Mode).HighlightedObject as Linedef;
if (ld == null)
return false;
return (ld.Front == sidedef || (ld.Back != null && ld.Back == sidedef));
}
}
}
/// <summary>
/// If the `Sidedef`'s lower part is selected or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
/// </summary>
/// <version>3</version>
public bool lowerSelected
{
get
{
if (sidedef.IsDisposed)
throw BuilderPlug.Me.ScriptRunner.CreateRuntimeException("Sidedef is disposed, the lowerSelected property can not be accessed.");
if (General.Editing.Mode is BaseVisualMode)
{
bool u, m, l;
((BaseVisualMode)General.Editing.Mode).GetSelectedSurfaceTypesBySidedef(sidedef, out u, out m, out l);
return l;
}
else
{
return sidedef.Line.Selected;
}
}
}
/// <summary>
/// If the `Sidedef`'s lower part is highlighted or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
/// </summary>
/// <version>3</version>
public bool lowerHighlighted
{
get
{
if (sidedef.IsDisposed)
throw BuilderPlug.Me.ScriptRunner.CreateRuntimeException("Sidedef is disposed, the lowerHighlighted property can not be accessed.");
if (General.Editing.Mode is BaseVisualMode)
{
VisualGeometry vs = (VisualGeometry)((BaseVisualMode)General.Editing.Mode).Highlighted;
if (vs == null)
return false;
return (vs.Sidedef == sidedef && vs.GeometryType == VisualGeometryType.WALL_LOWER);
}
else
{
Linedef ld = ((ClassicMode)General.Editing.Mode).HighlightedObject as Linedef;
if (ld == null)
return false;
return (ld.Front == sidedef || (ld.Back != null && ld.Back == sidedef));
}
}
}
#endregion
#region ================== Constructors

View file

@ -70,7 +70,7 @@ namespace CodeImp.DoomBuilder.UDBScript
#region ================== Constants
private static readonly string SCRIPT_FOLDER = "udbscript";
public static readonly uint UDB_SCRIPT_VERSION = 2;
public static readonly uint UDB_SCRIPT_VERSION = 3;
#endregion

View file

@ -241,6 +241,14 @@ namespace CodeImp.DoomBuilder.UDBScript
engine.SetValue("UniValue", TypeReference.CreateTypeReference(engine, typeof(UniValue)));
engine.SetValue("Data", TypeReference.CreateTypeReference(engine, typeof(DataWrapper)));
// These can not be directly instanciated and don't have static method, but it's required to
// for example use "instanceof" in scripts
engine.SetValue("Linedef", TypeReference.CreateTypeReference(engine, typeof(LinedefWrapper)));
engine.SetValue("Sector", TypeReference.CreateTypeReference(engine, typeof(SectorWrapper)));
engine.SetValue("Sidedef", TypeReference.CreateTypeReference(engine, typeof(SidedefWrapper)));
engine.SetValue("Thing", TypeReference.CreateTypeReference(engine, typeof(ThingWrapper)));
engine.SetValue("Vertex", TypeReference.CreateTypeReference(engine, typeof(VertexWrapper)));
#if DEBUG
engine.SetValue("log", new Action<object>(Console.WriteLine));
#endif

View file

@ -80,7 +80,11 @@ for topic in topics:
if texttype == 'global':
texts['global'] = f'{summary}\n'
else:
commenttext += '\n---\n'
if 'version' in d:
commenttext += f'<span style="float:right;font-weight:normal;font-size:66%">Version: {d["version"]}</span>\n'
commenttext += f'### {signature}\n'
commenttext += f'{summary}\n'
if 'param' in d:
commenttext += '#### Parameters\n'

View file

@ -1,24 +1,32 @@
# Angle2D
## Static methods
---
### degToRad(deg)
Converts degrees to radians.
#### Parameters
* deg: Angle in degrees
#### Return value
Angle in radians
---
### doomToReal(doomangle)
Converts a Doom angle (where 0° is east) to a real world angle (where 0° is north).
#### Parameters
* doomangle: Doom angle in degrees
#### Return value
Doom angle in degrees
---
### doomToRealRad(doomangle)
Converts a Doom angle (where 0° is east) to a real world angle (where 0° is north) in radians.
#### Parameters
* doomangle: Doom angle in degrees
#### Return value
Doom angle in radians
---
### getAngle(p1, p2, p3)
Returns the angle between three positions.
#### Parameters
@ -27,6 +35,8 @@ Returns the angle between three positions.
* p3: Third position
#### Return value
Angle in degrees
---
### getAngleRad(p1, p2, p3)
Returns the angle between three positions in radians.
#### Parameters
@ -35,30 +45,40 @@ Returns the angle between three positions in radians.
* p3: Third position
#### Return value
Angle in radians
---
### normalized(angle)
Normalizes an angle in degrees so that it is bigger or equal to 0° and smaller than 360°.
#### Parameters
* angle: Angle in degrees
#### Return value
Normalized angle in degrees
---
### normalizedRad(angle)
Normalizes an angle in radians so that it is bigger or equal to 0 and smaller than 2 Pi.
#### Parameters
* angle: Angle in radians
#### Return value
Normalized angle in radians
---
### radToDeg(rad)
Converts radians to degrees.
#### Parameters
* rad: Angle in radians
#### Return value
Angle in degrees
---
### realToDoom(realangle)
Converts a real world angle (where 0° is north) to a Doom angle (where 0° is east).
#### Parameters
* realangle: Real world angle in degrees
#### Return value
Doom angle in degrees
---
### realToDoomRad(realangle)
Converts a real world angle (where 0° is north) to a Doom angle (where 0° is east) in radians.
#### Parameters

View file

@ -1,32 +1,44 @@
# Data
## Static methods
---
### flatExists(name)
Checks if a flat with the given name exists.
#### Parameters
* name: Flat name to check
#### Return value
`true` if the flat exists, `false` if it doesn't
---
### getFlatInfo(name)
Returns an `ImageInfo` object for the given flat name.
#### Parameters
* name: Flat name to get the info for
#### Return value
`ImageInfo` object containing information about the flat
---
### getFlatNames()
Returns an `Array`of all flat names.
#### Return value
`Array` of all flat names
---
### getTextureInfo(name)
Returns an `ImageInfo` object for the given texture name.
#### Parameters
* name: Texture name to get the info for
#### Return value
`ImageInfo` object containing information about the texture
---
### getTextureNames()
Returns an `Array` of all texture names.
#### Return value
`Array` of all texture names
---
### textureExists(name)
Checks if a texture with the given name exists.
#### Parameters

View file

@ -1,7 +1,11 @@
# GameConfiguration
## Properties
---
### engineName
Engine name, like `doom`, `boom`, `zdoom` etc. Used for the namespace in UDMF maps. Read-only.
---
### hasLocalSidedefTextureOffsets
If the game configuration supports local sidedef texture offsets (distinct offsets for upper, middle, and lower sidedef parts).

View file

@ -1,13 +1,23 @@
# ImageInfo
## Properties
---
### height
Height of the image.
---
### isFlat
If the image is a flat (`true`) or not (`false`).
---
### name
Name of the image.
---
### scale
Scale of the image as `Vector2D`.
---
### width
Width of the image.

View file

@ -1,6 +1,8 @@
# Line2D
## Constructors
---
### Line2D(v1, v2)
Creates a new `Line2D` from two points.
@ -12,6 +14,8 @@ let line2 = new Line2D([ 32, 64 ], [ 96, 128 ]);
* v1: First point
* v2: Second point
## Static methods
---
### areIntersecting(a1, a2, b1, b2, bounded=true)
Checks if two lines defined by their start and end points intersect. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used.
#### Parameters
@ -22,6 +26,8 @@ Checks if two lines defined by their start and end points intersect. If `bounded
* bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines
#### Return value
`true` if the lines intersect, `false` if they do not
---
### areIntersecting(line1, line2, bounded=true)
Checks if two lines intersect. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used.
#### Parameters
@ -30,6 +36,8 @@ Checks if two lines intersect. If `bounded` is set to `true` (default) the finit
* bounded: `true` to use finite length of lines, `false` to use infinite length of lines
#### Return value
`true` if the lines intersect, `false` if they do not
---
### getCoordinatesAt(v1, v2, u)
Returns the coordinate on a line defined by its start and end points as `Vector2D`.
#### Parameters
@ -38,6 +46,8 @@ Returns the coordinate on a line defined by its start and end points as `Vector2
* u: Offset coordinate relative to the first point of the line
#### Return value
Point on the line as `Vector2D`
---
### getDistanceToLine(v1, v2, p, bounded=true)
Returns the shortest distance from point `p` to the line defined by its start and end points. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used.
#### Parameters
@ -47,6 +57,8 @@ Returns the shortest distance from point `p` to the line defined by its start an
* bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines
#### Return value
The shortest distance to the line
---
### getDistanceToLineSq(v1, v2, p, bounded = true)
Returns the shortest square distance from point `p` to the line defined by its start and end points. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used.
#### Parameters
@ -56,6 +68,8 @@ Returns the shortest square distance from point `p` to the line defined by its s
* bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines
#### Return value
The shortest square distance to the line
---
### getIntersectionPoint(a1, a2, b1, b2, bounded = true)
Returns the intersection point of two lines as `Vector2D`. If the lines do not intersect the `x` and `y` properties of the `Vector2D` are `NaN`. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used.
#### Parameters
@ -66,6 +80,8 @@ Returns the intersection point of two lines as `Vector2D`. If the lines do not i
* bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines
#### Return value
The intersection point as `Vector2D`
---
### getNearestOnLine(v1, v2, p)
Returns the offset coordinate on the line nearest to the given point. `0.0` being on the first point, `1.0` being on the second point, and `u = 0.5` being in the middle between the points.
#### Parameters
@ -74,6 +90,8 @@ Returns the offset coordinate on the line nearest to the given point. `0.0` bein
* p: Point to get the nearest offset coordinate from
#### Return value
The offset value relative to the first point of the line.
---
### getSideOfLine(v1, v2, p)
Returns which the of the line defined by its start and end point a given point is on.
#### Parameters
@ -83,25 +101,37 @@ Returns which the of the line defined by its start and end point a given point i
#### Return value
`< 0` if `p` is on the front (right) side, `> 0` if `p` is on the back (left) side, `== 0` if `p` in on the line
## Properties
---
### v1
`Vector2D` position of start of the line.
---
### v2
`Vector2D` position of end of the line.
## Methods
---
### getAngle()
Return the angle of the `Line2D` in degrees.
#### Return value
Angle of the `Line2D` in degrees
---
### getAngleRad()
Returns the angle of the `Line2D` in radians.
#### Return value
Angle of `Line2D` in radians
---
### getCoordinatesAt(u)
Returns the coordinates on the line, where `u` is the position between the first and second point, `u = 0.0` being on the first point, `u = 1.0` being on the second point, and `u = 0.5` being in the middle between the points.
#### Parameters
* u: Position on the line, between 0.0 and 1.0
#### Return value
Position on the line as `Vector2D`
---
### getIntersectionPoint(a1, a2, bounded = true)
Returns the intersection point of of the given line defined by its start and end points with this line as `Vector2D`. If the lines do not intersect the `x` and `y` properties of the `Vector2D` are `NaN`. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used.
#### Parameters
@ -110,6 +140,8 @@ Returns the intersection point of of the given line defined by its start and end
* bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines
#### Return value
The intersection point as `Vector2D`
---
### getIntersectionPoint(ray, bounded=true)
Returns the intersection point of of the given line with this line as `Vector2D`. If the lines do not intersect the `x` and `y` properties of the `Vector2D` are `NaN`. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used.
#### Parameters
@ -117,20 +149,28 @@ Returns the intersection point of of the given line with this line as `Vector2D`
* bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines
#### Return value
The intersection point as `Vector2D`
---
### getLength()
Returns the length of the `Line2D`.
#### Return value
Length of the `Line2D`
---
### getPerpendicular()
Returns the perpendicular of this line as `Vector2D`.
#### Return value
Perpendicular of this line as `Vector2D`
---
### getSideOfLine(p)
Returns which the of the line defined by its start and end point a given point is on.
#### Parameters
* p: Point to check
#### Return value
`< 0` if `p` is on the front (right) side, `> 0` if `p` is on the back (left) side, `== 0` if `p` in on the line
---
### isIntersecting(a1, a2, bounded = true)
Checks if the given line intersects this line. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used.
#### Parameters
@ -139,6 +179,8 @@ Checks if the given line intersects this line. If `bounded` is set to `true` (de
* bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines
#### Return value
`true` if the lines intersect, `false` if they do not
---
### isIntersecting(ray, bounded=true)
Checks if the given `Line2D` intersects this line. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used.
#### Parameters

View file

@ -1,20 +1,36 @@
# Linedef
## Properties
---
### action
`Linedef` action.
---
### activate
The activation flag. Hexen format only.
---
### angle
The `Linedef`'s angle in degree. Read-only.
---
### angleRad
The `Linedef`'s angle in radians. Read-only.
---
### args
`Array` of arguments of the `Linedef`. Number of arguments depends on game config (usually 5). Hexen format and UDMF only.
---
### back
The `Linedef`'s back `Sidedef`. Is `null` when there is no back.
---
### end
The linedef's end `Vertex`.
---
### fields
UDMF fields. It's an object with the fields as properties.
@ -43,6 +59,8 @@ To remove a field you have to assign `null` to it:
```js
s.fields.user_myintfield = null;
```
---
### flags
`Linedef` flags. It's an object with the flags as properties. In Doom format and Hexen format they are identified by numbers, in UDMF by their name.
Doom and Hexen:
@ -56,43 +74,75 @@ UDMF:
ld.flags['blocksound'] = true; // Set the block sound flag
ld.flags.blocksound = true; // Also works
```
---
### front
The `Linedef`'s front `Sidedef`. Is `null` when there is no front (should not happen).
---
### index
The linedef's index. Read-only.
---
### length
The `Linedef`'s length. Read-only.
---
### lengthInv
1.0 / length. Read-only.
---
### lengthSq
The `Linedef`'s squared length. Read-only.
---
### line
The `Line2D` from the `start` to the `end` `Vertex`.
---
### marked
If the `Linedef` is marked or not. It is used to mark map elements that were created or changed (for example after drawing new geometry).
---
### selected
If the `Linedef` is selected or not.
---
### start
The linedef's start `Vertex`.
---
### tag
`Linedef` tag. UDMF only.
## Methods
---
### addTag(tag)
Adds a tag to the `Linedef`. UDMF only. Supported game configurations only.
#### Parameters
* tag: Tag to add
#### Return value
`true` when the tag was added, `false` when the tag already exists
---
### applySidedFlags()
Automatically sets the blocking and two-sided flags based on the existing `Sidedef`s.
---
### clearFlags()
Clears all flags.
---
### copyPropertiesTo(other)
Copies the properties of this `Linedef` to another `Linedef`.
#### Parameters
* other: The `Linedef` to copy the properties to
---
### delete()
Deletes the `Linedef`. Note that this will result in unclosed `Sector`s unless it has the same `Sector`s on both sides.
---
### distanceTo(pos, bounded)
Gets the shortest distance from `pos` to the line.
#### Parameters
@ -100,6 +150,8 @@ Gets the shortest distance from `pos` to the line.
* bounded: `true` if only the finite length of the line should be used, `false` if the infinite length of the line should be used
#### Return value
Distance to the line
---
### distanceToSq(pos, bounded)
Gets the shortest squared distance from `pos` to the line.
#### Parameters
@ -107,26 +159,40 @@ Gets the shortest squared distance from `pos` to the line.
* bounded: `true` if only the finite length of the line should be used, `false` if the infinite length of the line should be used
#### Return value
Squared distance to the line
---
### flip()
Flips the `Linedef`'s vertex attachments and `Sidedef`s. This is a shortcut to using both `flipVertices()` and `flipSidedefs()`.
---
### flipSidedefs()
Flips the `Linedef`'s `Sidedef`s.
---
### flipVertices()
Flips the `Linedef`'s vertex attachments.
---
### getCenterPoint()
Gets a `Vector2D` that's in the center of the `Linedef`.
#### Return value
`Vector2D` in the center of the `Linedef`
---
### getSidePoint(front)
Gets a `Vector2D` for testing on one side. The `Vector2D` is on the front when `true` is passed, otherwise on the back.
#### Parameters
* front: `true` for front, `false` for back
#### Return value
`Vector2D` that's either on the front of back of the Linedef
---
### getTags()
Returns an `Array` of the `Linedef`'s tags. UDMF only. Supported game configurations only.
#### Return value
`Array` of tags
---
### nearestOnLine(pos)
Get a `Vector2D` that's *on* the line, closest to `pos`. `pos` can either be a `Vector2D`, or an array of numbers.
@ -138,12 +204,16 @@ var v2 = ld.nearestOnLine([ 32, 64 ]);
* pos: Point to check against
#### Return value
`Vector2D` that's on the linedef
---
### removeTag(tag)
Removes a tag from the `Linedef`. UDMF only. Supported game configurations only.
#### Parameters
* tag: Tag to remove
#### Return value
`true` when the tag was removed successfully, `false` when the tag did not exist
---
### safeDistanceTo(pos, bounded)
Gets the shortest "safe" distance from `pos` to the line. If `bounded` is `true` that means that the not the whole line's length will be used, but `lengthInv` less at the start and end.
#### Parameters
@ -151,6 +221,8 @@ Gets the shortest "safe" distance from `pos` to the line. If `bounded` is `true`
* bounded: `true` if only the finite length of the line should be used, `false` if the infinite length of the line should be used
#### Return value
Distance to the line
---
### safeDistanceToSq(pos, bounded)
Gets the shortest "safe" squared distance from `pos` to the line. If `bounded` is `true` that means that the not the whole line's length will be used, but `lengthInv` less at the start and end.
#### Parameters
@ -158,12 +230,16 @@ Gets the shortest "safe" squared distance from `pos` to the line. If `bounded` i
* bounded: `true` if only the finite length of the line should be used, `false` if the infinite length of the line should be used
#### Return value
Squared distance to the line
---
### sideOfLine(pos)
Tests which side of the `Linedef` `pos` is on. Returns < 0 for front (right) side, > for back (left) side, and 0 if `pos` is on the line.
#### Parameters
* pos: Point to check against
#### Return value
< 0 for front (right) side, > for back (left) side, and 0 if `pos` is on the line
---
### split(pos)
Splits the `Linedef` at the given position. This can either be a `Vector2D`, an array of numbers, or an existing `Vertex`. The result will be two lines, from the start `Vertex` of the `Linedef` to `pos`, and from `pos` to the end `Vertex` of the `Linedef`.
#### Parameters

View file

@ -1,49 +1,81 @@
# Map
## Properties
---
### camera
`VisualCamera` object with information about the position of the camera in visual mode. Read-only.
---
### isDoom
`true` if the map is in Doom format, `false` if it isn't. Read-only.
---
### isHexen
`true` if the map is in Hexen format, `false` if it isn't. Read-only.
---
### isUDMF
`true` if the map is in UDMF, `false` if it isn't. Read-only.
---
### mousePosition
The map coordinates of the mouse position as a `Vector2D`. Read-only.
## Methods
---
### clearAllMarks(mark=false)
Sets the `marked` property of all map elements. Can be passed `true` to mark all map elements.
#### Parameters
* mark: `false` to set the `marked` property to `false` (default), `true` to set the `marked` property to `true`
---
### clearAllSelected()
Clears all selected map elements.
---
### clearMarkeLinedefs(mark=false)
Sets the `marked` property of all `Linedef`s. Can be passed `true` to mark all `Linedef`s.
#### Parameters
* mark: `false` to set the `marked` property to `false` (default), `true` to set the `marked` property to `true`
---
### clearMarkeSectors(mark = false)
Sets the `marked` property of all `Sector`s. Can be passed `true` to mark all `Sector`s.
#### Parameters
* mark: `false` to set the `marked` property to `false` (default), `true` to set the `marked` property to `true`
---
### clearMarkeSidedefs(mark = false)
Sets the `marked` property of all `Sidedef`s. Can be passed `true` to mark all `Sidedef`s.
#### Parameters
* mark: `false` to set the `marked` property to `false` (default), `true` to set the `marked` property to `true`
---
### clearMarkedThings(mark=false)
Sets the `marked` property of all `Thing`s. Can be passed `true` to mark all `Thing`s.
#### Parameters
* mark: `false` to set the `marked` property to `false` (default), `true` to set the `marked` property to `true`
---
### clearMarkedVertices(mark=false)
Sets the `marked` property of all vertices. Can be passed `true` to mark all vertices.
#### Parameters
* mark: `false` to set the `marked` property to `false` (default), `true` to set the `marked` property to `true`
---
### clearSelectedSectors()
Clears all selected `Sector`s.
---
### clearSelectedThings()
Clears all selected `Thing`s.
---
### clearSelectedVertices()
Clears all selected vertices.
---
### createThing(pos, type=0)
Creates a new `Thing` at the given position. The position can be a `Vector2D`, `Vector3D`, or an `Array` of two numbers or three numbers (note that the z position only works for game configurations that support vertical pos. A thing type can be supplied optionally.
@ -58,6 +90,8 @@ var t4 = Map.createThing([ 32, 64 ], 3001); // Create an Imp
* type: Thing type (optional)
#### Return value
The new `Thing`
---
### createVertex(pos)
Creates a new `Vertex` at the given position. The position can be a `Vector2D` or an `Array` of two numbers.
@ -69,6 +103,8 @@ var v2 = Map.createVertex([ 32, 64 ]);
* pos: Position where the `Vertex` should be created at
#### Return value
The created `Vertex`
---
### drawLines(data)
Draws lines. Data has to be an `Array` of `Array` of numbers, `Vector2D`s, `Vector3D`s, or objects with x and y properties. Note that the first and last element have to be at the same positions to make a complete drawing.
@ -93,166 +129,251 @@ Map.drawLines([
* data: `Array` of positions
#### Return value
`true` if drawing was successful, `false` if it wasn't
---
### getHighlightedLinedef()
Get the currently highlighted `Linedef`.
#### Return value
The currently highlighted `Linedef` or `null` if no `Linedef` is highlighted
---
### getHighlightedSector()
Get the currently highlighted `Sector`.
#### Return value
The currently highlighted `Sector` or `null` if no `Sector` is highlighted
---
### getHighlightedThing()
Get the currently highlighted `Thing`.
#### Return value
The currently highlighted `Thing` or `null` if no `Thing` is highlighted
---
### getHighlightedVertex()
Get the currently highlighted `Vertex`.
#### Return value
The currently highlighted `Vertex` or `null` if no `Vertex` is highlighted
---
### getLinedefs()
Returns an `Array` of all `Linedef`s in the map.
#### Return value
`Array` of `Linedef`s
---
### getMarkedLinedefs(mark = true)
Gets all marked (default) or unmarked `Linedef`s.
#### Parameters
* mark: `true` to get all marked `Linedef`s (default), `false` to get all unmarked `Linedef`s
#### Return value
*missing*
---
### getMarkedSectors(mark = true)
Gets all marked (default) or unmarked `Sector`s.
#### Parameters
* mark: `true` to get all marked `Sector`s (default), `false` to get all unmarked `Sector`s
#### Return value
*missing*
---
### getMarkedSidedefs(mark = true)
Gets all marked (default) or unmarked `Sidedef`s.
#### Parameters
* mark: `true` to get all marked `Sidedef`s (default), `false` to get all unmarked `Sidedef`s
#### Return value
*missing*
---
### getMarkedThings(mark = true)
Gets all marked (default) or unmarked `Thing`s.
#### Parameters
* mark: `true` to get all marked `Thing`s (default), `false` to get all unmarked `Thing`s
#### Return value
*missing*
---
### getMarkedVertices(mark=true)
Gets all marked (default) or unmarked vertices.
#### Parameters
* mark: `true` to get all marked vertices (default), `false` to get all unmarked vertices
#### Return value
*missing*
---
### getMultipleNewTags(count)
Gets multiple new tags.
#### Parameters
* count: Number of tags to get
#### Return value
`Array` of the new tags
---
### getNewTag(usedtags = null)
Gets a new tag.
#### Parameters
* usedtags: `Array` of tags to skip
#### Return value
The new tag
---
### getSectors()
Returns an `Array` of all `Sector`s in the map.
#### Return value
`Array` of `Sector`s
---
### getSelectedLinedefs(selected = true)
Gets all selected (default) or unselected `Linedef`s.
#### Parameters
* selected: `true` to get all selected `Linedef`s, `false` to get all unselected ones
#### Return value
`Array` of `Linedef`s
---
### getSelectedOrHighlightedLinedefs()
Gets the currently selected `Linedef`s *or*, if no `Linede`f`s are selected, a currently highlighted `Linedef`.
#### Return value
`Array` of `Linedef`s
---
### getSelectedOrHighlightedSectors()
Gets the currently selected `Sector`s *or*, if no `Sector`s are selected, a currently highlighted `Sector`.
#### Return value
`Array` of `Sector`s
---
### getSelectedOrHighlightedThings()
Gets the currently selected `Thing`s *or*, if no `Thing`s are selected, a currently highlighted `Thing`.
#### Return value
`Array` of `Thing`s
---
### getSelectedOrHighlightedVertices()
Gets the currently selected `Vertex`s *or*, if no `Vertex`s are selected, a currently highlighted `Vertex`.
#### Return value
`Array` of `Vertex`
---
### getSelectedSectors(selected = true)
Gets all selected (default) or unselected `Sector`s.
#### Parameters
* selected: `true` to get all selected `Sector`s, `false` to get all unselected ones
#### Return value
`Array` of `Sector`s
---
### getSelectedThings(selected = true)
Gets all selected (default) or unselected `Thing`s.
#### Parameters
* selected: `true` to get all selected `Thing`s, `false` to get all unselected ones
#### Return value
`Array` of `Thing`s
---
### getSelectedVertices(selected=true)
Gets all selected (default) or unselected vertices.
#### Parameters
* selected: `true` to get all selected vertices, `false` to get all unselected ones
#### Return value
`Array` of `Vertex`
---
### getSidedefs()
Returns an `Array` of all `Sidedef`s in the map.
#### Return value
`Array` of `Sidedef`s
---
### getSidedefsFromSelectedLinedefs(selected = true)
Gets all `Sidedef`s from the selected `Linedef`s.
In classic modes this will return both sidedefs of 2-sided lines, in visual mode it will only return the actually selected `Sidedef`.
#### Parameters
* selected: `true` to get all `Sidedef`s of all selected `Linedef`s, `false` to get all `Sidedef`s of all unselected `Linedef`s
#### Return value
*missing*
`Array` of `Sidedef`
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### getSidedefsFromSelectedOrHighlightedLinedefs()
Gets the `Sidedef`s of the currently selected `Linedef`s *or*, if no `Linede`f`s are selected, the `Sidedef`s of the currently highlighted `Linedef`.
In classic modes this will return both sidedefs of 2-sided lines, in visual mode it will only return the actually selected `Sidedef`.
#### Return value
`Array` of `Sidedef`s
---
### getThings()
Returns an `Array` of all `Thing`s in the map.
#### Return value
`Array` of `Thing`s
---
### getVertices()
Returns an `Array` of all `Vertex` in the map.
#### Return value
`Array` of `Vertex`
---
### invertAllMarks()
Inverts all marks of all map elements.
---
### invertMarkedLinedefs()
Inverts the `marked` property of all `Linedef`s.
---
### invertMarkedSectors()
Inverts the `marked` property of all `Sector`s.
---
### invertMarkedSidedefs()
Inverts the `marked` property of all `Sidedef`s.
---
### invertMarkedThings()
Inverts the `marked` property of all `Thing`s.
---
### invertMarkedVertices()
Inverts the `marked` property of all vertices.
---
### joinSectors(sectors)
Joins `Sector`s, keeping lines shared by the `Sector`s. All `Sector`s will be joined with the first `Sector` in the array.
#### Parameters
* sectors: `Array` of `Sector`s
---
### markSelectedLinedefs(mark = true)
Marks (default) or unmarks all selected `Linedef`s.
#### Parameters
* mark: `true` to mark all selected `Linedef`s (default), `false` to unmark
---
### markSelectedSectors(mark = true)
Marks (default) or unmarks all selected `Sector`s.
#### Parameters
* mark: `true` to mark all selected `Sector`s (default), `false` to unmark
---
### markSelectedThings(mark = true)
Marks (default) or unmarks all selected `Thing`s.
#### Parameters
* mark: `true` to mark all selected `Thing`s (default), `false` to unmark
---
### markSelectedVertices(mark=true)
Marks (default) or unmarks all selected vertices.
#### Parameters
* mark: `true` to mark all selected vertices (default), `false` to unmark
---
### mergeSectors(sectors)
Merges `Sector`s, deleting lines shared by the `Sector`s. All `Sector`s will be merged into the first `Sector` in the array.
#### Parameters
* sectors: `Array` of `Sector`s
---
### nearestLinedef(pos, maxrange = double.NaN)
Gets the `Linedef` that's nearest to the specified position.
#### Parameters
@ -260,6 +381,8 @@ Gets the `Linedef` that's nearest to the specified position.
* maxrange: Maximum range (optional)
#### Return value
Nearest `Linedef`
---
### nearestSidedef(pos)
Gets the `Sidedef` that's nearest to the specified position.
#### Parameters
@ -267,6 +390,8 @@ Gets the `Sidedef` that's nearest to the specified position.
* maxrange: Maximum range (optional)
#### Return value
Nearest `Sidedef`
---
### nearestThing(pos, maxrange = double.NaN)
Gets the `Thing` that's nearest to the specified position.
#### Parameters
@ -274,6 +399,8 @@ Gets the `Thing` that's nearest to the specified position.
* maxrange: Maximum range (optional)
#### Return value
Nearest `Linedef`
---
### nearestVertex(pos, maxrange = double.NaN)
Gets the `Vertex` that's nearest to the specified position.
#### Parameters
@ -281,16 +408,22 @@ Gets the `Vertex` that's nearest to the specified position.
* maxrange: Maximum range (optional)
#### Return value
Nearest `Vertex`
---
### snapAllToAccuracy(usepreciseposition = true)
Snaps all vertices and things to the map format accuracy. Call this to ensure the vertices and things are at valid coordinates.
#### Parameters
* usepreciseposition: `true` if decimal places defined by the map format should be used, `false` if no decimal places should be used
---
### snappedToGrid(pos)
Returns the given point snapped to the current grid.
#### Parameters
* pos: Point that should be snapped to the grid
#### Return value
Snapped position as `Vector2D`
---
### stitchGeometry(mergemode = MergeGeometryMode.CLASSIC)
Stitches marked geometry with non-marked geometry.
#### Parameters

View file

@ -14,12 +14,18 @@ qo.query();
showMessage('You want ' + qo.options.numsides + ' sides with a length of ' + qo.options.length);
```
## Constructors
---
### QueryOptions()
Initializes a new `QueryOptions` object.
## Properties
---
### options
Object containing all the added options as properties.
## Methods
---
### addOption(name, description, type, defaultvalue)
Adds a parameter to query
#### Parameters
@ -27,6 +33,8 @@ Adds a parameter to query
* description: Textual description of the parameter
* type: UniversalType value of the parameter
* defaultvalue: Default value of the parameter
---
### addOption(name, description, type, defaultvalue, enumvalues)
Adds a parameter to query
#### Parameters
@ -34,8 +42,12 @@ Adds a parameter to query
* description: Textual description of the parameter
* type: UniversalType value of the parameter
* defaultvalue: Default value of the parameter
---
### clear()
Removes all parameters
---
### query()
Queries all parameters. Options a window where the user can enter values for the options added through `addOption()`.
#### Return value

View file

@ -1,14 +1,34 @@
# Sector
## Properties
---
### brightness
The `Sector`'s brightness.
---
### ceilingHeight
Ceiling height of the `Sector`.
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### ceilingHighlighted
If the `Sector`'s ceiling is highlighted or not. Will always return `true` in classic modes if the `Sector` is highlighted.
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### ceilingSelected
If the `Sector`'s ceiling is selected or not. Will always return `true` in classic modes if the `Sector` is selected.
---
### ceilingSlopeOffset
The ceiling's slope offset.
---
### ceilingTexture
Ceiling texture of the `Sector`.
---
### fields
UDMF fields. It's an object with the fields as properties.
@ -37,6 +57,8 @@ To remove a field you have to assign `null` to it:
```js
s.fields.user_myintfield = null;
```
---
### flags
`Sector` flags. It's an object with the flags as properties. Only available in UDMF.
@ -45,57 +67,103 @@ s.fields.user_myintfield = null;
s.flags['noattack'] = true; // Monsters in this sector don't attack
s.flags.noattack = true; // Also works
```
---
### floorHeight
Floor height of the `Sector`.
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### floorHighlighted
If the `Sector`'s floor is highlighted or not. Will always return `true` in classic modes if the `Sector` is highlighted.
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### floorSelected
If the `Sector`'s floor is selected or not. Will always return `true` in classic modes if the `Sector` is selected.
---
### floorSlopeOffset
The floor's slope offset.
---
### floorTexture
Floor texture of the `Sector`.
---
### index
The `Sector`'s index. Read-only.
---
### marked
If the `Sector` is marked or not. It is used to mark map elements that were created or changed (for example after drawing new geometry).
---
### selected
If the `Sector` is selected or not.
---
### special
The `Sector`'s special type.
---
### tag
The `Sector`'s tag.
## Methods
---
### addTag(tag)
Adds a tag to the `Sector`. UDMF only. Supported game configurations only.
#### Parameters
* tag: Tag to add
#### Return value
`true` when the tag was added, `false` when the tag already exists
---
### clearFlags()
Clears all flags.
---
### copyPropertiesTo(s)
Copies the properties from this `Sector` to another.
#### Parameters
* s: the `Sector` to copy the properties to
---
### delete()
Deletes the `Sector` and its `Sidedef`s.
---
### getCeilingSlope()
Gets the ceiling's slope vector.
#### Return value
The ceiling's slope normal as a `Vector3D`
---
### getFloorSlope()
Gets the floor's slope vector.
#### Return value
The floor's slope normal as a `Vector3D`
---
### getSidedefs()
Returns an `Array` of all `Sidedef`s of the `Sector`.
#### Return value
`Array` of the `Sector`'s `Sidedef`s
---
### getTags()
Returns an `Array` of the `Sector`'s tags. UDMF only. Supported game configurations only.
#### Return value
`Array` of tags
---
### getTriangles()
Gets an array of `Vector2D` arrays, representing the vertices of the triangulated sector. Note that for sectors with islands some triangles may not always have their points on existing vertices.
#### Return value
Array of `Vector2D` arrays
---
### intersect(p)
Checks if the given point is in this `Sector` or not. The given point can be a `Vector2D` or an `Array` of two numbers.
@ -110,20 +178,28 @@ if(s.intersect([ 32, 64 ]))
* p: Point to test
#### Return value
`true` if the point is in the `Sector`, `false` if it isn't
---
### join(other)
Joins this `Sector` with another `Sector`. Lines shared between the sectors will not be removed.
#### Parameters
* other: Sector to join with
---
### removeTag(tag)
Removes a tag from the `Sector`. UDMF only. Supported game configurations only.
#### Parameters
* tag: Tag to remove
#### Return value
`true` when the tag was removed successfully, `false` when the tag did not exist
---
### setCeilingSlope(normal)
Sets the ceiling's slope vector. The vector has to be normalized.
#### Parameters
* normal: The new slope vector as `Vector3D`
---
### setFloorSlope(normal)
Sets the floor's slope vector. The vector has to be normalized.
#### Parameters

View file

@ -1,10 +1,16 @@
# Sidedef
## Properties
---
### angle
The `Sidedef`'s angle in degrees. Read-only.
---
### angleRad
The `Sidedef`'s angle in radians. Read-only.
---
### fields
UDMF fields. It's an object with the fields as properties.
@ -33,6 +39,8 @@ To remove a field you have to assign `null` to it:
```js
s.fields.user_myintfield = null;
```
---
### flags
`Sidedef` flags. It's an object with the flags as properties. Only available in UDMF.
@ -41,23 +49,73 @@ s.fields.user_myintfield = null;
s.flags['noattack'] = true; // Monsters in this sector don't attack
s.flags.noattack = true; // Also works
```
---
### index
The `Sidedef`'s index. Read-only.
---
### isFront
`true` if this `Sidedef` is the front of its `Linedef`, otherwise `false`. Read-only.
---
### line
The `Linedef` the `Sidedef` belongs to. Read-only.
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### lowerHighlighted
If the `Sidedef`'s lower part is highlighted or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### lowerSelected
If the `Sidedef`'s lower part is selected or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
---
### lowerTexture
The `Sidedef`'s lower texture.
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### middleHighlighted
If the `Sidedef`'s middle part is highlighted or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### middleSelected
If the `Sidedef`'s middle part is selected or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
---
### middleTexture
The `Sidedef`'s middle texture.
---
### offsetX
The x offset of the `Sidedef`'s textures.
---
### offsetY
The y offset of the `Sidedef`'s textures.
---
### other
The `Sidedef` on the other side of this `Sidedef`'s `Linedef`. Returns `null` if there is no other. Read-only.
---
### sector
The `Sector` the `Sidedef` belongs to. Read-only.
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### upperHighlighted
If the `Sidedef`'s upper part is highlighted or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### upperSelected
If the `Sidedef`'s upper part is selected or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
---
### upperTexture
The `Sidedef`'s upper texture.

View file

@ -1,14 +1,24 @@
# Thing
## Properties
---
### action
`Thing` action. Hexen and UDMF only.
---
### angle
Angle of the `Thing` in degrees, see https://doomwiki.org/wiki/Angle.
---
### angleRad
Angle of the `Thing` in radians.
---
### args
`Array` of arguments of the `Thing`. Number of arguments depends on game config (usually 5). Hexen format and UDMF only.
---
### fields
UDMF fields. It's an object with the fields as properties.
@ -37,6 +47,8 @@ To remove a field you have to assign `null` to it:
```js
s.fields.user_myintfield = null;
```
---
### flags
`Thing` flags. It's an object with the flags as properties. In Doom format and Hexen format they are identified by numbers, in UDMF by their name.
Doom and Hexen:
@ -50,12 +62,20 @@ UDMF:
t.flags['ambush'] = true; // Set the ambush flag
t.flags.ambush = true; // Also works
```
---
### index
Index of the `Thing`. Read-only.
---
### marked
If the `Thing` is marked or not. It is used to mark map elements that were created or changed (for example after drawing new geometry).
---
### pitch
Pitch of the `Thing` in degrees. Only valid for supporting game configurations.
---
### position
Position of the `Thing`. It's an object with `x`, `y`, and `z` properties. The latter is only relevant in Hexen format and UDMF.
The `x`, `y`, and `z` accept numbers:
@ -72,23 +92,39 @@ t.position = new Vector3D(32, 64, 128);
t.position = [ 32, 64 ];
t.position = [ 32, 64, 128 ];
```
---
### roll
Roll of the `Thing` in degrees. Only valid for supporting game configurations.
---
### selected
If the `Thing` is selected or not.
---
### tag
`Thing` tag. UDMF only.
---
### type
Type of the `Thing`.
## Methods
---
### clearFlags()
Clears all flags.
---
### copyPropertiesTo(t)
Copies the properties from this `Thing` to another.
#### Parameters
* t: The `Thing` to copy the properties to
---
### delete()
Deletes the `Thing`.
---
### distanceTo(pos)
Gets the distance between this `Thing` and the given point. The point can be either a `Vector2D` or an array of numbers.
@ -100,6 +136,8 @@ t.distanceToSq([ 32, 64 ]);
* pos: Point to calculate the distance to.
#### Return value
Distance to `pos`
---
### distanceToSq(pos)
Gets the squared distance between this `Thing` and the given point.
The point can be either a `Vector2D` or an array of numbers.
@ -112,11 +150,17 @@ t.distanceToSq([ 32, 64 ]);
* pos: Point to calculate the squared distance to.
#### Return value
Distance to `pos`
---
### getSector()
Determines and returns the `Sector` the `Thing` is in.
#### Return value
The `Sector` the `Thing` is in
---
### snapToAccuracy()
Snaps the `Thing`'s position to the map format's accuracy.
---
### snapToGrid()
Snaps the `Thing`'s position to the grid.

View file

@ -1,6 +1,8 @@
# Vector2D
## Constructors
---
### Vector2D(v)
Creates a new `Vector2D` from a point.
@ -9,6 +11,8 @@ let v = new Vector2D([ 32, 64 ]);
```
#### Parameters
* v: The vector to create the `Vector2D` from
---
### Vector2D(x, y)
Creates a new `Vector2D` from x and y coordinates
@ -19,6 +23,8 @@ let v = new Vector2D(32, 64);
* x: The x coordinate
* y: The y coordinate
## Static methods
---
### crossProduct(a, b)
Returns the cross product of two `Vector2D`s.
#### Parameters
@ -26,6 +32,8 @@ Returns the cross product of two `Vector2D`s.
* b: Second `Vector2D`
#### Return value
Cross product of the two vectors as `Vector2D`
---
### dotProduct(a, b)
Returns the dot product of two `Vector2D`s.
#### Parameters
@ -33,18 +41,24 @@ Returns the dot product of two `Vector2D`s.
* b: Second `Vector2D`
#### Return value
The dot product of the two vectors
---
### fromAngle(angle)
Creates a `Vector2D` from an angle in degrees,
#### Parameters
* angle: Angle in degrees
#### Return value
Vector as `Vector2D`
---
### fromAngleRad(angle)
Creates a `Vector2D` from an angle in radians,
#### Parameters
* angle: Angle in radians
#### Return value
Vector as `Vector2D`
---
### getAngle(a, b)
Returns the angle between two `Vector2D`s in degrees.
#### Parameters
@ -52,6 +66,8 @@ Returns the angle between two `Vector2D`s in degrees.
* b: Second `Vector2D`
#### Return value
Angle in degrees
---
### getAngleRad(a, b)
Returns the angle between two `Vector2D`s in radians
#### Parameters
@ -59,6 +75,8 @@ Returns the angle between two `Vector2D`s in radians
* b: Second `Vector2D`
#### Return value
Angle in radians
---
### getDistance(a, b)
Returns the distance between two `Vector2D`s.
#### Parameters
@ -66,6 +84,8 @@ Returns the distance between two `Vector2D`s.
* b: Second `Vector2D`
#### Return value
The distance
---
### getDistanceSq(a, b)
Returns the square distance between two `Vector2D`s.
#### Parameters
@ -73,6 +93,8 @@ Returns the square distance between two `Vector2D`s.
* b: Second `Vector2D`
#### Return value
The squared distance
---
### reflect(v, m)
Reflects a `Vector2D` over a mirror `Vector2D`.
#### Parameters
@ -80,6 +102,8 @@ Reflects a `Vector2D` over a mirror `Vector2D`.
* m: Mirror `Vector2D`
#### Return value
The reflected vector as `Vector2D`
---
### reversed(v)
Returns a reversed `Vector2D`.
#### Parameters
@ -87,19 +111,29 @@ Returns a reversed `Vector2D`.
#### Return value
The reversed vector as `Vector2D`
## Properties
---
### x
The `x` value of the vector.
---
### y
The `y` value of the vector.
## Methods
---
### getAngle()
Returns the angle of the `Vector2D` in degree.
#### Return value
The angle of the `Vector2D` in degree
---
### getAngleRad()
Returns the angle of the `Vector2D` in radians.
#### Return value
The angle of the `Vector2D` in radians
---
### getInverseTransformed(invoffsetx, invoffsety, invscalex, invscaley)
Returns the inverse transformed vector as `Vector2D`.
#### Parameters
@ -109,38 +143,54 @@ Returns the inverse transformed vector as `Vector2D`.
* invscaley: Y scale
#### Return value
The inverse transformed vector as `Vector2D`
---
### getLength()
Returns the length of the `Vector2D`.
#### Return value
The length of the `Vector2D`
---
### getLengthSq()
Returns the square length of the `Vector2D`.
#### Return value
The square length of the `Vector2D`
---
### getNormal()
Returns the normal of the `Vector2D`.
#### Return value
The normal as `Vector2D`
---
### getPerpendicular()
Returns the perpendicular to the `Vector2D`.
#### Return value
The perpendicular as `Vector2D`
---
### getRotated(theta)
Returns the rotated vector as `Vector2D`.
#### Parameters
* theta: Angle in degree to rotate by
#### Return value
The rotated `Vector2D`
---
### getRotatedRad(theta)
Returns the rotated vector as `Vector2D`.
#### Parameters
* theta: Angle in radians to rotate by
#### Return value
The rotated `Vector2D`
---
### getSign()
Returns a `Vector2D` with the sign of all components.
#### Return value
A `Vector2D` with the sign of all components
---
### getTransformed(offsetx, offsety, scalex, scaley)
Returns the transformed vector as `Vector2D`.
#### Parameters
@ -150,6 +200,8 @@ Returns the transformed vector as `Vector2D`.
* scaley: Y scale
#### Return value
The transformed vector as `Vector2D`
---
### isFinite()
Checks if the `Vector2D` is finite or not.
#### Return value

View file

@ -1,6 +1,8 @@
# Vector3D
## Constructors
---
### Vector3D(v)
Creates a new `Vector3D` from a point.
@ -9,6 +11,8 @@ let v = new Vector3D([ 32, 64, 128 ]);
```
#### Parameters
* v: The vector to create the `Vector3D` from
---
### Vector3D(x, y, z)
Creates a new `Vector3D` from x and y coordinates
@ -20,6 +24,8 @@ let v = new Vector3D(32, 64, 128);
* y: The y coordinate
* z: The z coordinate
## Static methods
---
### crossProduct(a, b)
Returns the cross product of two `Vector3D`s.
#### Parameters
@ -27,6 +33,8 @@ Returns the cross product of two `Vector3D`s.
* b: Second `Vector3D`
#### Return value
Cross product of the two vectors as `Vector3D`
---
### dotProduct(a, b)
Returns the dot product of two `Vector3D`s.
#### Parameters
@ -34,18 +42,24 @@ Returns the dot product of two `Vector3D`s.
* b: Second `Vector3D`
#### Return value
The dot product of the two vectors
---
### fromAngleXY(angle)
Creates a `Vector3D` from an angle in radians,
#### Parameters
* angle: Angle on the x/y axes in degrees
#### Return value
Vector as `Vector3D`
---
### fromAngleXYRad(angle)
Creates a `Vector3D` from an angle in radians
#### Parameters
* angle: Angle on the x/y axes in radians
#### Return value
Vector as `Vector3D`
---
### fromAngleXYZ(anglexy, anglez)
Creates a `Vector3D` from two angles in degrees
#### Parameters
@ -53,6 +67,8 @@ Creates a `Vector3D` from two angles in degrees
* anglez: Angle on the z axis in radians
#### Return value
Vector as `Vector3D`
---
### fromAngleXYZRad(anglexy, anglez)
Creates a `Vector3D` from two angles in radians
#### Parameters
@ -60,6 +76,8 @@ Creates a `Vector3D` from two angles in radians
* anglez: Angle on the z axis in radians
#### Return value
Vector as `Vector3D`
---
### reflect(v, m)
Reflects a `Vector3D` over a mirror `Vector3D`.
#### Parameters
@ -67,6 +85,8 @@ Reflects a `Vector3D` over a mirror `Vector3D`.
* m: Mirror `Vector3D`
#### Return value
The reflected vector as `Vector3D`
---
### reversed(v)
Returns a reversed `Vector3D`.
#### Parameters
@ -74,51 +94,77 @@ Returns a reversed `Vector3D`.
#### Return value
The reversed vector as `Vector3D`
## Properties
---
### x
The `x` value of the vector.
---
### y
The `y` value of the vector.
---
### z
The `z` value of the vector.
## Methods
---
### getAngleXY()
Returns the angle of the `Vector3D` in degrees.
#### Return value
The angle of the `Vector3D` in degrees
---
### getAngleXYRad()
Returns the x/y angle of the `Vector3D` in radians.
#### Return value
The x/y angle of the `Vector3D` in radians
---
### getAngleZ()
Returns the z angle of the `Vector3D` in degrees.
#### Return value
The z angle of the `Vector3D` in degrees
---
### getAngleZRad()
Returns the z angle of the `Vector3D` in radians.
#### Return value
The z angle of the `Vector3D` in radians
---
### getLength()
Returns the length of the `Vector3D`.
#### Return value
The length of the `Vector3D`
---
### getLengthSq()
Returns the square length of the `Vector3D`.
#### Return value
The square length of the `Vector3D`
---
### getNormal()
Returns the normal of the `Vector3D`.
#### Return value
The normal as `Vector3D`
---
### getScaled(scale)
Return the scaled `Vector3D`.
#### Parameters
* scale: Scale, where 1.0 is unscaled
#### Return value
The scaled `Vector3D`
---
### isFinite()
Checks if the `Vector3D` is finite or not.
#### Return value
`true` if `Vector3D` is finite, otherwise `false`
---
### isNormalized()
Checks if the `Vector3D` is normalized or not.
#### Return value

View file

@ -1,8 +1,12 @@
# Vertex
## Properties
---
### ceilingZ
The ceiling z position of the `Vertex`. Only available in UDMF. Only available for supported game configurations.
---
### fields
UDMF fields. It's an object with the fields as properties.
@ -31,12 +35,20 @@ To remove a field you have to assign `null` to it:
```js
s.fields.user_myintfield = null;
```
---
### floorZ
The floor z position of the `Vertex`. Only available in UDMF. Only available for supported game configurations.
---
### index
The vertex index. Read-only.
---
### marked
If the `Vertex` is marked or not. It is used to mark map elements that were created or changed (for example after drawing new geometry).
---
### position
Position of the `Vertex`. It's an object with `x` and `y` properties.
The `x` and `y` accept numbers:
@ -51,15 +63,23 @@ It's also possible to set all fields immediately by assigning either a `Vector2D
v.position = new Vector2D(32, 64);
v.position = [ 32, 64 ];
```
---
### selected
If the `Vertex` is selected or not.
## Methods
---
### copyPropertiesTo(v)
Copies the properties from this `Vertex` to another.
#### Parameters
* v: the vertex to copy the properties to
---
### delete()
Deletes the `Vertex`. Note that this can result in unclosed sectors.
---
### distanceTo(pos)
Gets the distance between this `Vertex` and the given point.
The point can be either a `Vector2D` or an array of numbers.
@ -72,6 +92,8 @@ v.distanceTo([ 32, 64 ]);
* pos: Point to calculate the distance to.
#### Return value
Distance to `pos`
---
### distanceToSq(pos)
Gets the squared distance between this `Vertex` and the given point.
The point can be either a `Vector2D` or an array of numbers.
@ -84,21 +106,31 @@ v.distanceToSq([ 32, 64 ]);
* pos: Point to calculate the squared distance to.
#### Return value
Squared distance to `pos`
---
### getLinedefs()
Gets all `Linedefs` that are connected to this `Vertex`.
#### Return value
Array of linedefs
---
### join(other)
Joins this `Vertex` with another `Vertex`, deleting this `Vertex` and keeping the other.
#### Parameters
* other: `Vertex` to join with
---
### nearestLinedef(pos)
Returns the `Linedef` that is connected to this `Vertex` that is closest to the given point.
#### Parameters
* pos: Point to get the nearest `Linedef` connected to this `Vertex` from
#### Return value
*missing*
---
### snapToAccuracy()
Snaps the `Vertex`'s position to the map format's accuracy.
---
### snapToGrid()
Snaps the `Vertex`'s position to the grid.

View file

@ -0,0 +1,18 @@
# Changes
This site lists all changes between different API version of UDBScript
## Version 3
- Exported the classes `Linedef`, `Sector`, `Sidedef`, `Thing`, and `Vertex`, so that they can be used with `instanceof`
- `Map` class
- the `getSidedefsFromSelectedLinedefs()` method now correctly only returns the `Sidedef`s of selected `Linedef`s in visual mode (and not also the highlighted one)
- added a new `getSidedefsFromSelectedOrHighlightedLinedefs()` method as the equivalent to the other `getSelectedOrHighlighted*()` methods
- `Sector` class
- added new `floorSelected`, `ceilingSelected`, `floorHighlighted`, and `ceilingHighlighted` properties. Those are mostly useful in visual mode, since they always return true when the `Sector` is selected or highlighted in the classic modes. The properties are read-only
- `Sidedef` class
- added new `upperSelected`, `middleSelected`, `lowerSelected`, `upperHighlighted`, `middleHighlighted`, and `lowerHighlighted` properties. Those are mostly useful in visual mode, since they always return true when the parent `Linedef` is selected or highlighted in the classic modes. The properties are read-only
## Version 2
- `Pen` built-in library
- the methods of the `Pen` class now return the instance of the Pen class to allow method chaining

View file

@ -247,11 +247,15 @@ let v2 = new Vector2D(2, 3) * 3; // Results in new Vector(6, 9)
### Working with map elements
Map elements (things, sectors, linedefs, sidedefs, vertices) can be accessed through the global `Map` object. This object has methods that return an array of map elements, for example `Map.getSectors()` returns an array of `Sector` objects, which are are all sectors in the map. There are also methods to get all selected (for example `Map.getSelectedSectors()`) and marked (for example `Map.getMarkedSectors()`) map elements. These map elements can then be modified, see the documentation for the particular map element type in the API section.
Map elements (things, sectors, linedefs, sidedefs, vertices) can be accessed through the global `Map` object. This object has methods that return an array of map elements, for example `Map.getSectors()` returns an array of `Sector` objects, which are are all sectors in the map. There are also methods to get all selected (for example `Map.getSelectedSectors()`) and marked (for example `Map.getMarkedSectors()`), or the currently highlighted (for example `Map.getHighlightedSector()`) map elements. There are also methods to get either the currently selected map elements, *or* the currently highlighted map elements (for example `Map.getSelectedOrHighlightedSectors()`). These map elements can then be modified, see the documentation for the particular map element type in the API section.
!!! note
"Marking" a map element is a way to denote that something happened to this map element. For example when using the `Map.drawLines()` method all new geometry will be marked.
!!! info
UDB differentiates between "selecting" and "highlighting" map elements. "Selecting" means clicking on the map element, "highlighting" means just hovering the mouse on (or near) a map element. All the `Map.getSelectedOrHighlighted...()` methods behave like UDB usually works, i.e. if at least one map element is selected, the selected map elements will be returned (and the highlighted map element will be ignored), if no map elements are selected the highlighted map element will be returned.
In most circumstances it is recommended to use the `Map.getSelectedOrHighlighted...()` to stay close to UDB's built-in actions.
### Creating new geometry
New map geometry can be created with the `drawLines()` method of the `Map` object. It accepts an array of coordinates in map space. The coordinates can either by instances of `Vector2D`, `Vector3D`, or an array of numbers.

View file

@ -3,6 +3,7 @@
## UDB script
- [Getting started](gettingstarted.md)
- [Changes](changes.md)
## API

View file

@ -1,12 +1,13 @@
site_name: UDB Script
site_name: UDBScript
theme: readthedocs
markdown_extensions:
- admonition
- footnotes
nav:
- 'UDB Script':
- 'UDBScript':
- Index: 'index.md'
- 'Getting started': 'gettingstarted.md'
- 'Changes': 'changes.md'
- 'API':
- Angle2D: 'Angle2D.md'
- Data: 'Data.md'