backExamples

Xelagot action script

NaughtsAndCrosses Bot

Tic-Tac-Toe



International Version
This version has been re-written, to allow playing in different languages. There are two copies of the script, one for bots without eminent domain, and one for bots with ED. Only the version without ED is printed here, both versions can be downloaded at the bottom of this page. Note that the zipped versions (you must unzip them first, of course) will run automatically when loaded by the bot. If you wish to stop that, edit the script and put a # sign in front of the word Run in the [Settings] section, as you see it on this page.
Preparation
Check Sub Init in the script. All the specs have been put there, so if you need to change any of them, that's the place to look. If you want to use a different language, you need to have the language strings file in the same folder as the script, and change the name of the file in Sub Init section:
$StringFile = "N&CStrings_UK.txt"
to the name of the file you are using to replace N&CStrings_UK.txt. This file, by the way, can serve as a model for other languages.

If you use the script as it is, without modifying it, you will need to have 3 signs for notices, and 9 signs for the board.

The signs for notices need the following in the Action line:

  1. create name not1, sign
  2. create name not2, sign
  3. create name not3, sign
After the word 'sign', you can add the 'color' etc.

The 9 signs used for the board need the following in the Action line:

  1. create name sq1,
  2. create name sq2,
  3. create name sq3,
  4. create name sq4,
  5. create name sq5,
  6. create name sq6,
  7. create name sq7,
  8. create name sq8,
  9. create name sq9,
After the comma, you will need to add the word 'sign' to create a sign. The word 'sign' may be followed by other commands, for example: create name sq1, sign bcolor=white color=black.

These objects are placed so:
sq1 sq4 sq7
sq2 sq5 sq8
sq3 sq6 sq9
or so:
sq1 sq2 sq3
sq4 sq5 sq6
sq7 sq8 sq9

The model of these playboard objects must also be specified. The default for all is sign3.rwx. That can be changed: you may change it in Sub Init. There are 3 models specified, one for an empty square: $Empty, one for a square with an "X": $Cross, and one with a square with a "O": $Naught. If you use signs, all 3 models must be identical. You do not have to use signs: you may use custom objects, with the appropriate symbols on them. If you do so, change the name of the models in Sub Init and make sure the Action line matches the lines specified in $sq1 etc... (mind the comma). You would then need to build your set using the $Empty model (or any other of the 3). Here you can download a 1m x 1m sign, made specially for this script: it is called sgn1x1.rwx. If you use it, change these lines in the script to this:

  $Empty  = "sgn1x1.rwx"
  $Naught = "sgn1x1.rwx"
  $Cross  = "sgn1x1.rwx"

The bot must be near these objects, and must belong to the same citizen as the objects unless you use the ED script. The owner of bot and objects must have build right.

Script
The scripts can be downloaded at the bottom of this page. Here below is the script for bots with build rights.
[Head]
Type=Script
Version=2.0

[Settings]
Origin=0.000n 0.000w 0.00a 0.0
#Run

[Script]
                         ###################################
                         #   The NaughtsAndCrosses Bot     #
                         #         (Tic-Tac-Toe)           #
                         #        a Xelagot script         #
                         # (c) 2000 Alex Grigny de Castro  #
                         ###################################

   ##################################################################
   ###### Requires Xelagot 2.9999916 or higher
   ###### Help: www.imatowns.com/xelagot/xlgasex_naughtsncrosses.html
   ##################################################################

# the specs used in this script are in Sub Init

var @centre
# not1, not2 and not3 are the notice boards, 
# the others are the squares on the board
var $not1, $not2, $not3
var $sq1, $sq2, $sq3
var $sq4, $sq5, $sq6
var $sq7, $sq8, $sq9
var ~not1, ~not2, ~not3
var ~sq1, ~sq2, ~sq3
var ~sq4, ~sq5, ~sq6
var ~sq7, ~sq8, ~sq9

var %square
var %Moves
var $Empty, $Naught, $Cross, $Models
var $Notice1Desc, $Notice2Desc, $Notice3Desc
var %Citnum, %Error
var /s_Xrows, /s_Nrows
var &XPlayer, &NPlayer, &Turn
var %XPlayer, %NPlayer, %Turn
var $XPlayer, $NPlayer, $Turn
var $TurnDesc
var %Players
var %IsQuerying
var %GameStage

