StallBoard/LSL/raw/Menu.lsl

318 lines
No EOL
14 KiB
Text
Executable file

#include "variables.lsl"
#include "functions.lsl"
default
{
state_entry()
{
g_lCheckboxes = ["[ ]", "[X]"];
MAIN_MENU_TEXT = HEADER+"Please choose from the following options";
IMPORT_MENU_TEXT = HEADER+"Enter the ID of the Flash Module which contains the data you wish to import from\n* Flash Module must be of protocol 0x2110b or newer";
}
link_message(integer s,integer n,string m,key i)
{
//llSay(0, llDumpList2String([n,m,i], " ~ "));
if(n == 0x2E1D)
{
g_iAuthorized=1;
g_kAuthorized=i;
PartialRestoreKVP();
MainMenu(i);
} else if(n == 0x1D)
{
g_lSupport = llJson2List(m);
}else if(n == LINK_MENU_TIMEOUT)
{
llInstantMessage(i, "Menu Timed out!");
if(i==g_kInvLoad){
g_kInvLoad=NULL;
llMessageLinked(LINK_SET, 0x3E, llList2Json(JSON_OBJECT, ["op", "nopic"]),"");
}
} else if(n == LINK_MENU_RETURN)
{
string sIdent = llJsonGetValue(m, ["id"]);
string sExtra = llJsonGetValue(m, ["extra"]);
string sButton = llJsonGetValue(m,["reply"]);
switch(sIdent)
{
case "menu~main":{
switch(sButton){
case "Utils..": {
UtilsMenu(i);
break;
}
case "-exit-":{
llInstantMessage(i, "Menu Closed!");
break;
}
case "Lease":{
// Set
if(g_iFlags&1)
{
llMessageLinked(LINK_SET,0x3E, llList2Json(JSON_OBJECT, ["op", "lease"]), i);
}else {
GetArbitraryData(i, "Who should the board be leased to? \nAccepts: [SLURL, Username, UUID]", "main~adminlease");
}
break;
}
case "End Lease":{
llMessageLinked(LINK_SET, 0x3E, llList2Json(JSON_OBJECT, ["op", "reset"]), "");
llInstantMessage(g_kLeasedTo, "Your lease has been terminated by secondlife:///app/agent/"+(string)i+"/about");
llResetScript();
break;
}
case "Renew":{
if(g_iExpireAt == -1)
{
llInstantMessage(g_kLeasedTo, "Your lease timer has been restarted and is no longer indefinite");
}
llInstantMessage(i, "Renew complete!");
llMessageLinked(LINK_SET, 0x3E, llList2Json(JSON_OBJECT, ["op", "renew"]), "");
break;
}
case "Set Picture":{
GetArbitraryData(i, HEADER+"Please input the texture UUID, or you can drag and drop a full permission texture into my inventory by holding CTRL", "menu~settxt");
llMessageLinked(LINK_SET, 0x3E, llList2Json(JSON_OBJECT, ["op", "pic"]), i);
g_kInvLoad=i;
break;
}
case "WhoLeased":{
if(g_kLeasedTo == NULL){
llSay(0, "Vacant - This board is available to be leased");
}else{
llSay(0, "Leased by : secondlife:///app/agent/"+(string)g_kLeasedTo+"/about");
if(g_kOwner != NULL)llSay(0, "The pony's owner is : secondlife:///app/agent/"+(string)g_kOwner+"/about");
}
break;
}
case "TimeRemain":{
if(g_iExpireAt == -1){
llSay(0, "No Expiration is set");
}else {
integer iDifference = g_iExpireAt - llGetUnixTime();
integer Days = iDifference/ONE_DAY;
iDifference -= (ONE_DAY*Days);
integer Hours = iDifference/60/60;
iDifference -= (Hours*60*60);
integer Minutes = iDifference/60;
iDifference -= (Minutes*60);
llSay(0, "Time Remaining: "+(string)Days+" days, "+(string)Hours+" hours, "+(string)Minutes+" minutes, "+(string)iDifference+" seconds");
}
break;
}
case "Set Owner":{
GetArbitraryData(i, HEADER+"What is the owner's secondlife name?", "main~owner");
break;
}
case "TransferLease":{
GetArbitraryData(i, HEADER+"Enter the username of the person you want to transfer this lease to", "main~leasetrans");
break;
}
case "Set Name":{
GetArbitraryData(i, HEADER+"Enter the name you want displayed on the panel. This is useful when Unicode is showing as question marks. Please only input ASCII.\n \n* To clear the current preference, submit the leave the box empty and hit submit.", "main~name");
break;
}
default:{
MainMenu(i);
llSay(0, "Button : "+sButton+" not implemented");
break;
}
}
break;
}
case "menu~utils": {
switch(sButton) {
case "-exit-":{
llInstantMessage(i, "Menu Closed!");
break;
}
case "Import":{
GetArbitraryData(i, IMPORT_MENU_TEXT, "main~import");
break;
}
case "Reboot":{
llMessageLinked(LINK_SET, 0x3E, llList2Json(JSON_OBJECT, ["op", "reboot"]), i);
break;
}
case "PermaLease":{
llMessageLinked(LINK_SET, 0x3E, llList2Json(JSON_OBJECT, ["op", "perma"]), i);
break;
}
case "*RESET*":{
llMessageLinked(LINK_SET, 0x3E, llList2Json(JSON_OBJECT, ["op", "reset"]), i);
llResetScript();
break;
}
case "main..": {
MainMenu(i);
break;
}
case "MemStick":{
llGiveInventory(i,"Stall Board Flash Drive [AC]");
break;
}
case "Export":{
llWhisper(5, llList2Json(JSON_OBJECT,["cmd","set_memstick","leasee",g_kLeasedTo,"expire_time",g_iExpireAt,"texture",g_kTexture,"owner",g_kOwner]));
break;
}
case Checkbox(bool(g_iMask & MASK_WHITEFRAME), "White Frame"):{
g_iMask = mask(TOGGLE, g_iMask, MASK_WHITEFRAME);
llLinksetDataWrite("mask", (string)g_iMask);
llMessageLinked(LINK_SET, 0x3E, llList2Json(JSON_OBJECT, ["op", "reboot"]), "");
break;
}
case Checkbox(bool(g_iMask & MASK_LOGO),"Logo"):{
g_iMask = mask(TOGGLE, g_iMask, MASK_LOGO);
llLinksetDataWrite("mask", (string)g_iMask);
llMessageLinked(LINK_SET, 0x3E, llList2Json(JSON_OBJECT, ["op", "reboot"]), "");
break;
}
case Checkbox(bool((g_iMask & MASK_CUSTOM_TEXT_COLOR)), "CustomTxt"):
{
g_iMask = mask(TOGGLE, g_iMask, MASK_CUSTOM_TEXT_COLOR);
llLinksetDataWrite("mask", (string)g_iMask);
llMessageLinked(LINK_SET, 0x3E, llList2Json(JSON_OBJECT, ["op", "reboot"]), "");
break;
}
case "SetTxtC":
{
Menu(i, "Pick a color, or enter a custom one", ["colormenu"], "CTxt");
break;
}
}
break;
}
case "main~import": {
llMessageLinked(LINK_SET, 0, "Importing Data", "fw_data");
llRegionSayTo((key)sButton, 0x9f, llList2Json(JSON_OBJECT, ["cmd","retrieve"]));
break;
}
case "main~name": {
llLinksetDataWrite("name", sButton);
llMessageLinked(LINK_SET, 0x3E, llList2Json(JSON_OBJECT, ["op", "reboot"]), "");
MainMenu(i);
break;
}
case "main~adminlease":
{
key kTemp = "";
if(IsLikelyAvatarID(sButton))
{
// Avatar ID.
kTemp = sButton;
}else {
// Determine if this is a SLURL
list lTemp = llParseString2List(sButton, ["/"],[]);
if(llList2String(lTemp,0) == "secondlife:")
{
kTemp = llList2String(lTemp,3);
}else {
llMessageLinked(LINK_SET, 0x3E, llList2Json(JSON_OBJECT, ["op", "actlease"]), sButton);
}
}
if(kTemp != "")
{
llMessageLinked(LINK_SET, 0x3E, llList2Json(JSON_OBJECT, ["op", "lease"]), kTemp);
}
break;
}
case "CTxt":
{
llLinksetDataWrite("customtxtcolor", sButton);
llMessageLinked(LINK_SET, 0x3E, llList2Json(JSON_OBJECT, ["op", "reboot"]), "");
MainMenu(i);
break;
}
case "menu~settxt":{
if(sButton == ""){
g_kTexture = NULL_KEY;
}else {
g_kTexture = (key)sButton;
}
llLinksetDataWrite("texture", (string)g_kTexture);
llMessageLinked(LINK_SET, 0x3E, llList2Json(JSON_OBJECT, ["op", "reboot"]), "");
break;
}
case "main~owner":{
if(sButton == ""){
g_kOwner=NULL_KEY;
llLinksetDataWrite("owner", (string)g_kOwner);
llMessageLinked(LINK_SET, 0x3E, llList2Json(JSON_OBJECT, ["op", "reboot"]), "");
MainMenu(i);
return;
}
llMessageLinked(LINK_SET, 0x3E, llList2Json(JSON_OBJECT, ["op", "setowner", "id", i]), sButton);
//UpdateDSRequest(NULL, llRequestUserKey(sButton), SetDSMeta(["set_owner"]));
//g_kOwner = (key)sButton;
//SavePayload();
//MainMenu(i);
break;
}
case "main~leasetrans":{
if(sButton == ""){
// Cancel transfer
if(g_kTransferID != NULL_KEY){
llLinksetDataWrite("name", "");
}
g_kTransferID=NULL_KEY;
g_iTransferTimeout=-1;
llLinksetDataWrite("transfer", g_kTransferID);
llLinksetDataWrite("transfer_expire", (string)g_iTransferTimeout);
llMessageLinked(LINK_SET,0x3E, llList2Json(JSON_OBJECT, ["op", "reboot"]), "");
MainMenu(i);
return;
}
//llRegionSay(0x99f9, llList2Json(JSON_OBJECT, ["op","request", "get", "transfer", "var", sButton]));
g_sPreferredName="<!c=red>*RESERVED*";
g_iTransferTimeout = llGetUnixTime()+(2*ONE_DAY);
llLinksetDataWrite("name", g_sPreferredName);
g_kTransferID=sButton;
llLinksetDataWrite("transfer", sButton);
llLinksetDataWrite("transfer_expire", (string)g_iTransferTimeout);
llMessageLinked(LINK_SET,0x3E, llList2Json(JSON_OBJECT, ["op", "reboot"]), "");
llSay(0, "Lease transfer has been initiated. secondlife:///app/agent/"+(string)g_kTransferID+"/about has 48 hours to touch this board to finalize the transfer process");
llInstantMessage(g_kTransferID, "A lease is being transfered to you. To confirm, you must click this board within 48 hours. My position is : "+(string)llGetPos());
MainMenu(i);
break;
}
}
}
}
}