Author Topic: Squirrel Scripting  (Read 10595 times)

VRocker

  • Liberty Unleashed Developer
  • Administrator
  • Full Member
  • ******
  • Posts: 342
  • Karma: +43/-15
    • View Profile
    • Madnight Software
Squirrel Scripting
« on: December 22, 2008, 12:36:11 pm »
Thought i'd make a topic on the scripting language used in Liberty Unleashed due to most of it being in the wish list.

LU uses Squirrel for scripting. Squirrel is easy to use and is designed specifically for game scripting.
I chose Squirrel due to it being similar in ways to Lua, but also having the syntax which is C-like. Once you learn Squirrel you will see it is a very powerful language and boasts many nice features.
Another reason why Squirrel was chosen is that its very easy to impliment. Being easy to impliment means i can spend less time messing around with the scripts and more time with the actual code.

One of its nice features is that i can make my own variable types and impliment them into the scripting (via SqPlus) which allows me to pass data to the scripts as Vectors or full classes, making less work for me but also keeping the scripts easy to use.

There is some documentation on Squirrels internal functions Here which is a modified version of the original document, but with the C++ stuff removed.

I will make an application to practice Squirrel on soon, instead of having to release the server. This should help in understanding it and why it has been chosen.


Rolan

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Squirrel Scripting
« Reply #1 on: December 22, 2008, 01:54:30 pm »
pls send here the gamemode from test server i want to trry squirell

VRocker

  • Liberty Unleashed Developer
  • Administrator
  • Full Member
  • ******
  • Posts: 342
  • Karma: +43/-15
    • View Profile
    • Madnight Software
Re: Squirrel Scripting
« Reply #2 on: December 22, 2008, 09:04:12 pm »
This is the script that was running before admin levels were implimented. I wont upload the admin script due to it being made by Juppi and not me.

Code: (squirrel) [Select]
function OnServerStart(  )
{
print( "Server Started: "+ GetServerName() );
}

function OnPlayerJoin( id, name )
{
MessagePlayer( "Welcome " + name + " to the LU testing session", id, 153, 255, 0 );
SetPlayerCash( id, 2000 );
}

function OnPlayerDeath( iID, iWep )
{
Message( "* " + GetPlayerName( iID ) + " killed himself. ("+GetWeaponName( iWep )+")", 255, 165, 0 );
local vPos = GetPlayerPos( iID );
local iCash = GetPlayerCash( iID );
CreateCashPickup( iCash, vPos.x + 1.75, vPos.y + 1.75, vPos.z );
SetPlayerCash( iID, 0 );
}

function OnPlayerKill( iKiller, iID, iWep, iBodyPart )
{
if ( iKiller == iID )
{
Message( "* " + GetPlayerName( iID ) + " killed himself. ("+GetWeaponName( iWep )+")", 255, 165, 0 );
local vPos = GetPlayerPos( iID );
local iCash = GetPlayerCash( iID );
CreateCashPickup( iCash, vPos.x + 1.75, vPos.y + 1.75, vPos.z );
SetPlayerCash( iID, 0 );
}
else
{
local iScore = GetPlayerScore( iKiller );
SetPlayerScore( iKiller, ( iScore + 1 ) );

local iCash = 1000;

local iKilledCash = GetPlayerCash( iID );
if ( iKilledCash > 0 )
{
//MessagePlayer( "!! You stole $" + iKilledCash + " from " + GetPlayerName( iID ) + " !!", iKiller, 102, 254, 255 );
//MessagePlayer( "!! " + GetPlayerName( iKiller ) + " stole " + iKilledCash + " from you !!", iID, 102, 254, 255 );
iCash = iCash + iKilledCash;
SetPlayerCash( iID, 0 );
}
//SetPlayerCash( iKiller, iCash );
local vPos = GetPlayerPos( iID );
CreateCashPickup( iCash, vPos.x + 1.75, vPos.y + 1.75, vPos.z );

if ( GetWeaponName( iWep ) == "Vehicle" )
{
local vehicle = GetPlayerVehicle( iKiller );
if ( vehicle )
{
if ( GetVehicleModel( vehicle ) == 126 ) Message( "* " + GetPlayerName( iKiller ) + " dodokilled "+GetPlayerName( iID ), 255, 165, 0 );
else Message( "* " + GetPlayerName( iKiller ) + " carkilled "+GetPlayerName( iID ), 255, 165, 0 );
}
else Message( "* " + GetPlayerName( iKiller ) + " carkilled "+GetPlayerName( iID ), 255, 165, 0 );
}
else Message( "* " + GetPlayerName( iKiller ) + " killed "+GetPlayerName( iID )+". ("+GetWeaponName( iWep )+")", 255, 165, 0 );
}
}

