Skip to content

Commit

Permalink
documents procs all the way down to istype()
Browse files Browse the repository at this point in the history
  • Loading branch information
hry-gh committed Nov 14, 2024
1 parent b445c5b commit f2bfda8
Show file tree
Hide file tree
Showing 39 changed files with 387 additions and 50 deletions.
7 changes: 6 additions & 1 deletion content/language/proc/fexists.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ type = "num" # AUTOGEN FIELD
description = "1 if the file exists; 0 if it does not."
+++

Determines if the file exists in the file system. Unlike [fdel()](@/language/proc/fdel.md), this exclusively operates on files - it cannot determine if a directory exists.
Determines if the file exists in the file system. Unlike [fdel()](@/language/proc/fdel.md), this exclusively operates on files - it cannot determine if a directory exists.

```dm
if(!fexists("code.dme"))
world.log << "How did we get here?"
```
12 changes: 11 additions & 1 deletion content/language/proc/flick.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
title = "flick"
[[extra.args]]
name = "Icon" # AUTOGEN STATIC
description = "An icon file, or a named icon state."
[[extra.args]]
name = "Object" # AUTOGEN STATIC
+++
description = "The object being changed."
+++

Temporarily replaces the {{ atom(var="icon") }}, or {{ atom(var="icon_state") }}, of the specified object for the duration of the animation. This only occurs on the client - the icon or icon_state variable is not actually altered.

```dm
/obj/button/Click()
flick("pressed_animation", src)
usr << "You pressed me!"
```
27 changes: 26 additions & 1 deletion content/language/proc/flist.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@
title = "flist"
[[extra.args]]
name = "Path" # AUTOGEN STATIC
description = "The path in the file system to return the contents of."
[extra.return]
type = "/list" # AUTOGEN FIELD
+++
description = "A list of files and directories in the specified path."
+++

This is non-recursive, and only returns the contents of the directory specified. Names returned are relative to the specified path.

Path must be a directory with a trailing slash.

```dm
// given a directory structure like
//
// example
// ├── maps
// │ └── map.dmm
// ├── code.dme
// └── icons
// ├── icon.dmi
// └── other_icon.dmi
for(var/item in flist("icons/"))
world.log << item // "icon.dmi", "other_icon.dmi"
for(var/item in flist("./"))
world.log << item // "maps/", "code.dme", "icons/"
```
9 changes: 8 additions & 1 deletion content/language/proc/floor.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
title = "floor"
[[extra.args]]
name = "A" # AUTOGEN STATIC
description = "A number."
[extra.return]
type = "num" # AUTOGEN FIELD
+++
description = "The largest integer less than or equal to A."
+++

```dm
world.log << floor(0.999999) // 0
world.log << floor(-0.00001) // 1
```
9 changes: 8 additions & 1 deletion content/language/proc/fract.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
title = "fract"
[[extra.args]]
name = "n" # AUTOGEN STATIC
description = "A number."
[extra.return]
type = "num" # AUTOGEN FIELD
+++
description = "The numbers after the decimal point."
+++

```dm
world.log << fract(0.1234) // 1234
world.log << fract(-0.1234) // -1234
```
12 changes: 11 additions & 1 deletion content/language/proc/ftime.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@
title = "ftime"
[[extra.args]]
name = "File" # AUTOGEN STATIC
description = "The path to the entry on the file system to test."
[[extra.args]]
name = "IsCreationTime" # AUTOGEN STATIC
default_value = "0" # AUTOGEN FIELD
description = "1 return the creation date; 0 for last modified date"
[extra.return]
type = "num" # AUTOGEN FIELD
+++
description = "Date expressed as number of deciseconds since Jan 1, 2000."
+++

This value can be formatted using [time2text()](@/language/proc/time2text.md).

```dm
var/time = ftime("environment.dme") // 7.76174e+09
world.log << time2text(time) // Mon Aug 05 12:58:22 2024
```
12 changes: 11 additions & 1 deletion content/language/proc/get_dist.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@
title = "get_dist"
[[extra.args]]
name = "Loc1" # AUTOGEN STATIC
description = "An object on the map."
type = "/atom" # AUTOGEN FIELD
[[extra.args]]
name = "Loc2" # AUTOGEN STATIC
description = "An object on the map."
type = "/atom" # AUTOGEN FIELD
[extra.return]
type = "num" # AUTOGEN FIELD
+++
description = "The number of tiles between both arguments."
+++

