Difference between revisions of "VL Furniture Devkit"

From GridPlay
Line 25: Line 25:
 
default {
 
default {
 
touch_end(integer num_detected) {
 
touch_end(integer num_detected) {
llMessageLinked(LINK_SET, LinkOut, "menu", llDetectedKey(0));
+
llMessageLinked(LINK_THIS, LinkOut, "menu", llDetectedKey(0));
//llMessageLinked(LINK_SET, LinkOut, "use", llDetectedKey(0));
+
//llMessageLinked(LINK_THIS, LinkOut, "use", llDetectedKey(0));
 
}
 
}
 
link_message(integer sender_num, integer num, string str, key id) {
 
link_message(integer sender_num, integer num, string str, key id) {
Line 32: Line 32:
 
if (llJsonValueType(str, ["uri"]) != JSON_INVALID) {
 
if (llJsonValueType(str, ["uri"]) != JSON_INVALID) {
 
                 string uri = llJsonGetValue(str, ["uri"]);
 
                 string uri = llJsonGetValue(str, ["uri"]);
                 if (uri == "confirm" || uri == "used") {
+
                 if (uri == "confirm") {
 
                 llSay(0, "Usage Confirmed");
 
                 llSay(0, "Usage Confirmed");
 
                 }
 
                 }
Line 51: Line 51:
 
string json = llList2Json(JSON_OBJECT, ["uri","menu"]);
 
string json = llList2Json(JSON_OBJECT, ["uri","menu"]);
 
key id = llDetectedKey(0);
 
key id = llDetectedKey(0);
llMessageLinked(LINK_SET, 99, json, id);
+
llMessageLinked(LINK_THIS, 99, json, id);
 
</syntaxhighlight>
 
</syntaxhighlight>
 
Options are '''menu''' and '''getstats'''
 
Options are '''menu''' and '''getstats'''
  
 
menu will open a dialog menu to '''id''' with a option to use the item
 
menu will open a dialog menu to '''id''' with a option to use the item

Revision as of 08:23, 28 July 2022

VenLife Furniture / Food DevKit
DevKitAd.png
Marketplace https://marketplace.secondlife.com/p/VenLife-Dev-Kit/23791939

Furniture / Food DevKit

Our dev kit somes with one script that can be used in items like a couch

Does require a notecard in the same prim as the core DevKit script and named vl config

All included in the package.

Only item in the package that is not full perm is the core DevKit script itself. It is set to no mod for security reasons.

  • 99 - You send a message on this channel
  • 98 - Dev Kit script sends a message on this channel

Example of how to process incoming

// Message Link channels. Please see our wiki on how this works
integer LinkIn = 98; // You send a message to this script
integer LinkOut = 99; // This sends a message out to other scripts you make
// numbers are so this script doesnt get confused with its own messages
default {
	touch_end(integer num_detected) {
		llMessageLinked(LINK_THIS, LinkOut, "menu", llDetectedKey(0));
		//llMessageLinked(LINK_THIS, LinkOut, "use", llDetectedKey(0));
	}
	link_message(integer sender_num, integer num, string str, key id) {
		if (num == LinkIn) {
			if (llJsonValueType(str, ["uri"]) != JSON_INVALID) {
                string uri = llJsonGetValue(str, ["uri"]);
                if (uri == "confirm") {
                	llSay(0, "Usage Confirmed");
                }
                if (uri == "#Stats#") {
                	//llOwnerSay(str);
                }
            }
		}
	}
}

URI are confirm and #Stats#

Stats uri will return the stats from the HUD of the person with id in JSON format

To Send a message to the script is easy

string json = llList2Json(JSON_OBJECT, ["uri","menu"]);
key id = llDetectedKey(0);
llMessageLinked(LINK_THIS, 99, json, id);

Options are menu and getstats

menu will open a dialog menu to id with a option to use the item