BNWCS Query API
This API is still in the 'beta' stages. It is quite possible that everything may not work right. Please report any bugs to Matthias Rozensztok!
Intro
To find out information about the BNWCS with your own scripts, you will need the "BNWCS Developer's Kit."
The BNWCS Query API allows you to ask other avatars' BNWCS meters, or the BNWCS website, certain questions and receive answers.
To use the Query API, all you need to do is drop the "BNWCS.api.query.lsl" script into an object. Then, depending on what you want to know, send a linked messages to the API, and it will send you an answer back.
Query Types
To ask the Query API a question, send it a linked message in the following format:
//---------- llMessageLinked(LINK_SET , query_id , "query_type" , "query_target"); //----------
-
query_id
integer
Any number. When the Query API has an answer to your query, the negative of this number will be sent as the linked messages's integer parameter. This can help you identify and keep track of multiple simultaneous queries. -
query_type
string
A string specifying the type of query you wish to make. A table detailing the possible values of this parameter can be found below. -
query_target
string
One or more pieces of information, separated by a pipe character ( " | " ). This tells the query API what to ask about. A table detailing the required values for this parameter for all the different query_types can be found below.
A summary of the currently-accepted "query_types" and the "query_target" you need to use for each, follows:
query_type | query_target | notes |
---|---|---|
meter_state_query | Avatar_Name | |
player_stats_query | Avatar_Name | Will return all of an avatar's ranking and statistic information for the sim that the Query API script is in. |
sim_stats_query | Statistic_Name|Top_X_Avatars | You cannot get more than the top 25 avatars. |
sim_settings_query | (Nothing) | Will return the sim's custom BNWCS settings (damage multiplier, team names, etc) See also http://bnwcs.org/?zone_notes |
Return Types
When the Query API has an answer to one of your questions, it will send a linked message in the following format:
//---------- llMessageLinked(LINK_SET , -1*query_id , query_type_return , query_results); //----------
-
query_id
integer
The same number used when the query question was asked, but multiplied by -1. It's a good idea to not use 0 for your query_id. -
query_type_return
string
A string telling you what kind of response this is. Whatever the original query_type was, the word "query" will be replaced with "return". For example, the answer to a "meter_state_query" linked message would have "meter_state_return" as its string parameter. -
query_results
string
The results of the query. A detailed outline of all the different formats this string may take can be found below.
A summary of the different query_results you will get for each query_type follows. Hold your mouse over an underlined word in the 'query_results' box for an explanation of that piece of data.
query_type_return | query_results |
---|---|
meter_state_return | Avatar_UUID| Avatar_Name| Avatar_Meter_Name| Avatar_Meter_Script_Name| Avatar_Meter_Version| Avatar_Meter_State| Avatar_ActiveOnly| Avatar_HP| Avatar_Team |
no_response|Avatar_Name | |
player_stats_return | Avatar_Name|Sim_Name|stat1=value1&stat2=value2&stat3=value3... |
no_response|Avatar_Name | |
sim_stats_return | Sim_Name\n Statistic_Name\n First_Place_Name|First_Place_Number|Second_Place_Name|Second_Place_Number|....| |
no_response|Statistic_Name|Top_X_Avatars | |
sim_settings_return | sim=Sim_Name&sim_setting_1=sim_value_1&sim_setting_2=sim_value_2... |
no_response| |