Introduction to ApeScript - Contents - ApeScript Notes

## THE APESCRIPT INTERFACE INTO THE APESDK

Variables automatically defined in ApeScript run in Simulated Ape.

Variable | Type | Notes |  |
random | output | special - produces a 16-bit random number
vector_angle | input/output | values from 0 to 255 with wrap-around (for greater values)
vector_x | output | based on vector_angle (-840 to 840)
vector_y | output | based on vector_angle (-840 to 840)
| Land |
test_x | input/output |
test_y | input/output |
test_z | output | based on test_x and test_y, provides numerical land height
time | output | constant dt - numerical 24 hour time in minutes (see File Format)
date | output | constant dt - numerical date in days (see File Format)
weather | output | based on test_x and test_y, weather value and time of day/night - Daytime Sun(0), Daytime Cloudy(1), Daytime Rain(2), Nighttime Sun(3), Nighttime Cloudy(4), Nighttime Rain(5), Sunrise/Sunset(6)
water_level | output | constant - the numerical water level (from z height)
| Being |
number_beings | output | constant dt
current_being | output | constant db
select_being | input/output | set to current_being initially
location_x | output | based on select_being (see File Format)
location_y | output | based on select_being (see File Format)
location_z | output | based on location_x and location_y (ie select_being), provides numerical land height
id_number | output | based on select_being (see File Format)
date_of_birth | output | based on select_being (see File Format)
state | output | based on select_being (see File Format)
listen | output | based on select_being from speak (see File Format)
facing | i/o being | NOT based on select_being (see File Format)
speed | i/o being | NOT based on select_being (see File Format)
energy | i/o being | NOT based on select_being (see File Format)
honor | i/o being | NOT based on select_being (see File Format)
parasites | i/o being | NOT based on select_being (see File Format)
height | i/o being | NOT based on select_being (see File Format)
family_name1 | i/o being | NOT based on select_being (see File Format)
family_name2 | i/o being | NOT based on select_being (see File Format)
goal_type | i/o being | NOT based on select_being (see File Format)
goal_x | i/o being | NOT based on select_being (see File Format)
goal_y | i/o being | NOT based on select_being (see File Format)
drive_hunger | i/o being | NOT based on select_being (see File Format)
drive_social | i/o being | NOT based on select_being (see File Format)
drive_fatigue | i/o being | NOT based on select_being (see File Format)
drive_sex | i/o being | NOT based on select_being (see File Format)
speak | i/o being | NOT based on select_being, to be spoken next dt (see File Format)
hungry | output | constant - the numerical hunger level (from energy)
is_visible | output | based on location_x, location_y, facing, test_x and test_y - shows if the test point is visible (NOTE the distinction between location_x/location_y vs facing if select_being != current_being, is_visible will allow this but it won't produce the desired results)
brain_value | i/o being | based on brain_x, brain_y and brain_z
brain_x | input/output |
brain_y | input/output |
brain_z | input/output |
| Biology |
biology_operator | input/output |
biology_output | output | based on test_x, test_y and biology_operator
biology_area | output |
biology_height | output |
biology_water | output |
biology_moving_sun | output |
biology_total_sun | output |
biology_bush | output |
biology_grass | output |
biology_tree | output |
biology_insect | output |
biology_mouse | output |
biology_parrot | output |
biology_lizard | output |
biology_eagle | output |
| Key
| constant | remains the same
| constant db | constant for one being in this time cycle
| constant dt | constant for all beings in this time cycle
| input/output | can be read from and written to
| i/o being | like input/output but set to and from the being
| output | can only be read from, not written to
| special | generated every time it is called

## APESCRIPT ERRORS THAT CAN BE REPORTED IN THE SIMULATION

This list shows some of the errors provided by ApeScript and their potential causes. (This document is due for an update with a full list of all the errors.)

Error | Help Text Unknown error | Please contact tom at apesim dot io
Number expected | A non-numeric character is included in a number string.
Number out of range | Number does not fit in the range
Maximum numbers reached | Please contact tom at apesim dot io
Maximum script size reached | Please contact tom at apesim dot io
Maximum variables reached | Please contact tom at apesim dot io
Unknown syntax (parser buffer) | Syntax is incorrect
Unknown syntax (parser convert) | Syntax is incorrect
Selected entity out of range | Selected entity is outside the bounds of the number of entities.
Coordinates out of range | Coordinates outside the prescribed range.
Value out of range | Value outside the presecribed range.
Too many } | You have closed too many braces. Go back to the code and see if there is an erroneous additional } in the code.
Maximum braces reached | Please contact tom at apesim dot io
First value failed | Something is wrong with the first value of an equality, if or while operation. It could be the first and only value in this function.
Second value failed | Something is wrong with the second number/variable value of an equality, if or while operation.
Unknown syntax (missing =) | Syntax is incorrect
Unknown syntax (no command) | Syntax is incorrect
Wrong end | A bracket or colon was expected but not found.
Line start incorrect | A line of code begins incorrectly. It could start with a number or an operator when if/while or a variable was expected.
Output set as input variable | An output only variable is attempting to be set.
if/while not followed by { | All if/while statements require a bracket following the if/while (allowing for any amount of whitespace too).
Function isn't variable | Function must not be a special term.
Non-function applied | Expecting a function.
Function defined prior | Single function definition only.
Function out of range | Function defined outside the range of the code presented.
Without ; | Semi-colon required.
Without { | All if/while statements expect what is executed through the bracket enclosed statement being correct to be followed by inclusive braces { }. There is no single line if or while statements without { } in ApeScript.
Function setting failed | Function could not be set.
Error starting main | Main could not be started.
Code after main | All the code in ApeScript must exist before the end of main.
No } to end of file | Based on the final main function it is expected that the last meaningful character will be }.
Code outside function | All code in ApeScript needs to exist within functions.
Input variable without equals | All variables set require an equals following the variable.
Assign value failed | Something is wrong with the variable set by an equality.
Unknown syntax (from interpret) | Syntax is incorrect
No main code | ApeScript requires a main function.

Introduction to ApeScript - Contents - ApeScript Notes