// Settings integer LISTENER_CHANNEL = 45; // change this to listen on a different channel integer face = ALL_SIDES; // initial / default value.

Similar documents
Subscriber Kiosk 3.0 Application Program Interface User Guide

state View; else if (mesg == "Overview") { state Overview; state_exit(){}

Subscriber Kiosk Timed Sale Vendor [SKTSV]

Python Release September 11, 2014

Copyright (c) by Matthew S. Harris

Texturing HUD Kit Instructions

PLA 3.0 MICROSOFT EXCEL DATA ACQUISITION MODULE

Rndxxxxx - Ladder Diagram Page 1

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

PLA 3.0 TEXT DATA ACQUISITION MODULE

NAME asm cross-assembler SYNOPSIS

QTP Open Source Test Automation Framework Extensibility for Developers

Jdrview User Manual. Version. Nicola L.C. Talbot 18 th March, 2017 PGF. \parshape. \shapepar.

The type of all data used in a C++ program must be specified

2.6 Configuring the Ethernet Communication Module as an EtherNet/IP Adapter

Make Video PDF Booklet v1.0

Open2Test Test Automation Framework for OpenScript - Extensibility for Developers

Fundamentals of Python: First Programs. Chapter 4: Strings and Text Files

Appendix: Generic PbO programming language extension

Discogs Search Kit v1.0 AppleScript for itunes Find more free AppleScripts and info on writing your own at Doug's AppleScripts for itunes.

Part III. Shell Config. Tobias Neckel: Scripting with Bash and Python Compact Max-Planck, February 16-26,

Assignment 4. Overview. Prof. Stewart Weiss. CSci 335 Software Design and Analysis III Assignment 4

Number Song Names by Play Order v2.0

D3D Pythons 1. Material Utilities

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

A Simple Guide to Using SPSS (Statistical Package for the. Introduction. Steps for Analyzing Data. Social Sciences) for Windows

loc ( 3 )[ IDENT ]; tax ( 4 )[ IDENT ]; col ( )[ loc + tax ];

Building A Virtual Babel: Mono In Second Life

Introduction to C# Applications

Instruction Manual v1.2

Language Reference Manual

AStyle C/C++ Source Code Formatter Plugin

SpecialClicks={char(1),char(3),'l','w'}; %you can add as many as you d like %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Using ifix EGD I/O Driver and OPC Server v7.20 with Microsoft Windows XP Service Pack 2 WHITE PAPER

Python memento TI-Smart Grids

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming

Design Insights Enhanced Cue Functionality

Language Editor User Manual

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)

DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6)

Selected Tags to Lyrics v1.1

LiveCode for FM Handbook

Open2Test Test Automation Framework Extensibility for Developers - TestPartner

Open2Test Test Automation Framework for SilkTest - Coding Standards for Developers

Statements and Operators

QTP Open Source Test Automation Framework Coding Standards for Developers

BasicScript 2.25 User s Guide. May 29, 1996

Microsoft Dynamics GP. This paper provides guidance for ISV products that integrate with Inventory transaction posting.

1 Lexical Considerations

Inventory Reports. Detailed Device Report CHAPTER

Merge HL7 Toolkit Segment Map User Interface (UI) Sample Application Guide v.4.7.0

Allen-Bradley ControlLogix Slave Ethernet Driver Help Kepware Technologies

7.0 Test Design Techniques & Dynamic Testing

finger-user-enum User Documentation

Example 1: Read N7:1, N7:2, N7:3 into IntegersRead[] table, offset for starting index is 2. Fig.1 Source data, MicroLogix 1500.

Syntax Syntax for file I/O error detection system function (not in Annex A)

Open2Test Test Automation Framework for Selenium Web Driver FAQ

Anubis User Guide. Paul Murray. For use with version 1.7 Last Update: 13 th October 2005

Mailing Labels from REARS

EnableBasic. The Enable Basic language. Modified by Admin on Sep 13, Parent page: Scripting Languages

ABB Modbus RTU Driver for JMobile

Cloud Services. Spam Manager. Quarantine Admin Guide