var /s_temp, $StringFile
var $s1, $s2, $s3, $s4, $s5, $s6, $s7, $s8, $s9
var $w1, $w2, $w3
var $e1, $e2, $e3, $e4
var $a1, $a2, $a3, $a4
var $b1
var $c1, $c2, $c3, $c4, $c5, $c6, $c7

Label Scan
  OnWorldEnterEvent WorldEnter
  OnWorldReconnectEvent Reconnect
  Gosub Init
  OnQueryCompleteEvent QueryComplete
  Gosub ScanArea
Label Query
  IfInt %IsQuerying = 1 Goto Query
  Gosub GetSigns
  # e1=sign(s) not found...
  IfInt %Error > 0 SayConcat %Error " " $e1
  Else Goto More1
End
Label More1
  # s3=Found signs
  SayConcat $s3
  Gosub GetNotice1
  # e2=Notice1 board not found...
  IfInt %Error > 0 SayConcat $e2
  Else Goto More2
End
Label More2
  Gosub GetNotice2
  # e3=Notice2 board not found...
  IfInt %Error > 0 SayConcat $e3
  Else Goto More3
End
Label More3
  Gosub GetNotice3
  # e4=Notice3 board not found...
  IfInt %Error > 0 SayConcat $e4
  Else Goto More
End

Label More
  OnAvatarDeleteEvent AvatarDelete
  IfInt %GameStage = 3 Goto Wait
Label Register
  OnObjectClickEvent
  %GameStage = 1
  %Players = 0
  Gosub ClearLists
  Gosub GetSigns
  Gosub ClearSigns
  Gosub GetNotice1
  # a1=Click here to register
  Concat $Notice1Desc $a1
  Gosub SetNotice1
  Gosub GetNotice2
  # b1=Players:
  Concat $Notice2Desc $b1 #13 #10 "X = ?" #13 #10 "0 = ?"
  Gosub SetNotice2
  Gosub GetNotice3
  # c1=No players...
  Concat $Notice3Desc $c1
  Gosub SetNotice3
  OnObjectClickEvent Register1Click
Label RegisterLoop
  IfInt %GameStage = 1 Goto RegisterLoop

Label Play
  OnObjectClickEvent GameClick
Label PlayLoop
  IfInt %GameStage = 2 Goto PlayLoop

Label Wait
  OnObjectClickEvent WaitClick
Label WaitLoop
  IfInt %Gamestage = 3 Goto WaitLoop
  Goto Register
End

Sub Init
  GetCitnum %Citnum
  GetPosition @centre
  # 'create name' in the objects
  $not1 = "name not1,"
  $not2 = "name not2,"
  $not3 = "name not3,"
  $sq1 = "name sq1,"
  $sq2 = "name sq2,"
  $sq3 = "name sq3,"
  $sq4 = "name sq4,"
  $sq5 = "name sq5,"
  $sq6 = "name sq6,"
  $sq7 = "name sq7,"
  $sq8 = "name sq8,"
  $sq9 = "name sq9,"
  $Empty  = "sign3.rwx"
  $Naught = "sign3.rwx"
  $Cross  = "sign3.rwx"
  Concat $Models $Empty "," $Naught "," $Cross
  Gosub ClearLists

  $StringFile = "N&CStrings_UK.txt"
  SListLoad /s_temp $StringFile %r
  IfInt %r <> 0 SListSetText /s_temp Strings
  SListGetValue /s_temp "s1" $s1
  SListGetValue /s_temp "s2" $s2
  SListGetValue /s_temp "s3" $s3
  SListGetValue /s_temp "s4" $s4
  SListGetValue /s_temp "s5" $s5
  SListGetValue /s_temp "s6" $s6
  SListGetValue /s_temp "s7" $s7
  SListGetValue /s_temp "s8" $s8
  SListGetValue /s_temp "s9" $s9
  SListGetValue /s_temp "w1" $w1
  SListGetValue /s_temp "w2" $w2
  SListGetValue /s_temp "w3" $w3
  SListGetValue /s_temp "e1" $e1
  SListGetValue /s_temp "e2" $e2
  SListGetValue /s_temp "e3" $e3
  SListGetValue /s_temp "e4" $e4
  SListGetValue /s_temp "a1" $a1
  SListGetValue /s_temp "a2" $a2
  SListGetValue /s_temp "a3" $a3
  SListGetValue /s_temp "a4" $a4
  SListGetValue /s_temp "b1" $b1
  SListGetValue /s_temp "c1" $c1
  SListGetValue /s_temp "c2" $c2
  SListGetValue /s_temp "c3" $c3
  SListGetValue /s_temp "c4" $c4
  SListGetValue /s_temp "c5" $c5
  SListGetValue /s_temp "c6" $c6
  SListGetValue /s_temp "c7" $c7
