User:Gilbert189/Babalang+

From Esolang
Jump to navigation Jump to search
This article is just a draft. See User:Gilbert189#Drafts for more info.

Babalang+ (or Babalang Plus) is an extension of Babalang, an esolang that uses Baba is You-like rules.

3D: 3D objects

BABA IS 3D // 8-bit integer 3-tuple

BABA IS FRONT AND MOVE // +Z direction
BABA IS BACK AND MOVE  // -Z direction
// Using NOT reverses the direction

// TODO: Better names
BABA IS TURN       // XY rotation
BABA IS TURN_PITCH // YZ rotation
BABA IS TURN_YAW   // XZ rotation

// The following also applies to WRITE, SHIFT, FALL, and SLEEP
BABA IS LEFT AND TEXT  // outputs X value
BABA IS UP AND TEXT    // outputs Y value
BABA IS FRONT AND TEXT // outputs Z value

Default values of IMAGEs

The first ever syntactic sugar of Babalang (plus)?

SKULL IS IMAGE
    SKULL HAS BABA AND KEKE

    BABA IS YOU AND MOVE

    SKULL IS LEVEL
        SKULL HAS ME
        // ...
    SKULL IS DONE

    KEKE IS LEVEL
        // ...
    KEKE IS DONE
SKULL IS DONE

Levelpacks

KEKE IS LEVEL
    KEKE HAS ME AND IT
    FOFO IS ME AND IT
    KEKE MAKE FOFO
KEKE IS DONE

ME IS LEVEL AND HIDE // Hidden objects cannot be imported.
    ME HAS BABA
    BABA IS TEXT
ME IS DONE

LEVEL IS BABA // Defines the levelpack name.
              // If LEVEL IS ... is present in the last parsed
              // rule, the file is considered a levelpack.
              // This statement must only be added as the last
              // rule, otherwise an error will be thrown.

Using levelpacks

LEVEL HAS BABA // Import the BABA levelpack. (NOT does nothing)
BABA MAKE KEKE // Import KEKE from the BABA levelpack. (NOT does nothing)
ME IS YOU AND MOVE
KEKE HAS ME AND ME
KEKE IS POWER AND TEXT // prints ASCII 0x02

Searching for levelpacks

Upon executing, the interpreter will search for all files with the extensions .babaplus or .bbp or all sub-directories on the main directory. Files take priority over directories. Caching may be done to ease future executions.

Files

The file name doesn't matter when it's being imported (although a warning is given if it doesn't correspond with the levelpack name).

Directory

All directory levelpacks must have a LEVEL.babaplus (or LEVEL.bbp) file on them (case insensitive). All objects (except hidden ones) defined in that file are available to import. The directory name will be the name of the levelpack.

Invalid levelpack names or levelpacks without the LEVEL file will not be considered (a warning may be given if found).

Standard levelpacks

This section is incomplete. It also needs to be split into their separate pages.

COMPUTER: Operating system interface

ENV IS IMAGE

A special IMAGE which contains the process environment variables.

When the currently FOLLOWed attribute is EATen, this will automatically modify the environment variable (the contents are not consumed). Similarly, MAKEing it will query the environment variable and assignes a GROUP of YOU objects to the variable in statement.

Note that ENV may only EAT GROUP of YOU objects. If given an object that's not a GROUP, or if any of the elements of GROUP aren't a YOU object, an error will be thrown.

SHELL IS LEVEL AND HAS ARGS

A LEVEL object that executes a shell command. ARGS should be a GROUP of YOU objects.

TAPE IS IMAGE AND HAS NAME AND MODE
FILE MIMIC TAPE

An IMAGE object that can read, write, and modify files. NAME should be a GROUP of YOU objects, and MODE should either be a YOU or YOU2 object. Depending on the MODE argument, the file would be:

  • opened for reading if it's FACING UP;
  • opened for writing if it's FACING DOWN; or
  • opened for appending if it's FACING RIGHT

This IMAGE defines the following attributes:

  • MOTOR, which controls the file pointer. MOTOR MAKEs a YOU2 object that returns the position of the file pointer (wrapping around).
    When MOTOR EATs a YOU or YOU2 object, the file pointer is:
    • decremented by their X position if it's FACING LEFT;
    • incremented by their X position if it's FACING RIGHT;
    • set to their X position forward from the starting position if it's FACING UP; and
    • set to their X position back from the end position if it's FACING DOWN.
  • CURSOR, which reads and writes a unit to/from the file. When CURSOR EATs a unit, it is written to the file. CURSOR MAKEs a unit, reading it from the file. Doing either of those will advance the file pointer.
    What constitutes a unit is dependent by the MODE argument.
    • If its Y position is 0, the unit would use the X position to store the value.
    • Else if its X position is 0, the unit would use the Y position to store the value.
    • If none of its axis components are 0, the unit would use both the X and Y position to store the value, largest component first.
    • The object type of the unit is equal to the MODE argument.

4D: 4D objects

LEVEL HAS 4D

BABA IS 4D // 8-bit integer 4-tuple
BABA IS ANA AND MOVE  // +W direction
BABA IS KATA AND MOVE // -W direction
// Using NOT reverses the direction

// TODO: Better names
BABA IS TURN       // XY rotation
BABA IS TURN_PITCH // YZ rotation
BABA IS TURN_YAW   // XZ rotation
BABA IS TURN_WHEEL // XW rotation
BABA IS TURN_HEAVE // YW rotation
BABA IS TURN_CHASE // ZW rotation
// Using Greek names
BABA IS TURN_CYLIND // XW rotation
BABA IS TURN_VOLLEY // YW rotation
BABA IS TURN_CUNIGO // ZW rotation

// The following also applies to WRITE, SHIFT, FALL, and SLEEP
BABA IS LEFT AND TEXT  // outputs X value
BABA IS UP AND TEXT    // outputs Y value
BABA IS FRONT AND TEXT // outputs Z value
BABA IS ANA AND TEXT   // outputs W value

META: Custom word definitions

LEVEL HAS META
META MAKE METHOD

STRAFE_LEFT IS LEVEL
	STRAFE_LEFT HAS OBJECT
	OBJECT IS NOT TURN
	OBJECT IS MOVE
	OBJECT IS TURN
STRAFE_LEFT IS DONE
METHOD HAS STRAFE_LEFT AND IS POWER

BABA IS YOU
BABA IS STRAFE_LEFT