A script that interfaces directly with the HUD, allowing the user to interact with your plugin through the HUD's menu system. This particular example has most of the commands in it, allowing you to easily test them.
/*
ATLust API Example Script
-----
Demonstrates how to use the ATLust V2.1 API to act as a plugin for the HUD.
This particular script requires level 1 or higher API access.
Please see the wiki for more details on ATLust V2.1 API
https://atlust.fandom.com/wiki/API_V2.1
-----
This script was compiled with the LSL Preprocessor. If you do not use a preprocessor, you will need to remove all of the code prefixed with # and manually replace each of their values.
*/
#define SERVER_VERSION "atnet" //Should be "atnet" in all cases unless you're told otherwise.
#define API_KEY "" //The API key that you were provided with
#define API_ID 0 //The API ID that you were provided with
//--------- Request Types-----------
#define TEST "TEST" //Returns "Hello, world!"
#define GET_VALUE "GET_VALUE" //Returns the values of the indicated value names. (Requires: names[]<Strings>, target<UUID/Char ID>)
#define SET_VALUE "SET_VALUE" //Sets the values of the indicated value names. (Requires: names{}<String, Variable>, target<UUID/Char ID>)
#define SEND_MESSAGE "SEND_MESSAGE" //Send a message to the indicated character/player. (Requires: target<UUID/Char ID>, message<String>)
#define TEST_PERMS "TEST_PERMS" //A simple request to use to see if your API has permissions on the target player. (Requires: target<UUID/Char ID> | Returns: OK)
#define GET_ORGAN_VALUE "GET_ORGAN_VALUE" //Gets organ values (Requires: target<UUID/Char ID>, names[]<string>, organ_id<string> | Returns: Object<String, Variable>)
#define SET_ORGAN_VALUE "SET_ORGAN_VALUE" //Sets organ values (Requires: target<UUID/Char ID>, values[]<string, variable>, organ_id<string> | Returns: Object<String, Variable>)
#define GET_CONDITIONS "GET_CONDITIONS" //Gets a list of all condition types on the target. (Requires: target<UUID/Char ID> | Returns: List of strings)
#define GET_SPECIES "GET_SPECIES" //Gets the target character's species data (Requires: target<UUID/Char ID> | Returns: List of objects)
#define GET_PREGNANCY_PROGRESS "GET_PREGNANCY_PROGRESS" //Gets the target character's pregnancy progress (Requires: target<UUID/Char ID> | Returns: Float<0.0 - 1.0>)
#define GET_PREGNANCY_COUNTS "GET_PREGNANCY_COUNTS" //Gets the target character's number of active pregnancies in each organ (Requires: target<UUID/Char ID> | Returns: Object<String, Integer>)
#define GET_ORGANS "GET_ORGANS" //Returns an object of all the character's target organs. (Requires: target<UUID/Char ID> | Returns: Object<String, List<String>>)
#define GET_IS_ATLUST_USER "GET_IS_ATLUST_USER" //Checks to see if the target resident owns ATLust. (Requires: player_id<UUID> | Returns: Boolean)
#define GET_IS_PLAYER_ONLINE "GET_IS_PLAYER_ONLINE" //Checks to see if the ATLust player is online. (Requires: player_id<UUID> | Returns: Boolean)
#define GET_ACTIVE_SEX_ACTIONS "GET_ACTIVE_SEX_ACTIONS" //Gets a list of all active sex actions. (Requires: player_id<UUID> | Returns: List of Objects)
#define GET_ORGAN_INFO "GET_ORGAN_INFO" //Gets info for the specified organ. (Requires: target<UUID/Char ID>, organ_id | Returns: Object)
#define GET_ATTRACTION "GET_ATTRACTION" //Gets the attraction amount between two characters. (Requires: source_char(Char ID), target_char(Char ID) | Returns: Object)
#define MAKE_CUM "MAKE_CUM" //Creates a cum object for the specified target. (Requires: target<UUID/Char ID> | Returns: CumID)
#define GET_CUM_INFO "GET_CUM_INFO" //Gets info on the specified cum object (Requires: cum_id<String> | Returns: Object)
#define INJECT_CUM "INJECT_CUM" //Injects the specified cum object into the specified organ (Requires: target<UUID/CharID>, organ_id<String>, cum_id<CumID> | Returns: OK)
#define CUSTOM_CONDITION "CUSTOM_CONDITION" //Creates a custom condition on the target character (Requires: target<UUID,CharID>, name<String>, desc<String>, time<Integer>, id<String> ++SEE WIKI FOR MORE PARAMETERS++ | Returns: OK)
#define REGISTER_URL "REGISTER_URL" //Registers a URL to receive notifications from the ATLust server (Requires: player_id<UUID>, url<String> | Returns: OK)
#define SEND_MESSAGE "SEND_MESSAGE" //Sends a message to the player through their ATLust HUD (Requires: target<UUID/CharID>, message<String>)
#define REGISTER_MENU "REGISTER_MENU" //Registers a menu with the target player's HUD. (Requires: player_id, url, name, desc | Returns: OK)
#define DEREGISTER_MENU "DEREGISTER_MENU" //Deregisters the indicated menu from the target player's HUD. (Requires: player_id, name | Returns: OK)
#define GET_NAME "GET_NAME" //Returns the character name, title and owner ID. (Requires: target<UUID/CharID> | Returns: Character name string)
#define GET_BREEDING_GROUND "GET_BREEDING_GROUND" //Returns info about the specified breeding ground. (Requires: parcel_id | Returns: JSON Object)
#define GET_BREEDING_GROUNDS "GET_BREEDING_GROUNDS" //Returns a key/value pair list of all active breeding grounds. (Returns: Key-Value, Parcel ID and Parcel Name)
#define GET_CUM_LIST "GET_CUM_LIST" //Returns a list of all cum in the target's specified organ. (Requires: target<UUID/CharID>, organ_id | Returns: Array of Objects)
#define GET_INVENTORY_ITEMS "GET_INVENTORY_ITEMS" //Returns a key/value pair of all inventory items and their quantities that the player has. (Requires: player_id | Returns: Array of Strings)
#define GET_AVAILABLE_TITLES "GET_AVAILABLE_TITLES" //Returns a list of all titles that the character has earned. (Requires: target<UUID/CharID> | Returns: Array of Strings)
#define REMOVE_CONDITION "REMOVE_CONDITION" //Removes the indicated condition (Requires: target<UUID/CharID>, name<String> | Returns: OK)
#define MODIFY_RESTRICTIONS "MODIFY_RESTRICTIONS" //Adds or removes the indicated restriction types on the target player. (Requires: player_id, restrictions, state | Returns: OK)
#define GET_ALL_RESTRICTIONS "GET_ALL_RESTRICTIONS" //Lists each restriction that the player has imposed on them. (Requires: player_id | Returns: Array of Strings)
#define GET_SEX_ACTION_INFO "GET_SEX_ACTION_INFO" //Returns info about the sex action (Requires: id | Returns: name, desc, init_organ, rec_organ, owner, penetrative)
#define GET_PLAY_ACTION_INFO "GET_PLAY_ACTION_INFO" //Returns info about the play action (Requires: id | Returns: name, desc, init_organ, rec_organ, owner, lust)
#define GET_TEASE_ACTION_INFO "GET_TEASE_ACTION_INFO" //Returns info about the tease action (Requires: id | Returns: name, desc, init_organ, rec_organ, owner, lust)
#define GET_HUD_VERSION "GET_HUD_VERSION" //Returns the HUD version (Requires: player_id | Returns: HUD version as float)
#define CUM_IN_ORGAN "CUM_IN_ORGAN" //Causes the source organ to climax with the target organ. (Requires: target, source, target_organ_id, source_organ_id)
#define HUD_DIALOG "HUD_DIALOG" //Creates a dialog popup for the player to respond to. Response is sent through the DIALOG_RESPONSE signal. (Requires: player_id, message, buttons, id)
#define KV_SET "KV_SET" //Sets a key-value pair (Requires: target, key, value)
#define KV_GET "KV_GET" //Gets the value for the corresponding key (Require: target, key | Returns: Value)
#define KV_DEL "KV_DEL" //Deletes the KV record for the corresponding key (Requires: target, key)
#define KV_LIST "KV_LIST" //Lists all keys for the target. (Requires: target)
#define KV_CLEAR "KV_CLEAR" //Delets all KV records for the target. (Requires: target)
#define GET_INFECTIONS "GET_INFECTIONS" //Returns a list of all infections. (Requires: target | Returns list of objects)
//--------- Request Types-----------
//--------- Listen Modes -----------
#define LISTEN_MODE_GET_VALUE 1
#define LISTEN_MODE_SET_VALUE 2
#define LISTEN_MODE_GET_ORGAN_VALUE 3
#define LISTEN_MODE_GET_ORGAN_VALUE_ID 4
#define LISTEN_MODE_SET_ORGAN_VALUE 5
#define LISTEN_MODE_SET_ORGAN_VALUE_ID 6
#define LISTEN_MODE_GET_ORGAN_INFO 7
#define LISTEN_MODE_GET_CUM_INFO 8
#define LISTEN_MODE_INJECT_CUM_ORGAN 9
#define LISTEN_MODE_INJECT_CUM_ID 10
#define LISTEN_MODE_SEND_MESSAGE 11
#define LISTEN_MODE_GET_BREEDING_GROUND 12
#define LISTEN_MODE_CUM_LIST 13
#define LISTEN_MODE_REMOVE_CONDITION 14
#define LISTEN_MODE_RESTRICTION_TYPES 15
#define LISTEN_MODE_RESTRICTION_STATE 16
#define LISTEN_MODE_GET_SEX_ACTION_INFO 17
#define LISTEN_MODE_GET_PLAY_ACTION_INFO 18
#define LISTEN_MODE_GET_TEASE_ACTION_INFO 19
#define LISTEN_MODE_GET_DIALOG_BUTTONS 20
#define LISTEN_MODE_CUM_IN_GET_ORGAN 21
#define LISTEN_MODE_CUM_IN_GET_PARTNER 22
#define LISTEN_MODE_CUM_IN_GET_PART_ORGAN 23
#define LISTEN_MODE_KV_SET_GET_KEY 24
#define LISTEN_MODE_KV_SET_GET_VALUE 25
#define LISTEN_MODE_KV_GET_KEY 26
#define LISTEN_MODE_KV_CLEAR_CONFIRM 27
#define LISTEN_MODE_KV_DEL_KEY 28
#define LISTEN_MODE_PLAYER_ONLINE 29
//--------- Listen Modes -----------
key req_register_signals;
key req_menu_register;
key req_send_message;
key req_check_player;
key req_get_value;
key req_set_value;
key req_get_organ_value;
key req_set_organ_value;
key req_get_conditions;
key req_get_species;
key req_get_preg_proc;
key req_get_preg_count;
key req_get_organs;
key req_get_active_sex_actions;
key req_get_organ_info;
key req_get_make_cum;
key req_get_cum_info;
key req_set_inject_cum;
key req_get_send_message;
key req_get_breeding_ground;
key req_get_breeding_grounds;
key req_get_cum_list;
key req_custom_condition;
key req_get_titles;
key req_get_inventory;
key req_remove_condition;
key req_mod_restrictions;
key req_get_restrictions;
key req_get_action_info;
key req_get_hud_version;
key req_hud_dialog;
key req_cum_inside;
key req_kv_set;
key req_kv_get;
key req_kv_clear;
key req_kv_del;
key req_kv_list;
key req_player_online;
key earl_get;
key api_target;//Target of the API tester commands.
key cum_partner;
string earl; //The URL that will receive communications from the server.
string organ_id;
string kv_key;
integer listen_chan;
integer listen_mode;
list restrictions;
key HTTPRequest(string data)
{
key id;
integer attempts;
#if API_ID==0
string hash = "NONE";
#else
string hash = llSHA1String(API_KEY + "(C) Aozora Tech 2023 - Do not distribute with transfer and/or modify permissions. Copy permission only. KEEP YOUR KEY PRIVATE!" + data);
#endif
list headers = [HTTP_METHOD, "POST",
HTTP_MIMETYPE, "application/x-www-form-urlencoded",
HTTP_BODY_MAXLENGTH, 8192,
HTTP_VERBOSE_THROTTLE, FALSE,
HTTP_CUSTOM_HEADER, "api-id", (string)API_ID,
HTTP_CUSTOM_HEADER, "api-hash", hash];
while( (id = llHTTPRequest("https://aozoratech.net/" + SERVER_VERSION + "/atlust/api", headers, "do=request&data=" + data)) == NULL_KEY &&
++attempts <= 5)
{
llSleep(25.0);
}
return id;
}
string RequestObject(string req, list params)
{
return llList2Json(JSON_OBJECT, ["req", req, "params", llList2Json(JSON_OBJECT, params)]);
}
key MakeRequest(string req, list params)
{
return HTTPRequest(RequestObject(req, params));
}
string BoolToJson(integer bool)
{
if(bool)
{
return JSON_TRUE;
}
return JSON_FALSE;
}
/*
Creates a menu button item.
text = The value that is visible to the user.
value = The buttons actual value (What your plugin sees)
hover_text = The text that appears when the user hovers their cursor over the button. (Plain text only!)
disabled = If true, the button will be greyed out and unusable.
*/
string MenuButton(string text, string value, string hover_text, integer disabled)
{
return llList2Json(JSON_OBJECT, ["text", text,
"value", value,
"hover_text", hover_text,
"disabled", BoolToJson(disabled)]);
}
GetURL()
{
earl_get = llRequestSecureURL();
}
PrintResults(list results)
{
integer num = llGetListLength(results);
list foo = [];
while( (num -= 2) >= 0)
{
foo += llList2String(results, num) + " = " + llList2String(results, num + 1);
}
llOwnerSay(" [Results]\n" + llDumpList2String(foo, "\n"));
}
default
{
on_rez(integer start)
{
llResetScript();
}
changed(integer change)
{
if(change & (CHANGED_REGION|CHANGED_REGION_START))//We need to get a new URL. If this is a rezzed script (Such as in furniture), you will need to check for CHANGED_REGION_START, if it's attached, then CHANGED_REGION.
{
GetURL();
}
}
state_entry()
{
GetURL();
llListen(listen_chan = (integer)llFrand(DEBUG_CHANNEL), "", llGetOwner(), "");
api_target = llGetOwner();
req_kv_set = MakeRequest(KV_SET, ["target", api_target,
"key", "int_test",
"value", llGetUnixTime()]);
}
timer()
{
llResetScript();
}
listen(integer chan, string name, key id, string msg)
{
if(listen_mode == LISTEN_MODE_GET_VALUE)
{
req_get_value = MakeRequest(GET_VALUE, ["target", api_target,
"names", llList2Json(JSON_ARRAY, llCSV2List(msg))]);
}
else if(listen_mode == LISTEN_MODE_SET_VALUE)
{
req_set_value = MakeRequest(SET_VALUE, ["target", api_target,
"values", llList2Json(JSON_OBJECT, llParseStringKeepNulls(msg, ["=",","], []))]);
}
else if(listen_mode == LISTEN_MODE_GET_ORGAN_VALUE_ID)
{
organ_id = msg;
listen_mode = LISTEN_MODE_GET_ORGAN_VALUE;
llTextBox(llGetOwner(), "\n\nWhich organ values? \n \nOrgan ID: " + organ_id, listen_chan);
return;//Avoids resetting the listen mode to 0
}
else if(listen_mode == LISTEN_MODE_GET_ORGAN_VALUE)
{
req_get_organ_value = MakeRequest(GET_ORGAN_VALUE, ["target", api_target,
"organ_id", organ_id,
"names", llList2Json(JSON_ARRAY, llCSV2List(msg))]);
organ_id = "";
}
else if(listen_mode == LISTEN_MODE_SET_ORGAN_VALUE_ID)
{
organ_id = msg;
listen_mode = LISTEN_MODE_SET_ORGAN_VALUE;
llTextBox(llGetOwner(), "\n\nWhich organ values?\n(Format them as: Name=Value\n \nOrgan ID: " + organ_id, listen_chan);
return;//Avoids resetting the listen mode to 0
}
else if(listen_mode == LISTEN_MODE_SET_ORGAN_VALUE)
{
req_set_organ_value = MakeRequest(SET_ORGAN_VALUE, ["target", api_target,
"organ_id", organ_id,
"values", llList2Json(JSON_OBJECT, llParseStringKeepNulls(msg, ["=",","], []))]);
organ_id = "";
}
else if(listen_mode == LISTEN_MODE_GET_ORGAN_INFO)
{
req_get_organ_info = MakeRequest(GET_ORGAN_INFO, ["target", api_target,
"organ_id", msg]);
}
else if(listen_mode == LISTEN_MODE_GET_CUM_INFO)
{
req_get_cum_info = MakeRequest(GET_CUM_INFO, ["cum_id", msg]);
}
else if(listen_mode == LISTEN_MODE_INJECT_CUM_ORGAN)
{
organ_id = msg;
listen_mode = LISTEN_MODE_INJECT_CUM_ID;
llTextBox(llGetOwner(), "\n\nWhich cum ID?\nOrgan ID: " + organ_id, listen_chan);
return;//Avoids resetting the listen mode to 0
}
else if(listen_mode == LISTEN_MODE_INJECT_CUM_ID)
{
req_set_inject_cum = MakeRequest(INJECT_CUM, ["target", api_target,
"organ_id", organ_id,
"cum_id", msg]);
}
else if(listen_mode == LISTEN_MODE_SEND_MESSAGE)
{
req_get_send_message = MakeRequest(SEND_MESSAGE, ["target", api_target,
"message", msg]);
}
else if(listen_mode == LISTEN_MODE_GET_BREEDING_GROUND)
{
req_get_breeding_ground = MakeRequest(GET_BREEDING_GROUND, ["parcel_id", msg]);
}
else if(listen_mode == LISTEN_MODE_CUM_LIST)
{
req_get_cum_list = MakeRequest(GET_CUM_LIST, ["target", api_target,
"organ_id", msg]);
}
else if(listen_mode == LISTEN_MODE_REMOVE_CONDITION)
{
req_remove_condition = MakeRequest(REMOVE_CONDITION, ["target", api_target,
"name", msg]);
}
else if(listen_mode == LISTEN_MODE_RESTRICTION_TYPES)
{
restrictions = llCSV2List(msg);
llDialog(llGetOwner(), "\n\nAdd or Remove the restrictions?", ["Add", "Remove"], listen_chan);
listen_mode = LISTEN_MODE_RESTRICTION_STATE;
return;
}
else if(listen_mode == LISTEN_MODE_RESTRICTION_STATE)
{
req_mod_restrictions = MakeRequest(MODIFY_RESTRICTIONS, ["player_id", api_target,
"restrictions", llList2Json(JSON_ARRAY, restrictions),
"state", BoolToJson(msg == "Add")]);
restrictions = [];
}
else if(listen_mode == LISTEN_MODE_GET_SEX_ACTION_INFO)
{
req_get_action_info = MakeRequest(GET_SEX_ACTION_INFO, ["id", (integer)msg]);
}
else if(listen_mode == LISTEN_MODE_GET_PLAY_ACTION_INFO)
{
req_get_action_info = MakeRequest(GET_PLAY_ACTION_INFO, ["id", (integer)msg]);
}
else if(listen_mode == LISTEN_MODE_GET_TEASE_ACTION_INFO)
{
req_get_action_info = MakeRequest(GET_TEASE_ACTION_INFO, ["id", (integer)msg]);
}
else if(listen_mode == LISTEN_MODE_GET_DIALOG_BUTTONS)
{
req_hud_dialog = MakeRequest(HUD_DIALOG, ["player_id", api_target,
"message", "Test message",
"id", (integer)llFrand(99999),
"buttons", llList2Json(JSON_ARRAY, llCSV2List(msg))]);
}
else if(listen_mode == LISTEN_MODE_CUM_IN_GET_ORGAN)
{
organ_id = msg;
listen_mode = LISTEN_MODE_CUM_IN_GET_PARTNER;
llTextBox(llGetOwner(), "\n\nWhich partner will cum inside your organ?\nYour Organ ID: " + organ_id, listen_chan);
return;//Avoids resetting the listen mode to 0
}
else if(listen_mode == LISTEN_MODE_CUM_IN_GET_PARTNER)
{
cum_partner = msg;
listen_mode = LISTEN_MODE_CUM_IN_GET_PART_ORGAN;
llTextBox(llGetOwner(), "\n\nWhich organ on the partner will cum?\nYour Organ ID: " + organ_id + "\nPartner ID: " + (string)cum_partner, listen_chan);
return;//Avoids resetting the listen mode to 0
}
else if(listen_mode == LISTEN_MODE_CUM_IN_GET_PART_ORGAN)
{
req_cum_inside = MakeRequest(CUM_IN_ORGAN, ["target", api_target,
"source", cum_partner,
"source_organ_id", msg,
"target_organ_id", organ_id]);
cum_partner = "";
organ_id = "";
}
else if(listen_mode == LISTEN_MODE_KV_SET_GET_KEY)
{
kv_key = msg;
listen_mode = LISTEN_MODE_KV_SET_GET_VALUE;
llTextBox(llGetOwner(), "\n\nWhat value for: " + kv_key, listen_chan);
return;//Avoids resetting the listen mode to 0
}
else if(listen_mode == LISTEN_MODE_KV_SET_GET_VALUE)
{
req_kv_set = MakeRequest(KV_SET, ["target", api_target,
"key", kv_key,
"value", msg]);
kv_key = "";
}
else if(listen_mode == LISTEN_MODE_KV_GET_KEY)
{
req_kv_get = MakeRequest(KV_GET, ["target", api_target,
"key", msg]);
}
else if(listen_mode == LISTEN_MODE_KV_CLEAR_CONFIRM)
{
if(msg == "Yes")
{
req_kv_clear = MakeRequest(KV_CLEAR, ["target", api_target]);
}
}
else if(listen_mode == LISTEN_MODE_KV_DEL_KEY)
{
req_kv_del = MakeRequest(KV_DEL, ["target", api_target,
"key", msg]);
}
else if(listen_mode == LISTEN_MODE_PLAYER_ONLINE)
{
req_player_online = MakeRequest(GET_IS_PLAYER_ONLINE , ["player_id", msg]);
}
listen_mode = 0;
}
http_request(key id, string method, string body)
{
string path = llGetSubString(llGetHTTPHeader(id, "x-path-info"), 1, -1);
if(id == earl_get)
{
earl = body;
req_menu_register = MakeRequest(REGISTER_MENU, ["player_id", llGetOwner(),
"url", earl + "/menu", //You do not have to append your URL's with "menu" or "signals" like this script does; It just makes it easier to recognize requests made to them.
"name", "Tester",
"desc", "Testing 1 2 3"]);
}
else if(path == "menu")
{
string button = llJsonGetValue(body, ["button"]);
string plugin_name = llJsonGetValue(body, ["plugin_name"]);
string menu_name = llJsonGetValue(body, ["menu_name"]);
string player_id = llJsonGetValue(body, ["player_id"]);
integer char_id = (integer)llJsonGetValue(body, ["char_id"]);
string menu_text = "";
string modal = "";
list butts = [];
if(menu_name == JSON_INVALID)//In some instances, the server will send messages to the menu URL that will not contain menu data.
{
string msg = llJsonGetValue(body, ["message"]);
if(msg == "REMOVED")//The player has removed your plugin. You should do some clean up if necessary. (There is no guarantee you will receive this message. This message is only sent once at the time of removal)
{
llOwnerSay("Plugin removed.");
state removed;
}
else if(msg == "STARTUP")//If the server has just restarted, we may need to refresh some data.
{
llOwnerSay("Server has restarted.");
}
llHTTPResponse(id, 200, "OK");
return;
}
else if(menu_name == "main")
{
//Main menu will automatically receive a back button, along with a "Remove Plugin" button.
butts += MenuButton("Test1", "test1", "Do the thing!", FALSE);
butts += MenuButton("Next Menu>", "sm:nextmenu", "Test stuff", FALSE);
butts += MenuButton("Tests>", "sm:tests", "Go to the next menu", FALSE);
butts += MenuButton("Do The Thing", "nope", "You are not allowed to do the thing", TRUE);
if(button == "test1")
{
req_send_message = MakeRequest(SEND_MESSAGE, ["target", api_target,
"message", "Hippos!"]);
}
menu_text = "Hello, [b]World![/b]";
}
else if(menu_name == "nextmenu")
{
butts += MenuButton("<Back", "sm:main", "Go back", FALSE);
butts += MenuButton("", "", "", FALSE);
butts += MenuButton("Here be dragons", "dragons", "", FALSE);
butts += MenuButton("Check Players>", "sm:checkplr", "", FALSE);
if(button == "dragons")
{
llOwnerSay("RAWR!");
}
}
else if(menu_name == "checkplr")
{
butts += MenuButton("<Back", "sm:nextmenu", "Go back", FALSE);
butts += MenuButton("", "", "", FALSE);
if(llGetAgentSize(button))
{
req_check_player = MakeRequest(GET_NAME, ["target", button]);
}
list peeps = llGetAgentList(AGENT_LIST_PARCEL, []);
integer num = llGetListLength(peeps);
while(~--num)
{
key id = llList2Key(peeps, num);
butts += MenuButton(llKey2Name(id), (string)id, "", FALSE);
}
}
else if(menu_name == "tests") //Here are a bunch of test buttons for most of the API commands.
{
if(button == GET_VALUE)
{
listen_mode = LISTEN_MODE_GET_VALUE;
llTextBox(llGetOwner(), "\n\nWhich values do you want to get?", listen_chan);
}
else if(button == SET_VALUE)
{
listen_mode = LISTEN_MODE_SET_VALUE;
llTextBox(llGetOwner(), "\n\nWhich values do you want to set?\n(Format them as: Name=Value)", listen_chan);
}
else if(button == GET_ORGAN_VALUE)
{
listen_mode = LISTEN_MODE_GET_ORGAN_VALUE_ID;
llTextBox(llGetOwner(), "\n\nWhich organ ID?", listen_chan);
}
else if(button == SET_ORGAN_VALUE)
{
listen_mode = LISTEN_MODE_SET_ORGAN_VALUE_ID;
llTextBox(llGetOwner(), "\n\nWhich organ ID?", listen_chan);
}
else if(button == GET_CONDITIONS)
{
req_get_conditions = MakeRequest(GET_CONDITIONS, ["target", api_target]);
}
else if(button == GET_SPECIES)
{
req_get_species = MakeRequest(GET_SPECIES, ["target", api_target]);
}
else if(button == GET_PREGNANCY_PROGRESS)
{
req_get_preg_proc = MakeRequest(GET_PREGNANCY_PROGRESS, ["target", api_target]);
}
else if(button == GET_PREGNANCY_COUNTS)
{
req_get_preg_count = MakeRequest(GET_PREGNANCY_COUNTS, ["target", api_target]);
}
else if(button == GET_ORGANS)
{
req_get_organs = MakeRequest(GET_ORGANS, ["target", api_target]);
}
else if(button == GET_ACTIVE_SEX_ACTIONS)
{
req_get_active_sex_actions = MakeRequest(GET_ACTIVE_SEX_ACTIONS, ["player_id", api_target]);
}
else if(button == GET_ORGAN_INFO)
{
listen_mode = LISTEN_MODE_GET_ORGAN_INFO;
llTextBox(llGetOwner(), "\n\nWhich organ ID?", listen_chan);
}
else if(button == MAKE_CUM)
{
req_get_make_cum = MakeRequest(MAKE_CUM, ["target", api_target]);
}
else if(button == GET_CUM_INFO)
{
listen_mode = LISTEN_MODE_GET_CUM_INFO;
llTextBox(llGetOwner(), "\n\nWhich cum ID?", listen_chan);
}
else if(button == INJECT_CUM)
{
listen_mode = LISTEN_MODE_INJECT_CUM_ORGAN;
llTextBox(llGetOwner(), "\n\nWhich organ ID?", listen_chan);
}
else if(button == SEND_MESSAGE)
{
listen_mode = LISTEN_MODE_SEND_MESSAGE;
llTextBox(llGetOwner(), "\n\nWhat message?", listen_chan);
}
else if(button == GET_BREEDING_GROUND)
{
listen_mode = LISTEN_MODE_GET_BREEDING_GROUND;
llTextBox(llGetOwner(), "\n\nBreeding ground parcel ID.", listen_chan);
}
else if(button == GET_BREEDING_GROUNDS)
{
req_get_breeding_grounds = MakeRequest(GET_BREEDING_GROUNDS, []);//The results will most likely be truncated if you're only viewing it through llOwnerSay (Due to the 2KB chat limit)
}
else if(button == GET_CUM_LIST)
{
listen_mode = LISTEN_MODE_CUM_LIST;
llTextBox(llGetOwner(), "\n\nWhat Organ ID?", listen_chan);
}
else if(button == CUSTOM_CONDITION)
{
req_custom_condition = MakeRequest(CUSTOM_CONDITION, ["target", api_target,
"name", "Foo Bar", //A name to identify this condition. Non-unique names with the same or no modifier will overwrite eachother.
"id", (string)llRound(llFrand(100)), //ID parameter is optional (It allows you to create multiple instances of the same condition).
"desc", "Causes your bars to foo",
"time", 300,
"health_effect", -0.5]);
}
else if(button == GET_AVAILABLE_TITLES)
{
req_get_titles = MakeRequest(GET_AVAILABLE_TITLES, ["target", api_target]);
}
else if(button == GET_INVENTORY_ITEMS)
{
req_get_inventory = MakeRequest(GET_INVENTORY_ITEMS, ["player_id", api_target]);
}
else if(button == REMOVE_CONDITION)
{
listen_mode = LISTEN_MODE_REMOVE_CONDITION;
llTextBox(llGetOwner(), "\n\nWhat condition ID?", listen_chan);
}
else if(button == MODIFY_RESTRICTIONS)
{
listen_mode = LISTEN_MODE_RESTRICTION_TYPES;
llTextBox(llGetOwner(), "\n\nWhich restrictions (CSV)?", listen_chan);
}
else if(button == GET_ALL_RESTRICTIONS)
{
req_get_restrictions = MakeRequest(GET_ALL_RESTRICTIONS, ["player_id", api_target]);
}
else if(button == GET_SEX_ACTION_INFO)
{
listen_mode = LISTEN_MODE_GET_SEX_ACTION_INFO;
llTextBox(llGetOwner(), "\n\nWhich sex action ID?", listen_chan);
}
else if(button == GET_PLAY_ACTION_INFO)
{
listen_mode = LISTEN_MODE_GET_PLAY_ACTION_INFO;
llTextBox(llGetOwner(), "\n\nWhich play action ID?", listen_chan);
}
else if(button == GET_TEASE_ACTION_INFO)
{
listen_mode = LISTEN_MODE_GET_TEASE_ACTION_INFO;
llTextBox(llGetOwner(), "\n\nWhich tease action ID?", listen_chan);
}
else if(button == GET_HUD_VERSION)
{
req_get_hud_version = MakeRequest(GET_HUD_VERSION, ["player_id", api_target]);
}
else if(button == HUD_DIALOG)
{
listen_mode = LISTEN_MODE_GET_DIALOG_BUTTONS;
llTextBox(llGetOwner(), "\n\nWhat buttons (CSV)?", listen_chan);
}
else if(button == CUM_IN_ORGAN)
{
listen_mode = LISTEN_MODE_CUM_IN_GET_ORGAN;
llTextBox(llGetOwner(), "\n\nWhich organ of yours?", listen_chan);
}
else if(button == CUM_IN_ORGAN)
{
listen_mode = LISTEN_MODE_CUM_IN_GET_ORGAN;
llTextBox(llGetOwner(), "\n\nWhich organ of yours?", listen_chan);
}
else if(button == KV_SET)
{
listen_mode = LISTEN_MODE_KV_SET_GET_KEY;
llTextBox(llGetOwner(), "\n\nWhat is the key?", listen_chan);
}
else if(button == KV_GET)
{
listen_mode = LISTEN_MODE_KV_GET_KEY;
llTextBox(llGetOwner(), "\n\nWhat is the key?", listen_chan);
}
else if(button == KV_DEL)
{
listen_mode = LISTEN_MODE_KV_DEL_KEY;
llTextBox(llGetOwner(), "\n\nWhat is the key?", listen_chan);
}
else if(button == KV_LIST)
{
req_get_hud_version = MakeRequest(KV_LIST, ["target", api_target]);
}
else if(button == KV_CLEAR)
{
listen_mode = LISTEN_MODE_KV_CLEAR_CONFIRM;
llDialog(llGetOwner(), "\n\nAre you sure you want to clear all KV records?", ["Yes", "No"], listen_chan);
}
else if(button == GET_IS_PLAYER_ONLINE)
{
listen_mode = LISTEN_MODE_PLAYER_ONLINE;
llTextBox(llGetOwner(), "\n\nWhat is the key of the player?", listen_chan);
}
butts += MenuButton("<Back", "sm:main", "Go back", FALSE);
butts += MenuButton("", "", "", FALSE);
butts += MenuButton(GET_VALUE, GET_VALUE, "", FALSE);
butts += MenuButton(SET_VALUE, SET_VALUE, "", FALSE);
butts += MenuButton(GET_ORGAN_VALUE, GET_ORGAN_VALUE, "", FALSE);
butts += MenuButton(SET_ORGAN_VALUE, SET_ORGAN_VALUE, "", FALSE);
butts += MenuButton(GET_CONDITIONS, GET_CONDITIONS, "", FALSE);
butts += MenuButton(GET_SPECIES, GET_SPECIES, "", FALSE);
butts += MenuButton(GET_PREGNANCY_PROGRESS, GET_PREGNANCY_PROGRESS, "", FALSE);
butts += MenuButton(GET_PREGNANCY_COUNTS, GET_PREGNANCY_COUNTS, "", FALSE);
butts += MenuButton(GET_ORGANS, GET_ORGANS, "", FALSE);
butts += MenuButton(GET_ACTIVE_SEX_ACTIONS, GET_ACTIVE_SEX_ACTIONS, "", FALSE);
butts += MenuButton(GET_ORGAN_INFO, GET_ORGAN_INFO, "", FALSE);
butts += MenuButton(MAKE_CUM, MAKE_CUM, "", FALSE);
butts += MenuButton(GET_CUM_INFO, GET_CUM_INFO, "", FALSE);
butts += MenuButton(INJECT_CUM, INJECT_CUM, "", FALSE);
butts += MenuButton(SEND_MESSAGE, SEND_MESSAGE, "", FALSE);
butts += MenuButton(GET_BREEDING_GROUND, GET_BREEDING_GROUND, "", FALSE);
butts += MenuButton(GET_BREEDING_GROUNDS, GET_BREEDING_GROUNDS, "", FALSE);
butts += MenuButton(GET_CUM_LIST, GET_CUM_LIST, "", FALSE);
butts += MenuButton(CUSTOM_CONDITION, CUSTOM_CONDITION, "", FALSE);
butts += MenuButton(GET_AVAILABLE_TITLES, GET_AVAILABLE_TITLES, "", FALSE);
butts += MenuButton(GET_INVENTORY_ITEMS, GET_INVENTORY_ITEMS, "", FALSE);
butts += MenuButton(REMOVE_CONDITION, REMOVE_CONDITION, "", FALSE);
butts += MenuButton(MODIFY_RESTRICTIONS, MODIFY_RESTRICTIONS, "", FALSE);
butts += MenuButton(GET_ALL_RESTRICTIONS, GET_ALL_RESTRICTIONS, "", FALSE);
butts += MenuButton(GET_SEX_ACTION_INFO, GET_SEX_ACTION_INFO, "", FALSE);
butts += MenuButton(GET_PLAY_ACTION_INFO, GET_PLAY_ACTION_INFO, "", FALSE);
butts += MenuButton(GET_TEASE_ACTION_INFO, GET_TEASE_ACTION_INFO, "", FALSE);
butts += MenuButton(GET_HUD_VERSION, GET_HUD_VERSION, "", FALSE);
butts += MenuButton(HUD_DIALOG, HUD_DIALOG, "", FALSE);
butts += MenuButton(CUM_IN_ORGAN, CUM_IN_ORGAN, "", FALSE);
butts += MenuButton(KV_SET, KV_SET, "", FALSE);
butts += MenuButton(KV_GET, KV_GET, "", FALSE);
butts += MenuButton(KV_DEL, KV_DEL, "", FALSE);
butts += MenuButton(KV_LIST, KV_LIST, "", FALSE);
butts += MenuButton(KV_CLEAR, KV_CLEAR, "", FALSE);
butts += MenuButton(GET_IS_PLAYER_ONLINE, GET_IS_PLAYER_ONLINE, "", FALSE);
}
else
{
llOwnerSay("Invalid menu: " + menu_name + "(" + body + ")");
}
list response = ["menu_text", menu_text,
"modal", modal,
"menu_name", menu_name,
"buttons", llList2Json(JSON_ARRAY, butts)];
butts = [];
body = llList2Json(JSON_OBJECT, response);
//llOwnerSay(body);
llHTTPResponse(id, 200, body);
}
else if(path == "signals")
{
list signals = llJson2List(llJsonGetValue(body, ["signals"]));
integer i = llGetListLength(signals);
while(~--i)
{
body = llList2String(signals, i);
method = llJsonGetValue(body, ["type"]);
if(method == "TEST")
{
llHTTPResponse(id, 200, "OK");
return;//This request will always be sent by itself. No need to continue processing.
}
else
{
//llOwnerSay("Got signal: " + method + " | " + body);
PrintResults(llJson2List(llJsonGetValue(body, ["signal"])));
}
}
llHTTPResponse(id, 200, "OK");
}
else
{
llHTTPResponse(id, 404, "");
}
}
http_response(key id, integer code, list meta, string body)
{
if(code != 200)
{
llOwnerSay("Error: " + (string)code);
}
string status = llJsonGetValue(body, ["status"]);//I recommend checking the status before further processing the response data. OK/WARN status means you should be able to process the response data normally (With WARN, you should check the 'message' value to see what's wrong).
if(id == req_menu_register)
{
if(status == "OK")
{
req_register_signals = MakeRequest(REGISTER_URL, ["player_id", llGetOwner(),
"url", earl + "/signals"]);
}
else if(status == "NOPERM")
{
llOwnerSay("Waiting for permissions...");
llSetTimerEvent(30.0);
return;
}
else
{
llOwnerSay("Failed to register plugin. Status: " + status + " | Message: " + llJsonGetValue(body, ["message"]));
}
}
else if(id == req_send_message)
{
if(status != "OK")
{
llOwnerSay("Failed to send message. Status: " + status + " | Message: " + llJsonGetValue(body, ["message"]));
}
}
else if(id == req_register_signals)
{
llOwnerSay("Connection Status: " + status + " | Message: " + llJsonGetValue(body, ["message"]));
}
else if(id == req_check_player)
{
if(status == "OK")
{
id = llJsonGetValue(body, ["results", "owner_id"]);
llOwnerSay(llKey2Name(id) + " is an ATLust player. Their character name is: " + llJsonGetValue(body, ["results", "name_title"]));
}
else if(status == "NOT_FOUND")
{
llOwnerSay("That person is not an ATLust player.");
}
else
{
llOwnerSay("Player check error: " + body);
}
}
else if(id == req_player_online)
{
if(status == "OK")
{
if(llJsonGetValue(body, ["results"]) == JSON_TRUE)
{
llOwnerSay("True");
}
else
{
llOwnerSay("False");
}
}
else
{
llOwnerSay("Failed to get info. Status: " + status + " | Message: " + llJsonGetValue(body, ["message"]));
}
}
else if(id == req_get_value || id == req_set_value || id == req_get_organ_value || id == req_set_organ_value || id == req_get_preg_count || id == req_get_organs || id == req_get_cum_info || id == req_get_breeding_grounds || id == req_get_breeding_ground || id == req_get_conditions || id == req_get_inventory || id == req_get_action_info)
{
if(status == "OK")
{
PrintResults(llJson2List(llJsonGetValue(body, ["results"])));
}
else
{
llOwnerSay("Failed to get info. Status: " + status + " | Message: " + llJsonGetValue(body, ["message"]));
}
}
else if(id == req_get_species || id == req_get_active_sex_actions)
{
if(status == "OK")
{
llOwnerSay("Results: " + llList2CSV(llJson2List(llJsonGetValue(body, ["results"]))));
}
else
{
llOwnerSay("Failed to get info. Status: " + status + " | Message: " + llJsonGetValue(body, ["message"]));
}
}
else if(id == req_get_preg_proc || id == req_get_organ_info || id == req_get_make_cum || id == req_get_cum_list || id == req_get_titles || id == req_get_restrictions || id == req_get_hud_version || id == req_kv_get || id == req_kv_list)
{
if(status == "OK")
{
llOwnerSay("Results: " + llJsonGetValue(body, ["results"]));
}
else
{
llOwnerSay("Failed to get info. Status: " + status + " | Message: " + llJsonGetValue(body, ["message"]));
}
}
else if(id == req_get_send_message || id == req_set_inject_cum || id == req_custom_condition || id == req_remove_condition || id == req_mod_restrictions || id == req_hud_dialog || id == req_cum_inside || id == req_kv_clear || id == req_kv_set || id == req_kv_clear || id == req_kv_del)
{
if(status == "OK")
{
llOwnerSay("Command successful.");
}
else
{
llOwnerSay("Failed to execute command. Status: " + status + " | Message: " + llJsonGetValue(body, ["message"]));
}
}
}
}
state removed
{
touch_start(integer num)
{
llResetScript();
}
}