Aetheria Wiki

Programming Poncho (G-Script)

G-Script: the language

It's a small slice of Python. If it's listed here, it works.

# comments start with a hash
x = 3                     # variables
x += 1                    # also -= *= /= //= %=
crops = [1, 2, 3]         # lists: crops[0], crops[-1], crops[i] = v, crops.append(4)
sold = {Corn: 0, "x": 2}  # dictionaries (Memory manual): sold[Corn] += 1, "x" in sold

if is_ripe():             # if / elif / else
    harvest()
elif not is_tilled():
    till()
else:
    wait(1)

for i in range(3):        # for loops: range(stop), range(start, stop), range(start, stop, step)
    move(East)

while not is_ripe():      # while loops, with break / continue / pass
    wait(2)

if is_ripe(): harvest()   # one-line blocks are fine
  • Indent with 4 spaces.
  • Math + - * / // % ** (/ gives decimals). Compare == != < <= > >=, plus in / not in. Logic and or not.
  • Functions (needs the Functions manual): def name(a, b): … return value. Use global x inside a function to change a top-level variable.
  • Built-ins: print(...) (goes to chat), len, range, abs, min, max, str, int, float, round(n) / round(n, digits), list.
  • List methods: .append(v), .pop(), .pop(i), .insert(i, v), .remove(v), .index(v), .count(v).
  • Dictionaries (needs the Memory manual): d = {key: value}, d[key], d[key] = v, key in d, len(d), for key in d:, .get(key) / .get(key, default), .keys(), .values(), .items() (a list of [key, value]), .pop(key), .clear(). Keys can be text, numbers or names like Corn.
  • Constants: North East South West, Potato Radish Beans Corn, Compost Urea Lime Sulfur Phosphate Potash, wild things and buildings (Tree Boulder Brush Chest Silo WoodenFence ...), items for storage (Wood Stone Planks Bricks Weeds PotatoSeed ScrapMetal ...; crop names mean the crop, e.g. deposit(Corn, East)), True False None.
  • Not supported yet: tuples, classes, import, chained compares (a < b < c), inline x if y else z.
  • Safety caps: 64 nested function calls, 10,000-item lists, 10,000-character text.

Errors are friendly: misspell something and Poncho says e.g. "Did you mean 'print'?" with the line number. A failed action (like harvest() on an unripe crop) just returns False, Poncho says why, and the program keeps going.