SalesNet Mailing Labels

Linden Scripting Language Guide. Aaron Brashears Andrew Meadows Cory Ondrejka Doug Soo

Section 5.5: Text Menu Input from Character Strings

Changing unique password of root user for idrac9 by using Dell EMC License Manager

Networked Audio Solutions Third-Party Control Protocol: User Manual

GNU ccscript Scripting Guide IV

Functional Programming in Haskell Prof. Madhavan Mukund and S. P. Suresh Chennai Mathematical Institute

Simatic S7 Ethernet driver for JMobile

Tip: You can modify variable settings after you add the web application. See Managing repository variable list values, page 4.

Defining Route Maps. Information About Route Maps CHAPTER

You can now give this notecard to people by dragging and dropping it on their avatars.

SequenceManager Controls

MULTIPLE CHOICE. Chapter Seven

INFORMATION TECHNOLOGY SERVICES

Deploying Windows Server 2003 Internet Authentication Service (IAS) with Virtual Local Area Networks (VLANs)

Precision Routing. Capabilities. Precision Queues. Capabilities, page 1 Initial setup, page 5

Advanced Algorithms and Computational Models (module A)

Open2Test Test Automation Framework for SilkTest - Usage Guidelines

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming

UNIT 4. Research Methods in Business

Week 2 Lecture 3. Unix

The Very Basics of the R Interpreter

DSV Library for Lisp

Excel Introduction to Excel Databases & Data Tables

Authorized Send User s Guide Version 4.0

Precision Routing. Capabilities. Precision Queues. Capabilities, page 1 Initial Setup, page 6