function OnPlayerCommand( iID, szCmd, szText )
{
if ( szCmd == "health" )
{
if ( szText != null )
{
local a = split( szText, " " );

local ID = 0;
if ( !IsNum( a[0] ) ) ID = GetPlayerID( a[0] );
else ID = a[0].tointeger();

local Armour = GetPlayerArmour( ID );
if ( Armour == 0 ) Message( "* " + GetPlayerName( ID ) + "'s Health: " + GetPlayerHealth( ID ) );
else Message( "* " + GetPlayerName( ID ) + "'s Health: " + GetPlayerHealth( ID ) + ", Armour: " + Armour );
}
else
{
local Armour = GetPlayerArmour( ID );
if ( Armour == 0 ) Message( "* " + GetPlayerName( iID ) + "'s Health: " + GetPlayerHealth( iID ) );
else Message( "* " + GetPlayerName( iID ) + "'s Health: " + GetPlayerHealth( iID ) + ", Armour: " + Armour );
}
}
else if ( szCmd == "mypos" )
{
local v = GetPlayerPos( iID );
Message( GetPlayerName( iID ) + " is currently at " + v.x + ", " + v.y + ", " + v.z );
}
else if ( szCmd == "goto" )
{
if ( szText != null )
{
local a = split( szText, " " );

local ID = 0;
if ( !IsNum( a[0] ) ) ID = GetPlayerID( a[0] );
else ID = a[0].tointeger();

if ( GetPlayerName( ID ) != "Unknown" )
{
local vPos = GetPlayerPos( ID );

Message( GetPlayerName( iID ) + " is teleporting to " + GetPlayerName( ID ) );
SetPlayerPos( iID, vPos );
}
}
}
else if ( szCmd == "cash" )
{
Message( GetPlayerName( iID ) + " has $" + GetPlayerCash( iID ) );
}
else if ( szCmd == "hpickup" )
{
local v = GetPlayerPos( iID );
Message( "Creating Pickup At: " + v.x + ", " + v.y + ", " + v.z );
local pickup = CreatePickup( 1362, 3, v.x, v.y, v.z );
}
else if ( szCmd == "apickup" )
{
local v = GetPlayerPos( iID );
Message( "Creating Pickup At: " + v.x + ", " + v.y + ", " + v.z );
local pickup = CreatePickup( 1364, 3, v.x, v.y, v.z );
}
else if ( szCmd == "stinger" )
{
local v = GetPlayerPos( iID );
MessagePlayer( "Spawning a Stinger...", iID );
CreateVehicle( VEH_STINGER, v.x + 5, v.y, v.z, GetPlayerAngle( iID ) );
}
else if ( szCmd == "banshee" )
{
local v = GetPlayerPos( iID );
MessagePlayer( "Spawning a Banshee...", iID );
CreateVehicle( VEH_BANSHEE, v.x + 5, v.y, v.z, GetPlayerAngle( iID ) );
}
else if ( szCmd == "dodo" )
{
local v = GetPlayerPos( iID );
MessagePlayer( "Spawning a Dodo...", iID );
CreateVehicle( VEH_DODO, v.x + 5, v.y, v.z, GetPlayerAngle( iID ) );
}
else if ( szCmd == "spawncar" )
{
if ( szText != null )
{
local a = split( szText, " " );

local ID = 90;
if ( IsNum( a[0] ) ) ID = a[0].tointeger();

if ( ( ID >= 90 ) && ( ID <= 150 ) )
{
local v = GetPlayerPos( iID );
MessagePlayer( "Spawning a vehicle with model ID " + ID + "...", iID );
CreateVehicle( ID, v.x + 5, v.y, v.z, GetPlayerAngle( iID ) );
}
}
}
}

