Editing Krafties Energy API

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
[[Category:Krafties API]]
 
{{Technical}}
 
==Quick Start==
 
  
#Drag the script and config notecard into your object or prim
+
Quick Start
#*"krafties-API_BASE [Energy]" script
 
#*"Krafties Energy API Config" notcard
 
#Edit the config notecard for the energy amounts payable to you.
 
#*You can use up to 12 amounts separated by commas. <code>0</code> = Any custom amount and allows players to say the amount they wish to give.
 
#*:Example:    <code><nowiki>ENERGY_PRICE=0,10,100,1000</nowiki></code>
 
  
===Response===
+
1. Drag the script and config notecard into your object or prim
  
Succesfull transactions will fire a linked message which can be parsed:
+
"KraftiesEnergyAPI" script
:<code><nowiki>llMessageLinked(LINK_THIS, 0, "ENERGY_GIVEN|"+fromKey+"|"+toKey+"|"+(string)amount, "");</nowiki></code>
 
  
===An Example Script===
+
"Krafties Energy API Config" notcard
 +
       
  
This is an example script, which would be placed into an object alongside the Energy API script and config notecard. This example gives the first object found in the Energy API object's inventory when someone interacts with it and transfers energy through the object. It essentially acts as a simple, barebones vendor.
+
2. Edit the config notecard for the energy amounts payable to you.
  
NOTE: You'll have to set the energy amount button in the config notecard to match the PRICE variable!
+
You can use upto 12 amounts seperated by commas. 0 = Any custom amount and allows players to say the amount they wish to give.
<pre><nowiki>
 
integer PRICE = 100;
 
  
default {
+
Example:   ENERGY_PRICE=0,10,100,1000
    link_message(integer senderNum, integer num, string message, key id) {
 
        // Message is sent in form: llMessageLinked(LINK_THIS, 0, "ENERGY_GIVEN|"+fromKey+"|"+toKey+"|"+(string)amount, "");
 
        list parts = llParseString2List(message, ["|"], []);
 
        string operation = llList2String(parts, 0);
 
 
          
 
          
        if (operation == "ENERGY_GIVEN") {
 
            key fromKey = llList2Key(parts, 1);
 
            key toKey = llList2Key(parts, 2);
 
            integer energyAmount = llList2Integer(parts, 3);
 
           
 
            if (energyAmount == PRICE) {
 
                llGiveInventory(fromKey, llGetInventoryName(INVENTORY_OBJECT, 0)); // Give the first object found in contents to the energy sender
 
            }
 
        }
 
    }
 
}
 
</nowiki></pre>
 
  
==Notes==
+
Response
*Only transferable energy can be given
+
 
 +
Succesfully transactions will fire a linked message which can be parsed:
 +
 
 +
llMessageLinked(LINK_THIS, 0, "ENERGY_GIVEN|"+fromKey+"|"+toKey+"|"+(string)amount, "");

Please note that all contributions to Krafties may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Copyrights for details). Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Templates used on this page: