Download presentation
Presentation is loading. Please wait.
Published byGeraldine McLaughlin Modified over 9 years ago
1
Libsecondlife: Bots Hyungwook Park
2
LSL vs. libsecondlife Linden Script Language (LSL) Programming language used by residents of Second Life Controls the behavior of in-world objects and allows objects to interact with the Second Life world State-event driven scripting language, in the sense of a finite state machine Libsecondlife (LibSL) A software library to communicate with the servers that control the virtual world of Second Life Function by manipulating avatars Reverse engineering of SL network protocol Used both to query the state of the world and to send uploads and commands that will modify the state Written in general purpose programming language (C#)
3
Bots in Second Life What is the difference between Avatar and Bot? http://www.youtube.com/watch?v=bcemyUuzCds&eurl= Two types of bot LSL based (prims) Come in many shapes and sizes Primarily server side code LibSL based (avatars) Function by manipulating avatars Mixed computation from client and server Network delay becomes an issue
4
Communication Network Second Life Server Client Second Life Server ClientDaemon Centralized network topology Client-server model Second LifeLibsecondlife Function Visualization
5
LSL Bot Prims with (motion) control Control is defined through LSL Integrated sensing (LSL sensors) Can interface with remote resources http://www.youtube.com/watch?v=824TFPerXsQ Tour Guide (Aesthetica)
6
LSL Bots: LSL Limitations Language limitations Emphasis on states and events No native arrays, only sequential list can be used Limited length for script (16KB) make it difficult to develop large, complex applications Control limitations Embedded in a prim, not in avatars Cannot log into the world more than one avatar Avatar cannot have the script, thus the prim has to be attached into the avatar
7
LibSecondLife Potential for complete avatar simulation Reverse engineering of SL network protocol Based on C# All C# features are available Much more flexible programming environment Avatar control Client-server interface
8
LibSecondLife (continue) Disadvantages Network traffic is subject to missed packets and limited by client performance Not robust (Beta version v0.3.2) and lack of documentation Combination with LSL will be one of possible solutions Demos http://www.youtube.com/watch?v=3TFGFtRizn0 http://www.youtube.com/watch?v=3TFGFtRizn0 http://www.youtube.com/watch?v=VaUNX00Uqc0 http://www.youtube.com/watch?v=VaUNX00Uqc0
9
LibSL: Getting Started (1) Prerequisites (For Windows) C# compiler Visual Studio.NET 2005 (Windows) Visual Studio Express.NET (Windows, free) Source code via SubVersion (SVN)* svn://openmetaverse.org/libsl/trunk For more help: http://www.libsecondlife.org/wiki/Main_Page http://www.libsecondlife.org/wiki/Getting_Started * Subversion (SVN) is a version control system. It is used to maintain current and historical versions of files such as source code, web pages, and documentation.
10
LibSL: Getting Started (2) Instructions Create a folder named dev in C:\ In the dev folder, create a folder named libsecondlife. Right click the libsecondlife folder, select SVN Checkout… In the field for "URL of Repository", put svn://opensecondlife.org/libsl/trunk Files should start getting downloaded.
11
How to create a basic libSL bot http://www.libsecondlife.org/wiki/Use_libSL_to_login_to_the_SL_grid
12
LibSL: Sample code (1) using System; using System.Collections.Generic; using System.Text; using libsecondlife; namespace MyFirstBot { class MyFirstBot { public static SecondLife client = new SecondLife(); private static string first_name = "First"; private static string last_name = "Last"; private static string password = "password"; public static void Main() { client.Network.OnConnected += new NetworkManager.ConnectedCallback(Network_OnConnected); if (client.Network.Login(first_name, last_name, password, "My First Bot", "Your name")) Console.WriteLine("I logged into Second Life!"); else Console.WriteLine("I couldn't log in); } static void Network_OnConnected(object sender) { Console.WriteLine("I'm connected to the simulator"); client.Self.Chat("Hello World!", 0, ChatType.Normal); Console.WriteLine("Now I am going to logout of SL.. Goodbye!"); client.Network.Logout(); } Include libsecondlife libraries Define SecondLife client(s) Add your bot’s name Define a connected event Try to log in to the Grid When connected, send a message After your message, logout
13
LibSL: Sample code (2) using System; using System.Collections.Generic; using System.Text; using libsecondlife; namespace MyFirstBot { class MyFirstBot { public static SecondLife client = new SecondLife(); private static string first_name = "First"; private static string last_name = "Last"; private static string password = "password"; public static void Main() { client.Network.OnConnected += new NetworkManager.ConnectedCallback(Network_OnConnected); if (client.Network.Login(first_name, last_name, password, "My First Bot", "Your name")) Console.WriteLine("I logged into Second Life!"); else Console.WriteLine("I couldn't log in); } static void Network_OnConnected(object sender) { Console.WriteLine("I'm connected to the simulator"); client.Self.Chat("Hello World!", 0, ChatType.Normal); Console.WriteLine("Now I am going to logout of SL.. Goodbye!"); client.Network.Logout(); } string startLocation = NetworkManager.StartLocation("Second China", 179,165,31); if (client.Network.Login(first_name, last_name, password, "My First Bot", startLocation, "Your name")) string startLocation = NetworkManager.StartLocation("Second China", 179,165,31); if (client.Network.Login(first_name, last_name, password, "My First Bot", startLocation, "Your name"))
14
LibSL: Framework Most actions are defined within callbacks (events) Network events OnConnected / OnDisconnected OnCurrentSimChanged Client (Avatar) events OnInstantMessage OnChat OnTeleport Object events OnNewAvatar / OnNewPrim OnObjectUpdated / OnObjectKilled
15
LibSL: Communication Send an instant message client.Self.InstantMessage(target, "Hello, World!"); Say something client.Self.Chat("Hey There World", 0, ChatType.Normal); Respond to instant message client.Self.OnInstantMessage += new AgentManager.InstantMessageCallback(Self_OnInstantMessage); static void Self_OnInstantMessage(InstantMessage im, Simulator sim) Respond to chat client.Self.OnChat += new AgentManager.ChatCallback(Self_OnChat); static void Self_OnChat(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourceType, string fromName, LLUUID id, LLUUID ownerid, LLVector3 position)
16
LibSL: Movement Teleport client.Self.Teleport(“Second China", new LLVector3(128.0f, 128.0f, 50.0f)); client.Self.Teleport(new LLUUID("The-key-of-a-landmark")); client.Self.OnTeleport += new AgentManager.TeleportCallback(Self_OnTeleport); static void Self_OnTeleport(string message, AgentManager.TeleportStatus status, AgentManager.TeleportFlags flags) LookAt(LLVector3 location) Walk client.Self.AutopilotLocal(128, 128, 30); Animation client.Self.AnimationStart(“UUID of animation”, true); System.Threading.Thread.Sleep(5000); client.Self.AnimationStop(“UUID of animation”, true); http://www.libsecondlife.org/docs/
17
Second China Demo Questions?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.