EndSub

Sub ScanArea
  # s1=Please wait, scanning area...
  SayConcat $s1
  %IsQuerying = 1
  QueryAt @Centre
EndSub

Event QueryComplete
  # s2=Finished scanning :)
  SayConcat $s2
   %IsQuerying = 0
EndEvent

Event Reconnect
  # s4=Got disconnected... I'm back now... Starting all over :(
  SayConcat $s4
  ResetTo Scan
EndEvent

Event WorldEnter
  ResetTo Scan
EndEvent

Sub GetSigns
  %Error = 0
  FilterClear
  ResClear
  FilterModel $Models
  FilterAction $sq1
  FilterCitizen %Citnum
  ResFromSurveyFilter
  IfGetResObjectItem ~sq1 1
  Else Inc %Error

  FilterClear
  ResClear
  FilterModel $Models
  FilterAction $sq2
  FilterCitizen %Citnum
  ResFromSurveyFilter
  IfGetResObjectItem ~sq2 1
  Else Inc %Error

  FilterClear
  ResClear
  FilterModel $Models
  FilterAction $sq3
  FilterCitizen %Citnum
  ResFromSurveyFilter
  IfGetResObjectItem ~sq3 1
  Else Inc %Error

  FilterClear
  ResClear
  FilterModel $Models
  FilterAction $sq4
  FilterCitizen %Citnum
  ResFromSurveyFilter
  IfGetResObjectItem ~sq4 1
  Else Inc %Error

  FilterClear
  ResClear
  FilterModel $Models
  FilterAction $sq5
  FilterCitizen %Citnum
  ResFromSurveyFilter
  IfGetResObjectItem ~sq5 1
  Else Inc %Error

  FilterClear
  ResClear
  FilterModel $Models
  FilterAction $sq6
  FilterCitizen %Citnum
  ResFromSurveyFilter
  IfGetResObjectItem ~sq6 1
  Else Inc %Error

  FilterClear
  ResClear
  FilterModel $Models
  FilterAction $sq7
  FilterCitizen %Citnum
  ResFromSurveyFilter
  IfGetResObjectItem ~sq7 1
  Else Inc %Error

  FilterClear
  ResClear
  FilterModel $Models
  FilterAction $sq8
  FilterCitizen %Citnum
  ResFromSurveyFilter
  IfGetResObjectItem ~sq8 1
  Else Inc %Error

  FilterClear
  ResClear
  FilterModel $Models
  FilterAction $sq9
  FilterCitizen %Citnum
  ResFromSurveyFilter
  IfGetResObjectItem ~sq9 1
  Else Inc %Error
EndSub

Sub ClearSigns
  # do not call from an event handler
  # as the object number will not be refreshed correctly
  
  Suspend

  ~a = ~sq1
  $b = ""
  GetModel ~a $Empty
  GetDescription ~a $b
  ObjectModify ~sq1 ~a
  ~sq1 = ~a 

  ~a = ~sq2
  GetModel ~a $Empty
  GetDescription ~a $b
  ObjectModify ~sq2 ~a
  ~sq2 = ~a 

  ~a = ~sq3
  GetModel ~a $Empty
  GetDescription ~a $b
  ObjectModify ~sq3 ~a
  ~sq3 = ~a 

  ~a = ~sq4
  GetModel ~a $Empty
  GetDescription ~a $b
  ObjectModify ~sq4 ~a
  ~sq4 = ~a 

  ~a = ~sq5
  GetModel ~a $Empty
  GetDescription ~a $b
  ObjectModify ~sq5 ~a
  ~sq5 = ~a 

  ~a = ~sq6
  GetModel ~a $Empty
  GetDescription ~a $b
  ObjectModify ~sq6 ~a
  ~sq6 = ~a 

  ~a = ~sq7
  GetModel ~a $Empty
  GetDescription ~a $b
  ObjectModify ~sq7 ~a
  ~sq7 = ~a 

  ~a = ~sq8
  GetModel ~a $Empty
  GetDescription ~a $b
  ObjectModify ~sq8 ~a
  ~sq8 = ~a 

  ~a = ~sq9
  GetModel ~a $Empty
  GetDescription ~a $b
  ObjectModify ~sq9 ~a
  ~sq9 = ~a 
  
  Do