function OnScriptLoad( )
{
print( "Script Loaded!" );
}

function OnScriptUnload( )
{
print( "Script Unloaded!" );
}
« Last Edit: December 22, 2008, 09:06:41 pm by VRocker »


[TDM]Relax

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Squirrel Scripting
« Reply #3 on: December 23, 2008, 01:21:44 am »
WoW, It's simple! :P

Windlord

  • Guest
Re: Squirrel Scripting
« Reply #4 on: December 23, 2008, 09:24:29 am »
orly?

Squirrel is really nice because VRocker can add in custom functions to the script and this makes it so much better since we won't need to spend time looking for alternative ways to do some stuff which could be solved easily by adding in a function into squirrel. (eg. irc echos)

BB101

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: Squirrel Scripting
« Reply #5 on: December 23, 2008, 10:45:11 am »
Bunnies > Squirrels

XAOC

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Squirrel Scripting
« Reply #6 on: December 23, 2008, 06:47:01 pm »
really easy scripting =)

rammar

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: Squirrel Scripting
« Reply #7 on: May 24, 2009, 05:49:07 pm »
please help some squirrel editor?? where is possibly to coulour syntax
If i am gonna die, I am gonna kill myself or take some drogs.....

Tamas

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
    • LCDM
Re: Squirrel Scripting
« Reply #8 on: June 01, 2009, 10:24:51 pm »
Use "Notepad+" you can use colour syntax with that.

MelKiY

  • Newbie
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Squirrel Scripting
« Reply #9 on: April 10, 2010, 06:55:08 pm »
woohoo easy :D
hello im MelKiY

BooMario

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
    • View Profile
Re: Squirrel Scripting
« Reply #10 on: May 18, 2010, 05:31:44 pm »
too easy code ^^

Windlord

  • Guest
Re: Squirrel Scripting
« Reply #11 on: May 18, 2010, 09:25:37 pm »
lol I can't wait to see posts with people asking for Squirrel scripting help.

.nuts ftw!

rammar

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: Squirrel Scripting
« Reply #12 on: May 19, 2010, 02:45:31 pm »
simple....is any list of functions? callbacks?
If i am gonna die, I am gonna kill myself or take some drogs.....

Force

  • Developer
  • Full Member
  • *****
  • Posts: 204
  • Karma: +6/-2
    • View Profile
Re: Squirrel Scripting
« Reply #13 on: May 19, 2010, 02:54:42 pm »
You will have a full list of functions and callbacks/signals available to you once we release LU, there's that many we sometimes forget what we have available. :P
« Last Edit: May 19, 2010, 03:37:05 pm by Force »
Quote
[Tue - 20:09:35] <&VRocker> CRAP!
[Tue - 20:09:43] <&VRocker> i think i just followed through...
Quote
[Sat - 22:11:56] <~Smapy> [R3V]breSt12 killed [R3V]Jack_Bauer. (Splat)

rammar

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: Squirrel Scripting
« Reply #14 on: May 19, 2010, 02:58:15 pm »
i think this will be best MP from unofficial gta series


- use many of SP things (pager, train. etc.)
- abnormaly good sync
VRocker and "his" team  is hero :D

GL, dont give up we are close :) :)
If i am gonna die, I am gonna kill myself or take some drogs.....

 

© Liberty Unleashed Team.