/* Copyright 2012 Robert C. Ilardi

EECE.2160: ECE Application Programming

CYMA IV Accounting for Windows Training Guide Series. General Import Training Guide

tm1640-rpi Documentation

EMC Documentum Composer

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

Lexmark X642 Troubleshooting Guide

II-11Tables. Chapter II-11

Request for Comments: Category: Standards Track January 2008

COMP 2718: Shell Scripts: Part 1. By: Dr. Andrew Vardy

Series 5000 ADSL Modem / Router. Firmware Release Notes

Selenium Open Source Test Automation Framework Usage Guidelines

Transcription:

/ A script to change textures on a prim by voice command or menu. The menu-based code is derived from the SimpleDialogMenuSystem script by Omei Qunhua see http:wiki.secondlife.com/wiki/simpledialogmenusystem Currently listens on the channel set by the LISTENER_CHANNEL variable. To listen on a different channel, change this value. Future versions may use a touch menu or notecard to change this. All commands are in the format of "command <param>" where the command and param are separated by a space. Currently param is a single string, but could be extended in the future to a comma-separated list using llparsestring2list or llcsv2list / @author Rebecca Ashbourne / @version 1.0 / @copyright 2017 Rebecca Ashbourne This script is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. This script is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License at http:www.gnu.org/licenses/ for more details. TODO list: * Add an access list rather than restricting to owner-only. Maybe via notecard. * Add ability to set the listener channel via a notecard. / Settings integer LISTENER_CHANNEL = 45; change this to listen on a different channel integer face = ALL_SIDES; initial / default value. Constants list ordinals = ["0","1","2","3","4","5","6","7","8","9"]; list aliases = [ "default", "blank", "transparent", "media" ]; Global variables integer listenerhandle; string facename; list glistfullnames; List of inventory textures list glistbriefnames; List of abbreviated texture names for dialog buttons

integer gpage; Current dialog page number (counting from zero) integer gmaxpage; Highest page number (counting from zero) integer gchan; Channel used for dialog communications. key guser; Current user accessing the dialogs / / Gets the UUID of a default texture from its alias name. / @return the UUID if @name is a valid alias, or an empty string string getalias(string name) if (name == "default" name == "plywood" name == "TEXTURE_PLYWOOD") return TEXTURE_PLYWOOD; if (name == "blank" name == "TEXTURE_BLANK") return TEXTURE_BLANK; if (name == "transparent" name == "TEXTURE_TRANSPARENT") return TEXTURE_TRANSPARENT; if (name == "media" name == "TEXTURE_MEDIA") return TEXTURE_MEDIA; return ""; / Reports a string to the owner(s) report(string message) key owner = llgetowner(); single owner that the region still has a handle for if (llkey2name(owner)) llownersay(message); group owned, must send the message publicly if (lllist2key(llgetobjectdetails(llgetkey(), [OBJECT_GROUP]), 0) == owner) llwhisper(0, "/me : " + message); single owner, not present, send them an IM llinstantmessage(owner, message); / Parses a string into a command and params, which are separated by a space. / @return a list whose 1st element is the command and whose 2nd element is the params string, which may be empty. list parsecommandstring(string str) list newlist;

integer idx = llsubstringindex(str, " "); if (~idx) newlist = [ llgetsubstring(str, 0, idx-1), llstringtrim(llgetsubstring(str, idx+1, -1), STRING_TRIM) ]; newlist = [ str, "" ]; return newlist; / Checks that the param string is not empty. If it is then it emits an error message and returns FALSE / @return TRUE or FALSE integer hasparam(string str) integer result = (str!= ""); if (!result) report("missing parameter"); return result; / Checks that the user is authorised. If they are not, then emits an error message and returns FALSE / @return TRUE or FALSE integer userauthorised(key user) key owner = llgetowner(); TODO: Test for group-owned if (user!= owner) llinstantmessage(user, "Access denied"); report("unauthorised molestation from " + (string)llkey2name(user)); return FALSE; return TRUE; / Gets the positive index represented by the string, otherwise returns -1 / @returns a valid positive integer, or -1 / @note Does not support an explicit leading plus sign. Does not support hexadecimal. integer getindex(string str) integer idx = -1; string c = llgetsubstring(str,0,0); first character if (~lllistfindlist(ordinals,[c])) idx = (integer)str; return idx; / Sets the texture by name. / Allows a limited set of alises too for system textures such as default (plywood), white, media, and transparent. / @param name a texture in the inventory of the prim this script is in or a UUID of a texture / @return TRUE if the name was valid or FALSE

/ @note a texture whose name is the same as an alias will override the alias. integer setbyname(string name) string texture; integer type = llgetinventorytype(name); if (type == INVENTORY_TEXTURE) It's a valid texture in the same object as this script. It can be used. texture = name; texture = getalias(name); if (texture!= "") report("setting texture of face " + facename + " to '" + texture +"'"); llsettexture(texture, face); return TRUE; report("invalid texture name. Try saying 'status' to get all textures."); return FALSE; / Sets the texture by index / @param idx the index of the texture, corresponding to textures in the prim this script is in, sorted alphabetically. setbyindex(integer idx) NOTE: We could bounds check idx against the number of textures, but the call to llgetinventorytype will effectively do this for us. string texture = llgetinventoryname(inventory_texture, idx); integer type = llgetinventorytype(texture); if (type == INVENTORY_TEXTURE) report("setting texture of face " + facename + " to '" + texture +"'"); llsettexture(texture, face); report("index " + (string)idx +" does not correspond to a texture. Try saying 'status' to get all textures."); / Sets the face value. / @return TRUE if the face was valid or FALSE integer setface(integer idx) if (idx >= ALL_SIDES && idx < llgetnumberofsides()) face = idx; if (idx == ALL_SIDES) facename = "ALL_SIDES"; facename = (string)idx;

return TRUE; return FALSE; / Compact function to put buttons in "correct" human-readable order list orderbuttons(list buttons) Button Order 9 10 11 6 7 8 3 4 5 0 1 2 return lllist2list(buttons, -3, -1) + lllist2list(buttons, -6, -4) + lllist2list(buttons, -9, -7) + lllist2list(buttons, -12, -10); / Builds the dialog menu builddialogpage(key user) integer totalchoices = (glistbriefnames!= [] ); get length of texture list set up scrolling buttons if needed list buttons = [ "<<", "-", ">>" ]; integer choicesperpage = 9; if (totalchoices < 13) buttons = []; choicesperpage = 12; Compute number of menu pages that will be available gmaxpage = (totalchoices - 1) / choicesperpage; Build a dialog menu for current page for given user integer start = choicesperpage * gpage; starting offset into action list for current page 'start + choicesperpage -1' might point beyond the end of the list, but LSL stops at the list end, without throwing a wobbly buttons = lllist2list(glistbriefnames, start, start + choicesperpage - 1) + buttons; Now raise the dialog lldialog(user, "\npage " + (string) (gpage+1) + " of " + (string) (gmaxpage + 1) + "\n\nchoose an item", orderbuttons(buttons), gchan); llsettimerevent(30); If no response in time, return to 'ready' state

default state_entry() setface(face); state ready; state ready state_entry() listenerhandle = lllisten(listener_channel, "", llgetowner(), ""); report("state: ready"); touch_end(integer total_number) guser = lldetectedkey(0); if (!userauthorised(guser)) gchan = 0x80000000 (integer)("0x" + (string) llgetkey()); Compute a negative communications channel based on prim UUID glistfullnames = []; glistbriefnames = []; integer n = 0; integer ntextures = llgetinventorynumber(inventory_texture); do string name = llgetinventoryname(inventory_texture, n); glistfullnames += name; glistbriefnames += llgetsubstring(name, 0, 23); while (++n < ntextures); n = 0; integer naliases = llgetlistlength(aliases); do string name = lllist2string(aliases, n); glistfullnames += name; glistbriefnames += ("(" + name + ")"); while (++n < naliases); Changing state sets the application to a busy condition while one user is selecting from the dialogs In the event of multiple 'simultaneous' touches, only one user will get a dialog state busy;

/ Respond to a voice command listen(integer channel, string name, key id, string message) if (!userauthorised(id)) All commands are in the format of "command <params>" where the command and params are separated by a space. list cmdline = parsecommandstring(message); string command = lllist2string(cmdline, 0); string param = lllist2string(cmdline, 1); if (command == "status") shows all options and also the current texture report("listening on channel " + (string)listener_channel + " with listener id " + (string)listenerhandle); report("current texture: " + llgettexture(face)); report("face: " + facename); report("available textures:"); integer n = 0; integer ntextures = llgetinventorynumber(inventory_texture); do string texturename = llgetinventoryname(inventory_texture, n); report((string)n + ": " + texturename); while (++n < ntextures); if (command == "name" command == "set") set the texture by name if (param == "") get instead of set report("face " + facename + " is currently set to '" + (string)llgettexture(face) + "'"); if (!setbyname(param)) report("'" + param + "' is not a valid texture. Try saying 'status' to get all textures."); if (command == "index" command == "idx") set the texture by index if (!hasparam(param)) integer idx = getindex(param); if (idx!= -1) setbyindex(idx); report("'" + param + "' does not correspond to valid index. Try saying 'status' to get all textures."); if (command == "face") if (param == "") show the current face

report("face is currently " + facename); Note: Due to the way getindex() works, the side effect is that any invalid value will be interpreted as ALL_SIDES if (setface(getindex(param))) report("face set to " + facename); report("invalid face '" + param + "'"); If a command isn't recognised, treat it as a texture name and try loading that by name. Only if that fails then report an invalid command or texture to the user. if (!~setbyname(message)) report("'" + message +"' is not a valid command or texture."); ready state busy state_entry() report("state: busy"); lllisten(gchan, "", guser, ""); This listener will be used throughout this state gpage = 0; builddialogpage(guser); Show Page 0 dialog to current user listen (integer chan, string name, key id, string msg) if (msg == "<<" msg == ">>") Page change... if (msg == "<<") --gpage; Page back if (msg == ">>") ++gpage; Page forward if (gpage < 0) gpage = gmaxpage; cycle around pages if (gpage > gmaxpage) gpage = 0; builddialogpage(id); if (msg!= " " && msg!= "-") User has selected a texture from the menu integer idx = lllistfindlist(glistbriefnames, [msg]); string name = lllist2string(glistfullnames, idx); setbyname(name); state ready;

timer() state ready; state_exit() llsettimerevent(0); kill the timer busy