EndSub

Sub GetNotice1
  %Error = 0
  FilterClear
  ResClear
  FilterAction $not1
  FilterCitizen %Citnum
  ResFromSurveyFilter
  IfGetResObjectItem ~not1 1
  Else Inc %Error
EndSub

Sub SetNotice1
  # must be preceeded by a call to GetNotice1
  ~a = ~not1
  GetDescription ~a $Notice1Desc
  ObjectModify ~not1 ~a
EndSub

Sub GetNotice2
  %Error = 0
  FilterClear
  ResClear
  FilterAction $not2
  FilterCitizen %Citnum
  ResFromSurveyFilter
  IfGetResObjectItem ~not2 1
  Else Inc %Error
EndSub

Sub SetNotice2
  # must be preceeded by a call to GetNotice2
  ~a = ~not2
  GetDescription ~a $Notice2Desc
  ObjectModify ~not2 ~a
EndSub

Sub GetNotice3
  %Error = 0
  FilterClear
  ResClear
  FilterAction $not3
  FilterCitizen %Citnum
  ResFromSurveyFilter
  IfGetResObjectItem ~not3 1
  Else Inc %Error
EndSub

Sub SetNotice3
  # must be preceeded by a call to GetNotice3
  ~a = ~not3
  GetDescription ~a $Notice3Desc
  ObjectModify ~not3 ~a
EndSub

Text Rows
1=0,0,0,0,0,0,0,0
2=0,0,0,0,0,0,0,0
3=0,0,0,0,0,0,0,0
4=0,0,0,0,0,0,0,0
5=0,0,0,0,0,0,0,0
6=0,0,0,0,0,0,0,0
7=0,0,0,0,0,0,0,0
8=0,0,0,0,0,0,0,0
9=0,0,0,0,0,0,0,0
EndText

Sub ClearLists
  SListSetText /s_Xrows Rows
  SListSetText /s_Nrows Rows
EndSub

# these subs inscribe the position in the row for Naughts
Sub n1
  %w = 1
  SListSetFields /s_Nrows "1" 8 %w x x %w x x %w x
  Gosub NAdd
EndSub

Sub n2
  %w = 1
  SListSetFields /s_Nrows "2" 8 %w x x x %w x x x
  Gosub NAdd
EndSub

Sub n3
  %w = 1
  SListSetFields /s_Nrows "3" 8 %w x x x x %w x %w
  Gosub NAdd
EndSub

Sub n4
  %w = 1
  SListSetFields /s_Nrows "4" 8 x %w x %w x x x x
  Gosub NAdd
EndSub

Sub n5
  %w = 1
  SListSetFields /s_Nrows "5" 8 x %w x x %w x %w %w
  Gosub NAdd
EndSub

Sub n6
  %w = 1
  SListSetFields /s_Nrows "6" 8 x %w x x x %w x x
  Gosub NAdd
EndSub

Sub n7
  %w = 1
  SListSetFields /s_Nrows "7" 8 x x %w %w x x x %w
  Gosub NAdd
EndSub

Sub n8
  %w = 1
  SListSetFields /s_Nrows "8" 8 x x %w x %w x x x
  Gosub NAdd
EndSub

Sub n9
  %w = 1
  SListSetFields /s_Nrows "9" 8 x x %w x x %w %w x
  Gosub NAdd
EndSub

Sub NAdd
  SListAddField /s_Nrows 1 %i
  IfInt %i > 2 Goto NAddDone 
  SListAddField /s_Nrows 2 %i
  IfInt %i > 2 Goto NAddDone 
  SListAddField /s_Nrows 3 %i
  IfInt %i > 2 Goto NAddDone 
  SListAddField /s_Nrows 4 %i
  IfInt %i > 2 Goto NAddDone 
  SListAddField /s_Nrows 5 %i
  IfInt %i > 2 Goto NAddDone 
  SListAddField /s_Nrows 6 %i
  IfInt %i > 2 Goto NAddDone 
  SListAddField /s_Nrows 7 %i
  IfInt %i > 2 Goto NAddDone 
  SListAddField /s_Nrows 8 %i
  IfInt %i > 2 Goto NAddDone 
  Inc %Moves
  IfInt %Moves >= 9 Gosub GameDraw
  IfInt %Moves >= 9 EndSub
  &Turn = &XPlayer
  %Turn = %XPlayer
  $Turn = $XPlayer
  $TurnDesc = "X"
  Gosub GetNotice3
  # c2=Playing now:
  Concat $Notice3Desc $c2 #13 #10 $Turn
  Gosub SetNotice3