If either object is not on the map, 127 will be returned.
If both arguments are the same object, -1 will be returned.

{% parity() %}
In BYOND, the distance in Z level is also calculated.
{% end %}
10 changes: 9 additions & 1 deletion content/language/proc/get_step_away.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
+++
title = "get_step_away"
[extra.return]
type = "/turf, num"
description = "The new position; or 0 if no movement has occured."
[[extra.args]]
name = "Ref" # AUTOGEN STATIC
type = "/atom/movable" # AUTOGEN FIELD
description = "The moving object."
[[extra.args]]
name = "Trg" # AUTOGEN STATIC
type = "/atom" # AUTOGEN FIELD
description = "The object being moved away from."
[[extra.args]]
name = "Max" # AUTOGEN STATIC
default_value = "5" # AUTOGEN FIELD
+++
description = "The maximum distance between Ref and Trg."
+++

Calculates the step in the opposite direction from the provided object.
8 changes: 7 additions & 1 deletion content/language/proc/get_step_rand.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
+++
title = "get_step_rand"
[extra.return]
type = "/turf, num"
description = "The new position; or 0 if no movement has occured."
[[extra.args]]
name = "Ref" # AUTOGEN STATIC
type = "/atom/movable" # AUTOGEN FIELD
+++
description = "The moving object."
+++

Calculates the destination of Ref taking a step in a random direction.
8 changes: 7 additions & 1 deletion content/language/proc/get_step_to.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ title = "get_step_to"
od_unimplemented = true # AUTOGEN FIELD
[[extra.args]]
name = "Ref" # AUTOGEN STATIC
description = "The moving object."
[[extra.args]]
name = "Trg" # AUTOGEN STATIC
description = "The object being moved away towards."
[[extra.args]]
name = "Min" # AUTOGEN STATIC
default_value = "0" # AUTOGEN FIELD
+++
description = "If the two objects are within this many steps, no step is calculated."
[extra.return]
type = "/turf"
description = "The location that should be moved to; 0 if no path is calculated."
+++
7 changes: 6 additions & 1 deletion content/language/proc/get_step_towards.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
+++
title = "get_step_towards"
[extra.return]
type = "/turf, num"
description = "The new position; or 0 if no movement has occured."
[[extra.args]]
name = "Ref" # AUTOGEN STATIC
type = "/atom/movable" # AUTOGEN FIELD
description = "The moving object."
[[extra.args]]
name = "Trg" # AUTOGEN STATIC
type = "/atom" # AUTOGEN FIELD
+++
description = "The object being moved towards."
+++
15 changes: 13 additions & 2 deletions content/language/proc/get_steps_to.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,22 @@ title = "get_steps_to"
od_unimplemented = true # AUTOGEN FIELD
[[extra.args]]
name = "Ref" # AUTOGEN STATIC
description = "The moving object."
[[extra.args]]
name = "Trg" # AUTOGEN STATIC
description = "The object being moved towards."
[[extra.args]]
name = "Min" # AUTOGEN STATIC
default_value = "0" # AUTOGEN FIELD
description = "If the two objects are within this many steps, no step is calculated."
[extra.return]
type = "/list" # AUTOGEN FIELD
+++
type = "/list, null" # AUTOGEN SKIP
description = "A list of directions to step in to reach the Trg; or null if no path is available."
+++

Calculates a path from Ref to Trg, avoiding dense objects. If the target is more than double {{ world(var="view") }}, null is returned.

```dm
for(var/dir in get_steps_to(me, them))
step(me, dir) // on our way!
```
22 changes: 21 additions & 1 deletion content/language/proc/gradient.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
+++
title = "gradient"
[extra]
format = [
[
{ name = "Item1", description = "Elements of a color gradient list." },
{ name = "Item2" },
{ name = "..." },
{ name = "index" },
],
[
{ name = "Gradient", type = "/list", description = "A color gradient list." },
{ name = "index", description = "The index on the gradient to perform the interpolation on." },
],
]
return = { type = "text", description = "A color, either in #rrggbb or #rrggbbaa format." }
[[extra.args]]
name = "A" # AUTOGEN STATIC
[[extra.args]]
name = "index" # AUTOGEN STATIC
+++
+++

