Aos

Introduction

aos is a different approach to building Processes or Contracts, the ao computer is a decentralized computer network that allows compute to run anywhere and aos in a unique interactive shell. You can use aos as your personal operating system, your development environment for building ao Processes, and your bot Army.

Lets go over some basic commands.

Variables

If you want to display the contents of any variable through the console, simply type the variable name.

Name

Inbox

the Inbox is a collection of messages that your Process has received.

Inbox[1]

If you want to get a count of messages, just add the # infront of Inbox.

#Inbox

The process of checking how many messages are in the inbox is a very common pattern. To make this easier, you can create a function that returns the number of messages within the inbox and displays it in the prompt.

Use either .editor or .load file to load this function on your process.

function Prompt()
  return "Inbox: " .. #Inbox .. " > "
end

The Expected Results:

undefined
Inbox: 2 >

Your prompt now has changed to include the number of messages in your inbox.

Globals

In aos process there are some Globals that can make development a little more intuitive.

NameDescriptionType
InboxThis is a lua Table that stores all the messages that are received and not handlers by any handlers.Table(Array)
Send(Message)This is a global function that is available in the interactive environment that allows you to send messages to Processesfunction
Spawn(Module, Message)This is a global function that is available in the aos interactive environment that allows you to spawn processes
Namea string that is set on init that describes the name of your processstring
Ownera string that is set on the init of the process that documents the owner of the process, warning if you change this value, it can brick you ability to interact with your processstring
Handlersa lua Table that contains helper functions that allows you to create handlers that execute functionality based on the pattern matching function on inbound messagestable
Dumpa function that takes any lua Table and generates a print friendly output of the datafunction
Utilsa functional utility library with functions like map, reduce, filtermodule
aothis is a core function library for sending messages and spawing processesmodule

Modules

In aos there are some built in common lua modules that are already available for you to work with, these modules can be referenced with a "require" function.

NameDescription
jsona json module that allows you to encode and decode json documents
aocontains ao specific functions like send and spawn
.base64a base64 module that allows you to encode and decode base64 text
.prettya pretty print module using the function tprint to output formatted syntax
.utilsan utility function library

Copyright © 2024