EndSub
Label NAddDone
  # Naughts has won!
  %GameStage = 3
  # a2=Click here for new game
  Concat $Notice1Desc $a2
  Gosub SetNotice1
  Gosub GetNotice3
  # c3=Winner:
  Concat $Notice3Desc $c3 #13 #10 $NPlayer
  Gosub SetNotice3
  # s5=Game between {x} and {n} was won by... {y}
  $s = $s5
  Replace $s $s "{x}" $XPlayer
  Replace $s $s "{n}" $NPlayer
  Replace $s $s "{y}" $NPlayer
  SayConcat $s
EndSub

# these subs inscribe the position in the row for Crosses
Sub x1
  %w = 1
  SListSetFields /s_Xrows "1" 8 %w x x %w x x %w x
  Gosub xAdd
EndSub

Sub x2
  %w = 1
  SListSetFields /s_Xrows "2" 8 %w x x x %w x x x
  Gosub xAdd
EndSub

Sub x3
  %w = 1
  SListSetFields /s_Xrows "3" 8 %w x x x x %w x %w
  Gosub xAdd
EndSub

Sub x4
  %w = 1
  SListSetFields /s_Xrows "4" 8 x %w x %w x x x x
  Gosub xAdd
EndSub

Sub x5
  %w = 1
  SListSetFields /s_Xrows "5" 8 x %w x x %w x %w %w
  Gosub xAdd
EndSub

Sub x6
  %w = 1
  SListSetFields /s_Xrows "6" 8 x %w x x x %w x x
  Gosub xAdd
EndSub

Sub x7
  %w = 1
  SListSetFields /s_Xrows "7" 8 x x %w %w x x x %w
  Gosub xAdd
EndSub

Sub x8
  %w = 1
  SListSetFields /s_Xrows "8" 8 x x %w x %w x x x
  Gosub xAdd
EndSub

Sub x9
  %w = 1
  SListSetFields /s_Xrows "9" 8 x x %w x x %w %w x
  Gosub xAdd
EndSub

Sub xAdd
  SListAddField /s_Xrows 1 %i
  IfInt %i > 2 Goto XAddDone 
  SListAddField /s_Xrows 2 %i
  IfInt %i > 2 Goto XAddDone 
  SListAddField /s_Xrows 3 %i
  IfInt %i > 2 Goto XAddDone 
  SListAddField /s_Xrows 4 %i
  IfInt %i > 2 Goto XAddDone 
  SListAddField /s_Xrows 5 %i
  IfInt %i > 2 Goto XAddDone 
  SListAddField /s_Xrows 6 %i
  IfInt %i > 2 Goto XAddDone 
  SListAddField /s_Xrows 7 %i
  IfInt %i > 2 Goto XAddDone 
  SListAddField /s_Xrows 8 %i
  IfInt %i > 2 Goto XAddDone 
  Inc %Moves
  IfInt %Moves >= 9 Gosub GameDraw
  IfInt %Moves >= 9 EndSub
  &Turn = &NPlayer
  %Turn = %NPlayer
  $Turn = $NPlayer
  $TurnDesc = "O"
  Gosub GetNotice3
  # c2=Playing now:
  Concat $Notice3Desc $c2 #13 #10 $Turn
  Gosub SetNotice3
EndSub
Label XAddDone
  # Crosses has won!
  %GameStage = 3
  # a2=Click here for new game
  Concat $Notice1Desc $a2
  Gosub SetNotice1
  Gosub GetNotice3
  # c3=Winner:
  Concat $Notice3Desc $c3 #13 #10 $XPlayer
  Gosub SetNotice3
  # s5=Game between {x} and {n} was won by... {y}
  $s = $s5
  Replace $s $s "{x}" $XPlayer
  Replace $s $s "{n}" $NPlayer
  Replace $s $s "{y}" $XPlayer
  SayConcat $s
