|
|
(4 intermediate revisions by 3 users not shown) |
Line 1: |
Line 1: |
− | = Krafties - Spell Receiver API v1.0 =
| |
− |
| |
− | ~~ NOTE: You MUST obtain an API key from Krafties before being able to use any of the Krafties APIs! This key is unique to each individual creator and should not be shared.
| |
− |
| |
− | ~~ Please see http://krafties.com/wiki for more details on the API and API keys.
| |
− |
| |
− |
| |
− | The Spell Receiver API allows player owned krafties to cast specific spells on any objects you create! The API allows you to then handle and respond to the spells when they are cast with ANY LSL code you put together via linked messages. At this point in time, when a spell is cast the API exposes the name of the spell that was cast, and the type of spell cast. These are all handled in a link_message event.
| |
− |
| |
− |
| |
− |
| |
− | ---------------------------------------------------------------------------------------
| |
− | SETUP:
| |
− | ---------------------------------------------------------------------------------------
| |
− | Step 1) Obtain your unique API Key. If you already have an API Key from a separate Krafties API, that will work for this one as well!
| |
− |
| |
− |
| |
− | Step 2) Drop both the "Krafties-API_spellReceiver v1.0" and "KRAFTIES_API Config [SpellReceiver]" scripts into the object you wish to have Krafties spells cast on
| |
− |
| |
− |
| |
− | Step 3) Open and configure the "Krafties_API Config [Spell Receiver]" script. All configuration variables are at the top of the script.
| |
− | a) API_KEY:
| |
− | - This is the key you get from Krafties that identifies you as a unique creator. Once you have obtained your key, copy/paste it into the script where it says UNIQUE_API_KEY_HERE.
| |
− | b) SPELL_DISPLAY_TYPES
| |
− | - This list determines what types of spells will show up in the menus of a player attempting to cast a spell on this object, if the player's creature has unlocked said spells. Alongside the predefined spell group identifiers, you can also include the names of specific spells or specific element types. Spell group identifiers follow:
| |
− | * SET_SPELL
| |
− | - Displays spells that show up when a player clicks their creature, selects "Battles", then selects "Set Spell"
| |
− | * OTHER_ACTIVE
| |
− | - Displays spells that show up when a player clicks on another player's active creature and then selects "Cast Spell"
| |
− | * WILD
| |
− | - Displays spells that show up when a player clicks on a wild creature, then selects "Cast Spell"
| |
− | * SELF
| |
− | - Displays spells that show up when a player clicks on their own active creature, then selects "Cast Spell"
| |
− | * OPPONENT
| |
− | - Displays spells that show up when a player clicks on an opposing creature in PvP battle
| |
− | * TEAMMATE
| |
− | - Displays spells that show up when a player clicks in a teammate in PvP battle
| |
− | * ENCHANT
| |
− | - Displays spells that show up when a creature clicks an enchanting tablet, then selects "Cast Spell"
| |
− | * ALCHEMY
| |
− | - Displays spells that show up when a creature clicks an alchemy tablet, then selects "Cast Spell"
| |
− |
| |
− |
| |
− | Step 4) Save the "Krafties_API Config [Spell Receiver]" script.
| |
− |
| |
− |
| |
− | *** IF ALL WENT WELL, YOU NOW HAVE THE BASIC SPELL CASTING FEATURES SET UP. CLICKING THE OBJECT WILL GIVE YOU A MENU ALLOWING YOU TO CAST SPELLS ON IT IF YOU HAVE A SUITABLE ACTIVE KRAFTIE ATTACHED.
| |
− |
| |
− | *** ADVANCED STEPS FOLLOW
| |
− |
| |
− |
| |
− | You are now ready to handle spells being cast, either in the link_message event of the "KRAFTIES_API Config [SpellReceiver]" script itself or your own script residing in the same object. Note that if you do use your own script, you will want to remove the llSay() provided in the "KRAFTIES_API Config [SpellReceiver]" so as not to detract from the experience you create.
| |
− |
| |
− | When a spell is cast, this function is called:
| |
− | - llMessageLinked(LINK_SET, 59377, spellName, spellType);
| |
− |
| |
− | What this does parameter by parameter:
| |
− | - assuming link_message event structure of: link_message(integer senderNum, integer num, string message, key id)
| |
− | * LINK_SET: message is sent to ALL prims in the link set
| |
− | * 59377: message is broadcast with a number identifier of 59377
| |
− | - FUN FACT: to 59377 resembles the word "SPELL"
| |
− | - In your link_message events, you'll want to check if (num == 59377) to verify it is a spell message
| |
− | * spellName: the message parameter holds the name of the spell cast
| |
− | - in script: string spellName = message;
| |
− | * spellType: the id parameter holds the element type of spell cast
| |
− | - In script: string spellType = (string)id;
| |
− | * Cast to string because actual type of id is key
| |
− |
| |
− | EXAMPLE:
| |
− | - Fireplace that lights when any fire spell is cast on it
| |
− | * In config step:
| |
− | - list SPELL_DISPLAY_TYPES = ["Fire"];
| |
− | * IF FLAMETHROWER IS CAST:
| |
− | - Link message sent: llMessageLinked(LINK_SET, 59377, "Flamethrower", "Fire");
| |
− | ---------------------------------------------------------------------------------------
| |
− |
| |
− | ---------------------------------------------------------------------------------------
| |
− |
| |
− |
| |
− |
| |
− | = Creature/Pet API =
| |
− |
| |
− | :The Krafties Scripting API is a feature which allows you to get data from your Kraftie Creature for your own scripted third party addons.
| |
− | :Currently this is read only although gives access to a wide range of possibilities.
| |
− | :This API relies on listening to 1 minute pings on channel '''<code>-748382747</code>''' from inworld Krafties Creatures.
| |
− | :Creatures will communicate on this channel once <code>on_rez</code> and then every 60 seconds.
| |
− |
| |
− | Message format is a string delimited by <code>|</code> containing every prim UUID. (16 Prims)
| |
− | :<code><nowiki>prim1UUID|prim2UUID|prim3UUID|prim4UUID|prim5UUID|prim6UUID|prim7UUID|prim8UUID|prim9UUID|prim10UUID|prim11UUID|prim12UUID|prim13UUID|prim14UUID|prim15UUID|prim16UUID</nowiki></code>
| |
− |
| |
− |
| |
− | Parsing this string to a list you can get the prims data from the description using <code><nowiki>llGetObjectDetails (PRIM_DESC or PRIM_NAME)</nowiki></code>
| |
− |
| |
− |
| |
− | ===PRIM DESCRIPTION FORMATS===
| |
− |
| |
− | *'''Prim 1 Description:''' <code><nowiki>"Bonded "+(string)species+ " - "+(string)elementType</nowiki></code>
| |
− |
| |
− | *'''Prim 2 Description:''' <code><nowiki>(string)creatureID()+";"+(string)elementType+";"+(integer)unixTimeCaught+";"+(string)elementAffinity</nowiki></code>
| |
− |
| |
− | *'''Prim 3 Description:''' <code><nowiki>(string)battleStyle</nowiki></code>
| |
− |
| |
− | *'''Prim 4 Description:''' <code><nowiki>(integer)hitpoints</nowiki></code>
| |
− |
| |
− | *'''Prim 5 Description:''' <code><nowiki>(string)volumeString+";"+(float)volumeFloat</nowiki></code>
| |
− |
| |
− | *'''Prim 6 Description:''' <code><nowiki>(integer)attackBonusLevels+","+(integer)strengthBonusLevels+","+(integer)defenseBonusLevels+","+(integer)hitpointsBonusLevels+","+(integer)craftingBonusLevels+";"+(integer)intellectBonusLevels+";"+(integer)focusBonusLevels+";"+(integer)fortitudeBonusLevels+";"+(float)attackBonusMult+","+(float)strengthBonusMult+","+(float)defenseBonusMult+","+(float)hitpointsBonusMult+","+(float)craftingBonusMult+","+(float)intellectBonusMult+","+(float)focusBonusMult+","+(float)fortitudeBonusMult</nowiki></code>
| |
− |
| |
− | *'''Prim 7 Description:''' <code><nowiki>(float)attackNaturalMult+","+(float)attackNaturalMult+","+(float)strengthNaturalMult+","+(float)defenseNaturalMult+","+(float)hitpointsNaturalMult+","+(float)intellectNaturalMult+","+(float)focusNaturalMult+","+(float)fortitudeNaturalMult</nowiki></code>
| |
− |
| |
− | *'''Prim 8 Description:''' <code><nowiki>(integer)recentAttackExp+","+(integer)recentAttackExp+","+(integer)recentStrengthExp+","+(integer)recentDefenseExp+","+(integer)recentHitpointsExp+","+(integer)recentCraftingExp+","+(integer)recentIntellectExp+","+(integer)recentFocusExp+","+(integer)recentFortitudeExp+","+(key)expEarnerPlayerKey</nowiki></code>
| |
− |
| |
− | *'''Prim 9 Description:''' <code><nowiki>(integer)isInPvp+";"+(integer)isInCrafting+";"+(integer)isHovertextOn</nowiki></code>
| |
− |
| |
− | *'''Prim 10 Description:''' <code><nowiki>(integer)playerExpEarnedLast24Hours + "," + (integer)playerExpEarnedLastWeek + "," + (integer)playerExpEarnedLastMonth + "," + (integer)playerExpEarnedAllTime + "," + (integer)battlesWonLast24Hours+ "," + (integer)battlesWonLast24Week + "," + (integer)battlesWonLast24Month + "," + (integer)battlesWonAllTime</nowiki></code>
| |
− |
| |
− | *'''Prim 11 Description:''' <code><nowiki>(integer)getAffinity</nowiki></code>
| |
− |
| |
− | *'''Prim 12 Description:''' <code><nowiki>(string)llList2CSV(weaknesses)</nowiki></code>
| |
− |
| |
− | *'''Prim 13 Description:''' <code><nowiki>(integer)silverMembershipExpiryUnixTime+";"+(integer)goldMembershipExpiryUnixTime</nowiki></code>
| |
− |
| |
− | *'''Prim 14 Description :''' <code><nowiki>(string)currentSpell</nowiki></code>
| |
− |
| |
− | *'''Prim 15 Description:''' UNUSED
| |
− |
| |
− | *'''Prim 16 Description:''' <code><nowiki>(integer)attackLevel+","+(integer)strengthLevel+","+(integer)defenseLevel+","+(integer)hitpointsLevel+","+(integer)craftingLevel+","+(integer)intellectLevel+","+(integer)focusLevel+","+(integer)fortitudeLevel+";"+(integer)attackExp+","+(integer)strengthExp+","+(integer)defenseExp+","+(integer)hitpointsExp+","+(integer)craftingExp+","+(integer)intellectExp+","+(integer)focusExp+","+(integer)fortitudeExp</nowiki></code>
| |
− |
| |
− | *'''Prim 3 Name:''' <code><nowiki>(string)attackXpLeft+","+(string)strengthXpLeft+","+(string)defenseXpLeft+","+(string)hpXpLeft+","+(string)craftXpLeft+","+(string)intellectXpLeft+","+(string)focusXpLeft+","+(string)fortitudeXpLeft</nowiki></code>
| |
− |
| |
− | *'''Prim 5 Name:''' <code><nowiki>(integer)allowBattleAssistance</nowiki></code>
| |
− |
| |
− |
| |
− | === Creature Spell ===
| |
− |
| |
− | Worn Krafties pets will communicate on channel '''<code>-748382747</code>''' each time a spell is cast from the Cast Spell menu.
| |
− |
| |
− |
| |
− | === Overall Level ===
| |
− |
| |
− | <code><nowiki>llRound( (combatLevel + craftingLevel + mentalLevel)/(float)3.0 )</nowiki></code>
| |
− |
| |
− | = Wild API =
| |
− |
| |
− | Sensor nearby wilds, using sensor to grab the wild UUID. Using <code><nowiki>llGetObjectDetails (PRIM_DESC)</nowiki></code>, parse the description accordingly.
| |
− |
| |
− | Experience fields are void and temporary data which should not be used.
| |
− |
| |
− | Format is the same on Regular or Giant wilds.
| |
− |
| |
− |
| |
− | '''Prim 1 Description:''' <code><nowiki>(integer)currentHealth+";"+(integer)attackLevel+","+(integer)strengthLevel+","+(integer)defenseLevel+","+(integer)hitpointsLevel+","+(integer)craftingLevel+","+(integer)intellectLevel+","+(integer)focusLevel+","+(integer)fortitudeLevel+";"+(integer)attackExpVoid+","+(integer)strengthExpVoid+","+(integer)defenseExpVoid+","+(integer)hitpointsExpVoid+","+(integer)craftingExpVoid+","+(integer)intellectExpVoid+","+(integer)focusExpVoid+","+(integer)fortitudeExpVoid</nowiki></code>
| |
− |
| |
− | = Battles API =
| |
− |
| |
− | The Krafties Battle Scripting API is a feature which allows you to get data from your battles for your own scripted third party addons such as scoreboards, contest/tournament boards or other assisting objects.
| |
− |
| |
− | Currently this is read only although gives access to a wide range of possibilities.
| |
− |
| |
− | This API relies on listening on channel '''<code>-748382748</code>''' from inworld Battle temples.
| |
− |
| |
− |
| |
− | Battle temples will communicate on different events:
| |
− |
| |
− | *Battle Start
| |
− |
| |
− | *Battle End
| |
− |
| |
− | *Player Eliminated
| |
− |
| |
− | These messages will be send on the corresponding event. There are 2 lists delimited by <code>","</code> & <code>"|"</code> into a string.
| |
− |
| |
− | By matching <code>matchID</code> you will be able to link temples for successful battles.
| |
− |
| |
− |
| |
− | *<code><nowiki>list playersData = [playerKey, petKey, petID, petLevel, manaLeft, energyLeft, lastPingTime, playerKey, petKey, petID, petLevel, manaLeft, energyLeft, lastPingTime];</nowiki></code> // 2 players strided by 7
| |
− | *<code><nowiki>list eliminatedPlayersData = [playerKey, petKey, petID, petLevel, manaLeft, energyLeft, lastPingTime, playerKey, petKey, petID, petLevel, manaLeft, energyLeft, lastPingTime, playerKey, petKey, petID, petLevel, manaLeft, energyLeft, lastPingTime];</nowiki></code> // 3 players strided by 7
| |
− |
| |
− | *<code><nowiki>"PLAYER_ELIMINATED|"+(string)matchID+"|"+(string)playerKey+"|"+llDumpList2String(playersData, ",")+"|"+llDumpList2String(eliminatedPlayersData, ","));</nowiki></code>
| |
− |
| |
− | *<code><nowiki>"BATTLE_ENDED|"+(string)matchID+"|"+(string)win+"|"+llDumpList2String(playersData, ",")+"|"+llDumpList2String(eliminatedPlayersData, ","));</nowiki></code>
| |
− |
| |
− | *<code><nowiki>"BATTLE_STARTED|"+(string)matchID+"|"+battleMode+"|"+llDumpList2String(playersData, ",") );</nowiki></code>
| |
− |
| |
− |
| |
− |
| |
− |
| |
− |
| |
− |
| |
| [[Category:Krafties API]] | | [[Category:Krafties API]] |
| <!-- I added the "code"tags to make the code stand out, and the "nowiki" to prevent the wiki from formatting any of the code when it wasn't supposed to --> | | <!-- I added the "code"tags to make the code stand out, and the "nowiki" to prevent the wiki from formatting any of the code when it wasn't supposed to --> |
Line 227: |
Line 38: |
| *'''Prim 10 Description:''' <code><nowiki>(integer)playerExpEarnedLast24Hours + "," + (integer)playerExpEarnedLastWeek + "," + (integer)playerExpEarnedLastMonth + "," + (integer)playerExpEarnedAllTime + "," + (integer)battlesWonLast24Hours+ "," + (integer)battlesWonLast24Week + "," + (integer)battlesWonLast24Month + "," + (integer)battlesWonAllTime</nowiki></code> | | *'''Prim 10 Description:''' <code><nowiki>(integer)playerExpEarnedLast24Hours + "," + (integer)playerExpEarnedLastWeek + "," + (integer)playerExpEarnedLastMonth + "," + (integer)playerExpEarnedAllTime + "," + (integer)battlesWonLast24Hours+ "," + (integer)battlesWonLast24Week + "," + (integer)battlesWonLast24Month + "," + (integer)battlesWonAllTime</nowiki></code> |
| | | |
− | *'''Prim 11 Description:''' <code><nowiki>(integer)getAffinity</nowiki></code> | + | *'''Prim 11 Description:''' <code><nowiki>(integer)spellsCanBeCastOnThisCreatureBool</nowiki></code> |
| | | |
| *'''Prim 12 Description:''' <code><nowiki>(string)llList2CSV(weaknesses)</nowiki></code> | | *'''Prim 12 Description:''' <code><nowiki>(string)llList2CSV(weaknesses)</nowiki></code> |
| | | |
− | *'''Prim 13 Description:''' <code><nowiki>(integer)silverMembershipExpiryUnixTime+";"+(integer)goldMembershipExpiryUnixTime</nowiki></code> | + | *'''Prim 13 Description:''' <code><nowiki>(integer)allowSpellAssistance</nowiki></code> |
| | | |
| *'''Prim 14 Description :''' <code><nowiki>(string)currentSpell</nowiki></code> | | *'''Prim 14 Description :''' <code><nowiki>(string)currentSpell</nowiki></code> |
Creature/Pet API[edit]
- The Krafties Scripting API is a feature which allows you to get data from your Kraftie Creature for your own scripted third party addons.
- Currently this is read only although gives access to a wide range of possibilities.
- This API relies on listening to 1 minute pings on channel
-748382747
from inworld Krafties Creatures.
- Creatures will communicate on this channel once
on_rez
and then every 60 seconds.
Message format is a string delimited by |
containing every prim UUID. (16 Prims)
prim1UUID|prim2UUID|prim3UUID|prim4UUID|prim5UUID|prim6UUID|prim7UUID|prim8UUID|prim9UUID|prim10UUID|prim11UUID|prim12UUID|prim13UUID|prim14UUID|prim15UUID|prim16UUID
Parsing this string to a list you can get the prims data from the description using llGetObjectDetails (PRIM_DESC or PRIM_NAME)
PRIM DESCRIPTION FORMATS[edit]
- Prim 1 Description:
"Bonded "+(string)species+ " - "+(string)elementType
- Prim 2 Description:
(string)creatureID()+";"+(string)elementType+";"+(integer)unixTimeCaught+";"+(string)elementAffinity
- Prim 3 Description:
(string)battleStyle
- Prim 4 Description:
(integer)hitpoints
- Prim 5 Description:
(string)volumeString+";"+(float)volumeFloat
- Prim 6 Description:
(integer)attackBonusLevels+","+(integer)strengthBonusLevels+","+(integer)defenseBonusLevels+","+(integer)hitpointsBonusLevels+","+(integer)craftingBonusLevels+";"+(integer)intellectBonusLevels+";"+(integer)focusBonusLevels+";"+(integer)fortitudeBonusLevels+";"+(float)attackBonusMult+","+(float)strengthBonusMult+","+(float)defenseBonusMult+","+(float)hitpointsBonusMult+","+(float)craftingBonusMult+","+(float)intellectBonusMult+","+(float)focusBonusMult+","+(float)fortitudeBonusMult
- Prim 7 Description:
(float)attackNaturalMult+","+(float)attackNaturalMult+","+(float)strengthNaturalMult+","+(float)defenseNaturalMult+","+(float)hitpointsNaturalMult+","+(float)intellectNaturalMult+","+(float)focusNaturalMult+","+(float)fortitudeNaturalMult
- Prim 8 Description:
(integer)recentAttackExp+","+(integer)recentAttackExp+","+(integer)recentStrengthExp+","+(integer)recentDefenseExp+","+(integer)recentHitpointsExp+","+(integer)recentCraftingExp+","+(integer)recentIntellectExp+","+(integer)recentFocusExp+","+(integer)recentFortitudeExp+","+(key)expEarnerPlayerKey
- Prim 9 Description:
(integer)isInPvp+";"+(integer)isInCrafting+";"+(integer)isHovertextOn
- Prim 10 Description:
(integer)playerExpEarnedLast24Hours + "," + (integer)playerExpEarnedLastWeek + "," + (integer)playerExpEarnedLastMonth + "," + (integer)playerExpEarnedAllTime + "," + (integer)battlesWonLast24Hours+ "," + (integer)battlesWonLast24Week + "," + (integer)battlesWonLast24Month + "," + (integer)battlesWonAllTime
- Prim 11 Description:
(integer)spellsCanBeCastOnThisCreatureBool
- Prim 12 Description:
(string)llList2CSV(weaknesses)
- Prim 13 Description:
(integer)allowSpellAssistance
- Prim 14 Description :
(string)currentSpell
- Prim 15 Description: UNUSED
- Prim 16 Description:
(integer)attackLevel+","+(integer)strengthLevel+","+(integer)defenseLevel+","+(integer)hitpointsLevel+","+(integer)craftingLevel+","+(integer)intellectLevel+","+(integer)focusLevel+","+(integer)fortitudeLevel+";"+(integer)attackExp+","+(integer)strengthExp+","+(integer)defenseExp+","+(integer)hitpointsExp+","+(integer)craftingExp+","+(integer)intellectExp+","+(integer)focusExp+","+(integer)fortitudeExp
- Prim 3 Name:
(string)attackXpLeft+","+(string)strengthXpLeft+","+(string)defenseXpLeft+","+(string)hpXpLeft+","+(string)craftXpLeft+","+(string)intellectXpLeft+","+(string)focusXpLeft+","+(string)fortitudeXpLeft
- Prim 5 Name:
(integer)allowBattleAssistance
Creature Spell[edit]
Worn Krafties pets will communicate on channel -748382747
each time a spell is cast from the Cast Spell menu.
Overall Level[edit]
llRound( (combatLevel + craftingLevel + mentalLevel)/(float)3.0 )
Wild API[edit]
Sensor nearby wilds, using sensor to grab the wild UUID. Using llGetObjectDetails (PRIM_DESC)
, parse the description accordingly.
Experience fields are void and temporary data which should not be used.
Format is the same on Regular or Giant wilds.
Prim 1 Description: (integer)currentHealth+";"+(integer)attackLevel+","+(integer)strengthLevel+","+(integer)defenseLevel+","+(integer)hitpointsLevel+","+(integer)craftingLevel+","+(integer)intellectLevel+","+(integer)focusLevel+","+(integer)fortitudeLevel+";"+(integer)attackExpVoid+","+(integer)strengthExpVoid+","+(integer)defenseExpVoid+","+(integer)hitpointsExpVoid+","+(integer)craftingExpVoid+","+(integer)intellectExpVoid+","+(integer)focusExpVoid+","+(integer)fortitudeExpVoid
Battles API[edit]
The Krafties Battle Scripting API is a feature which allows you to get data from your battles for your own scripted third party addons such as scoreboards, contest/tournament boards or other assisting objects.
Currently this is read only although gives access to a wide range of possibilities.
This API relies on listening on channel -748382748
from inworld Battle temples.
Battle temples will communicate on different events:
These messages will be send on the corresponding event. There are 2 lists delimited by ","
& "|"
into a string.
By matching matchID
you will be able to link temples for successful battles.
list playersData = [playerKey, petKey, petID, petLevel, manaLeft, energyLeft, lastPingTime, playerKey, petKey, petID, petLevel, manaLeft, energyLeft, lastPingTime];
// 2 players strided by 7
list eliminatedPlayersData = [playerKey, petKey, petID, petLevel, manaLeft, energyLeft, lastPingTime, playerKey, petKey, petID, petLevel, manaLeft, energyLeft, lastPingTime, playerKey, petKey, petID, petLevel, manaLeft, energyLeft, lastPingTime];
// 3 players strided by 7
"PLAYER_ELIMINATED|"+(string)matchID+"|"+(string)playerKey+"|"+llDumpList2String(playersData, ",")+"|"+llDumpList2String(eliminatedPlayersData, ","));
"BATTLE_ENDED|"+(string)matchID+"|"+(string)win+"|"+llDumpList2String(playersData, ",")+"|"+llDumpList2String(eliminatedPlayersData, ","));
"BATTLE_STARTED|"+(string)matchID+"|"+battleMode+"|"+llDumpList2String(playersData, ",") );