Angelscript is a programming language created in 2003 by Andreas Jönsson.
#596on PLDB | 21Years Old | 1kRepos |
AngelScript is a game-oriented interpreted compiled scripting language. AngelScript features static typing, object handles (similar to C++ pointers but garbage collected via reference counting), object-orientation, single inheritance, multiple inheritance with interfaces. Allows operators to be registered and overloaded. Read more on Wikipedia...
void main() { print("Hello World\n"); }
// Hello world in AngelScript
void main() { print("Hello world\n"); }
/*
* This is a sample script.
*/
#include "BotManagerInterface.acs"
BotManager::BotManager g_BotManager( @CreateDumbBot );
CConCommand@ m_pAddBot;
void PluginInit()
{
g_BotManager.PluginInit();
@m_pAddBot = @CConCommand( "addbot", "Adds a new bot with the given name", @AddBotCallback );
}
void AddBotCallback( const CCommand@ args )
{
if( args.ArgC() < 2 )
{
g_Game.AlertMessage( at_console, "Usage: addbot <name>" );
return;
}
BotManager::BaseBot@ pBot = g_BotManager.CreateBot( args[ 1 ] );
if( pBot !is null )
{
g_Game.AlertMessage( at_console, "Created bot " + args[ 1 ] + "\n" );
}
else
{
g_Game.AlertMessage( at_console, "Could not create bot\n" );
}
}
final class DumbBot : BotManager::BaseBot
{
DumbBot( CBasePlayer@ pPlayer )
{
super( pPlayer );
}
void Think()
{
BotManager::BaseBot::Think();
// If the bot is dead and can be respawned, send a button press
if( Player.pev.deadflag >= DEAD_RESPAWNABLE )
{
Player.pev.button |= IN_ATTACK;
}
else
Player.pev.button &= ~IN_ATTACK;
KeyValueBuffer@ pInfoBuffer = g_EngineFuncs.GetInfoKeyBuffer( Player.edict() );
pInfoBuffer.SetValue( "topcolor", Math.RandomLong( 0, 255 ) );
pInfoBuffer.SetValue( "bottomcolor", Math.RandomLong( 0, 255 ) );
if( Math.RandomLong( 0, 100 ) > 10 )
Player.pev.button |= IN_ATTACK;
else
Player.pev.button &= ~IN_ATTACK;
for( uint uiIndex = 0; uiIndex < 3; ++uiIndex )
{
m_vecVelocity[ uiIndex ] = Math.RandomLong( -50, 50 );
}
}
}
BotManager::BaseBot@ CreateDumbBot( CBasePlayer@ pPlayer )
{
return @DumbBot( pPlayer );
}
and abstract* auto bool break case cast class const continue default do double else enum false final* float for from* funcdef get* if import in inout int interface int8 int16 int32 int64 is mixin namespace not null or out override* private protected return set* shared* super* switch this* true typedef uint uint8 uint16 uint32 uint64 void while xor * ** / % + - <= < >= > ( ) == != ? : = += -= *= /= %= **= ++ -- & , { } ; | ^ ~ << >> >>> &= |= ^= <<= >>= >>>= . && || ! [ ] ^^ @ !is :: 123456789 123.123e123 123.123e123f 0x1234FEDC 0d123987 0o1276 0b1010 'abc' "abc" """heredoc""" _Abc123 // /* */
Feature | Supported | Example | Token |
---|---|---|---|
Conditionals | ✓ | ||
Switch Statements | ✓ | ||
Constants | ✓ | ||
Classes | ✓ | ||
While Loops | ✓ | ||
Booleans | ✓ | true false | |
MultiLine Comments | ✓ | /* A comment */ | /* */ |
Print() Debugging | ✓ | ||
Comments | ✓ | // A comment | |
Line Comments | ✓ | // A comment | // |
Semantic Indentation | X |