EndSub

Event Register1Click
  IfTargetUndefined EndEvent
  GetSourceTarget &p ~t
  GetObjectNumber %t ~t
  Gosub GetNotice1
  GetObjectNumber %n ~not1
  IfInt %n <> %t EndEvent
  &Xplayer = &p
  GetSession %XPlayer &XPlayer
  GetName $XPlayer &XPlayer
  %Players = 1
  OnObjectClickEvent Register2Click
  Gosub GetNotice2
  # b1=Players:
  Concat $Notice2Desc $b1 #13 #10 "X = " $XPlayer #13 #10 "0 = ?"
  Gosub SetNotice2
  Gosub GetNotice3
  # c4=needs a partner
  Concat $Notice3Desc $XPlayer " " $c4
  Gosub SetNotice3
EndEvent

Event Register2Click
  IfTargetUndefined EndEvent
  GetSourceTarget &p ~t
  GetSession %s &p
  IfInt %s = %XPlayer EndEvent
  GetObjectNumber %t ~t
  Gosub GetNotice1
  GetObjectNumber %n ~not1
  IfInt %n <> %t EndEvent
  &Nplayer = &p
  GetSession %NPlayer &NPlayer
  GetName $NPlayer &NPlayer
  %Moves = 0
  %Turn = %XPlayer
  $Turn = $XPlayer
  &Turn = &XPlayer
  $TurnDesc = "X"
  %Players = 2
  %GameStage = 2
  OnObjectClickEvent
  Gosub GetNotice1
  # a3=GAME ON
  # a4=click here to cancel
  Concat $Notice1Desc $a3 #13 #10 $a4
  Gosub SetNotice1
  Gosub GetNotice2
  # b1=Players:
  Concat $Notice2Desc $b1 #13 #10 "X = " $XPlayer #13 #10 "0 = " $NPlayer
  Gosub SetNotice2
  Gosub GetNotice3
  # c2=Playing now:
  Concat $Notice3Desc $c2 #13 #10 $Turn
  Gosub SetNotice3
  # s6=Game started between {x} and {n}
  $s = $s6
  Replace $s $s "{x}" $XPlayer
  Replace $s $s "{n}" $NPlayer
  SayConcat $s
EndEvent

Event GameClick
  IfTargetUndefined EndEvent
  %z = 0
  GetSourceTarget &p ~t
  GetSession %s &p

  GetObjectNumber %t ~t
  Gosub GetNotice1
  GetObjectNumber %n ~not1
  IfInt %n = %t Gosub CheckCancel
  IfInt %z <> 0 EndEvent

  # code here...
  # check if squares heve been clicked
  %square = 0
  GetCitnum %c ~t
  IfInt %c <> %Citnum EndEvent
  GetAction $a ~t
  IfString $sq1 IsIn $a %square = 1
  Else IfString $sq2 IsIn $a %square = 2
  Else IfString $sq3 IsIn $a %square = 3
  Else IfString $sq4 IsIn $a %square = 4
  Else IfString $sq5 IsIn $a %square = 5
  Else IfString $sq6 IsIn $a %square = 6
  Else IfString $sq7 IsIn $a %square = 7
  Else IfString $sq8 IsIn $a %square = 8
  Else IfString $sq9 IsIn $a %square = 9
  IfInt %square = 0 EndEvent

  IfInt %s <> %Turn Gosub SayNotYourTurn
  IfInt %s <> %Turn EndEvent

  # if so, check if valid square has been clicked
  GetDescription $d ~t
  IfString $d <> "" Gosub SayWrongSquare
  IfString $d <> "" EndEvent

  # if so, inscribe, count
  # next either announce winner, 
  # or change %Turn to session nr. of next player

  # $TurnDesc has the description
  ~a = ~t
  GetDescription ~a $TurnDesc
  ObjectModify ~t ~a

  # $h has the Sub label
  IfInt %Turn = %XPlayer Concat $h "x" %square
  Else Concat $h "n" %square
  Gosub $h
EndEvent

Sub CheckCancel
  %z = 0
  # w1=You are not playing
  IfInt %s = %XPlayer %z = 1
  Else IfInt %s = %NPlayer %z = 2
  Else WhisperConcat &p $w1
  IfInt %z = 0 EndSub
  Else IfInt %z = 1 Gosub SayCancelX
  Else Gosub SayCancelN
  %GameStage = 3
  # a2=Click here for new game
  Concat $Notice1Desc $a2
  Gosub SetNotice1
  Gosub GetNotice3
  # c6=GAME CANCELLED
  Concat $Notice3Desc $c6
  Gosub SetNotice3
