Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/g-js-api/G.js/llms.txt

Use this file to discover all available pages before exploring further.

The item functions provide direct access to GD’s Item Edit and Item Compare triggers. While counters handle most arithmetic at a higher level, these functions let you compose advanced item expressions with full control over types, operators, and modifiers. Item IDs for counters can be retrieved from counter.item. For background context on counters see Counters and Conditions.

Constants Reference

These constants are exported from geometry-dash-gjs and used throughout the item API.

Item Type Constants

ConstantValueDescription
ITEM1Standard item (pickup, counter)
TIMER2Timer item
POINTS3Points/score item
TIME4Level time
ATTEMPT5Attempt number

Assignment Operator Constants (assign_op)

ConstantValueOperation
EQ0target = expression
ADD1target += expression
SUB2target -= expression
MUL3target *= expression
DIV4target /= expression

Comparison Operator Constants (compare_op)

ConstantValueCondition
GREATER1item1 > item2
GREATER_OR_EQ2item1 >= item2
LESS3item1 < item2
LESS_OR_EQ4item1 <= item2
NOT_EQ5item1 ≠ item2

Abs/Neg Constants (absn1, absn2)

ConstantValueEffect
ABS1Take absolute value
NEG2Negate the value

Round/Floor/Ceil Constants (rfc1, rfc2)

ConstantValueEffect
RND1Round to nearest integer
FLR2Floor to nearest integer below
CEI3Ceil to nearest integer above

item_edit

Low-level implementation of the GD Item Edit trigger. Computes an expression from two source items and assigns the result to a target item. The formula is roughly:
target [assign_op]= (item1 [op1] item2) [op2] mod
with optional abs/neg and rounding applied to each side.
import {
  item_edit, counter,
  ITEM, EQ, ADD, MUL
} from 'geometry-dash-gjs';

const a = counter(5);
const b = counter(3);
const result = counter(0);

// result = a + b
item_edit(
  a.item, b.item, result.item,
  ITEM, ITEM, ITEM,
  EQ, ADD
).add();
item1
any
required
Item ID 1. Retrieve from counter.item.
item2
any
required
Item ID 2. Retrieve from counter.item.
target
any
required
Target item ID to write the result into.
type1
number
default:"NONE"
Type of item 1. Use ITEM, TIMER, POINTS, TIME, or ATTEMPT.
type2
number
default:"NONE"
Type of item 2.
targ_type
number
default:"NONE"
Type of the target item.
assign_op
number
default:"EQ"
Assignment operator applied to the target. Use EQ, ADD, SUB, MUL, or DIV.
op1
number
default:"ADD"
Operator combining item1 and item2. Use ADD, SUB, MUL, or DIV.
op2
number
default:"MUL"
Operator combining the intermediate result with mod.
mod
number
default:"1"
Scalar modifier applied via op2 to the entire expression.
absn1
number
default:"NONE"
Apply ABS or NEG to item1 before the operation.
absn2
number
default:"NONE"
Apply ABS or NEG to item2 before the operation.
rfc1
number
default:"NONE"
Apply RND, FLR, or CEI to item1.
rfc2
number
default:"NONE"
Apply RND, FLR, or CEI to item2.
Returns GJsObject — call .add() to place the trigger in the level.
You must call .add() on the returned object for the trigger to be included in the exported level.

item_comp

Low-level implementation of the GD Item Compare trigger. Compares two items and calls one of two groups depending on the result.
import {
  item_comp, counter, group,
  ITEM, GREATER
} from 'geometry-dash-gjs';

const a = counter(10);
const b = counter(5);

// If a > b, call group(1), otherwise call group(2)
item_comp(
  a.item, b.item,
  ITEM, ITEM,
  GREATER,
  group(1), group(2)
).add();
item_1
any
required
First item ID.
item_2
any
required
Second item ID.
type_1
number
required
Type of item 1. Use ITEM, TIMER, POINTS, TIME, or ATTEMPT.
type_2
number
required
Type of item 2.
compare_op
number
required
Comparison operator. Use GREATER, GREATER_OR_EQ, LESS, LESS_OR_EQ, or NOT_EQ.
truei
$group
default:"group(0)"
Group to call when the comparison is true.
falsei
$group
default:"group(0)"
Group to call when the comparison is false.
mod_1
number
default:"1"
Modifier for item 1 applied via op_1.
mod_2
number
default:"1"
Modifier for item 2 applied via op_2.
tol
number
default:"0"
Tolerance offset applied to the result.
op_1
number
default:"MUL"
Operator for mod_1. Use ADD, SUB, MUL, or DIV.
op_2
number
default:"MUL"
Operator for mod_2.
absneg_1
number
default:"NONE"
Apply ABS or NEG to item 1.
absneg_2
number
default:"NONE"
Apply ABS or NEG to item 2.
rfc_1
number
default:"NONE"
Apply RND, FLR, or CEI to item 1.
rfc_2
number
default:"NONE"
Apply RND, FLR, or CEI to item 2.
Returns GJsObject — call .add() to place the trigger in the level.

compare

Higher-level helper that compares two counters and calls the appropriate group without requiring manual type annotations.
import { compare, counter, group, GREATER } from 'geometry-dash-gjs';

const a = counter(10);
const b = counter(3);

compare(a, GREATER, b, group(1), group(2));
// If a > b → group(1) is called
// Otherwise → group(2) is called
c1
any
required
First counter or item to compare.
op
number
required
Comparison operator. Use GREATER, GREATER_OR_EQ, LESS, LESS_OR_EQ, or NOT_EQ.
c2
any
required
Second counter or item to compare.
truei
any
required
Group to call when the comparison is true.
falsei
any
required
Group to call when the comparison is false.
compare is a convenience wrapper around item_comp. Use item_comp directly when you need fine-grained control over modifiers, tolerances, or abs/neg/rounding flags.

Build docs developers (and LLMs) love