Generates a gradient between the specified elements, and retrieves the color at the specified point along the gradient, per the index argument.

```dm
world.log << gradient("#FF0000", "#000000", 0.5) // outputs #7F0000, as we have halved the red value
```
16 changes: 15 additions & 1 deletion content/language/proc/hascall.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,22 @@
title = "hascall"
[[extra.args]]
name = "Object" # AUTOGEN STATIC
description = "The object to check."
[[extra.args]]
name = "ProcName" # AUTOGEN STATIC
type = "text"
description = "The name of the proc."
[extra.return]
type = "num" # AUTOGEN FIELD
+++
description = "1 if the object has the specified proc; 0 if it does not"
+++

```dm
/datum/my_thingy/proc/does_something()
/world/New()
var/datum/my_thingy/thing = new
if(hascall(thing, "does_something"))
world.log << "The thing does something!"
```
7 changes: 6 additions & 1 deletion content/language/proc/hearers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
title = "hearers"
[[extra.args]]
name = "Depth" # AUTOGEN STATIC
description = "The radius to check for hearers in."
[[extra.args]]
name = "Center" # AUTOGEN STATIC
description = "An object on the map to check for hearers around."
[extra.return]
type = "/list" # AUTOGEN FIELD
+++
description = "A list of /mobs that can hear the center object."
+++

An object that can hear another object is calculated similarly to [viewers()](@/language/proc/viewers.md), but ignores darkness, as you can still hear in the dark.
11 changes: 10 additions & 1 deletion content/language/proc/html_decode.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
title = "html_decode"
[[extra.args]]
name = "HtmlText" # AUTOGEN STATIC
description = "A string to unescape."
[extra.return]
type = "text" # AUTOGEN FIELD
+++
description = "The provided string, unescaped."
+++

The inverse of [html_encode()](@/language/proc/html_encode.md), text that has already been escaped - such as `&` becoming `&amp;` - can be decoded into a normal string.

```dm
world.log << html_decode("My &amp; strin&#39;g full &gt; of reserved &#39; &lt; characters &quot;.")
// My & strin'g full > of reserved ' < characters \".
```
11 changes: 10 additions & 1 deletion content/language/proc/html_encode.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
title = "html_encode"
[[extra.args]]
name = "PlainText" # AUTOGEN STATIC
description = "A string to escape."
[extra.return]
type = "text" # AUTOGEN FIELD
+++
description = "The provided string, escaped."
+++

Before text can be displayed in a HTML document, certain reserved characters must be encoded, as they have special meaning in HTML. Using html_encode() on the string before it is displayed ensures that it is displayed literally.

```dm
world.log << html_encode("My & strin'g full > of reserved ' < characters \".")
// My &amp; strin&#39;g full &gt; of reserved &#39; &lt; characters &quot;.
```
9 changes: 8 additions & 1 deletion content/language/proc/icon.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@
title = "icon"
[[extra.args]]
name = "icon" # AUTOGEN STATIC
description = "An icon file, or /icon."
[[extra.args]]
name = "icon_state" # AUTOGEN STATIC
description = "Optional, the icon state within the icon to retrieve."
[[extra.args]]
name = "dir" # AUTOGEN STATIC
description = "Optional, the direction to retrieve."
[[extra.args]]
name = "frame" # AUTOGEN STATIC
description = "Optional, the animation frame to retrieve."
[[extra.args]]
name = "moving" # AUTOGEN STATIC
+++
description = "If truthy, extracts only movement states; 0 for non-movement states; null for both."
+++

This constructs a new {{ icon() }}, similar to using `new /icon()`, with the specified icon.
7 changes: 5 additions & 2 deletions content/language/proc/icon_states.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ name = "Icon" # AUTOGEN STATIC
name = "mode" # AUTOGEN STATIC
default_value = "0" # AUTOGEN FIELD
[extra.return]
type = "null, text" # AUTOGEN FIELD
+++
type = "null, /list" # AUTOGEN SKIP
description = "A list of strings containing the name of icon states."
+++

Icon files containing multiple icon states can be retrieved. The default, unnamed icon state is retrieved as "".
Loading

0 comments on commit f2bfda8

Please sign in to comment.