EndSub

Sub SayCancelN
  # s7=Game between {x} and {n} was cancelled by {y}
  $s = $s7
  Replace $s $s "{x}" $XPlayer
  Replace $s $s "{n}" $NPlayer
  Replace $s $s "{y}" $NPlayer
  SayConcat $s
EndSub

Sub SayCancelX
  # s7=Game between {x} and {n} was cancelled by {y}
  $s = $s7
  Replace $s $s "{x}" $XPlayer
  Replace $s $s "{n}" $NPlayer
  Replace $s $s "{y}" $XPlayer
  SayConcat $s
EndSub

Sub GameDraw
  %GameStage = 3
  # s9=Game between {x} and {n} ended in a draw
  $s = $s9
  Replace $s $s "{x}" $XPlayer
  Replace $s $s "{n}" $NPlayer
  SayConcat $s
  # a2=Click here for new game
  Concat $Notice1Desc $a2
  Gosub SetNotice1
  Gosub GetNotice3
  # c7=GAME ENDED IN DRAW
  Concat $Notice3Desc $c7
  Gosub SetNotice3
EndSub

Sub SayNotYourTurn
  # w1=You are not playing
  # w2=It's the turn of {y}
  IfInt %s = %NPlayer Replace $s $w2 "{y}" $XPlayer
  Else IfInt %s = %XPlayer Replace $s $w2 "{y}" $NPlayer
  Else $s = $w1
  WhisperConcat &p $s
EndSub

Sub SayWrongSquare
  # w3=Wrong move
  WhisperConcat &p $w3
EndSub

Event WaitClick
  IfTargetUndefined EndEvent
  GetSourceTarget &p ~t
  GetSession %s &p
  GetObjectNumber %t ~t
  Gosub GetNotice1
  GetObjectNumber %n ~not1
  IfInt %n = %t %GameStage = 0
EndEvent

Event AvatarDelete
  GetAvatarPerson &p
  GetSession %s &p
  IfInt %GameStage = 1 IfInt %Players > 0 Gosub CheckRegisterDel
  Else IfInt %GameStage = 2 Gosub CheckGameDel
EndEvent

Sub CheckRegisterDel
  IfInt %s = %XPlayer ResetTo Register
  Else EndSub
EndSub

Sub CheckGameDel
  IfInt %s = %XPlayer
  Else IfInt %s = %MPlayer
  Else EndSub
  GetName $n &p
  %GameStage = 3
  # a2=Click here for new game
  Concat $Notice1Desc $a2
  Gosub SetNotice1
  Gosub GetNotice3
  # c6=GAME CANCELLED
  Concat $Notice3Desc $c6
  Gosub SetNotice3
  # s8=Game between {x} and {n} cancelled: {y} left
  $s = $s8
  Replace $s $s "{x}" $XPlayer
  Replace $s $s "{n}" $NPlayer
  Replace $s $s "{y}" $n
  SayConcat $s
EndSub

Text Strings
s1=Please wait, scanning area...
s2=Finished scanning :)
s3=Found signs
s4=Got disconnected... I'm back now... Starting all over :(
s5=Game between {x} and {n} was won by... {y}
s6=Game started between {x} and {n}
s7=Game between {x} and {n} was cancelled by {y}
s8=Game between {x} and {n} cancelled: {y} left
s9=Game between {x} and {n} ended in a draw
w1=You are not playing
w2=It's the turn of {y}
w3=Wrong move
e1=sign(s) not found...
e2=Notice1 board not found...
e3=Notice2 board not found...
e4=Notice3 board not found...
a1=Click here to register
a2=Click here for new game
a3=GAME ON
a4=click here to cancel
b1=Players:
c1=No players...
c2=Playing now:
c3=Winner:
c4=needs a partner
c5=
c6=GAME CANCELLED
c7=GAME ENDED IN DRAW
EndText


Download the script for bots with build rights only. The script file is N&CNew.txt.

Download the script for bots with build rights and Eminent Domain rights. The script file is N&CNewED.txt.

Both sets contain these language files:

See the top of the page for how to use a language file.

backExamples