User:Daemonika Nightfire/Scripts/Advent Giver
Jump to navigation
Jump to search
*DS* Advent Giver v1.0.09
This script sends a different item to everyone who clicks on it every day of Advent. Group mode is also possible.
/*
*DS* Advent Giver (UTC time zone)
Place 24 gifts in the content of this giver and enter the names in the desired order in the list.
This script automatically selects an item for each day from the provided list.
Example: On 6th december you will receive the 6th item from the list.
It is recommended that you only insert gifts that can be copied, because everyone can click multiple times.
This means that no Redelivery is required for the gifts.
*/
// Replace the 24 entries with the names of the gifts between the quotation marks.
list items = [
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
"ten",
"eleven",
"twelve",
"thirteen",
"fourteen",
"fifteen",
"sixteen",
"seventeen",
"eighteen",
"nineteen",
"twenty",
"twenty-one",
"twenty-two",
"twenty-three",
"twenty-four"
];
// Set TRUE if you only want to send the gifts to group members.
// Set FALSE if you want to send the gifts to everyone.
integer group_mode = FALSE;
// Enter the key(uuid) of your group here.
key group_uuid = "6fcac03d-2c09-d5a7-e73f-ff73e15965d4";
// NOTHING TO DO BELOW THIS LINE
// _______________________________________________________________________________________________________
integer date2num(string data)
{
list parsed = llParseString2List(data, ["-"], []);
//string year = llList2String(parsed, 0);
string month = llList2String(parsed, 1);
string day = llList2String(parsed, 2);
if(month != "12") // It only works with this in december.
{
return -1;
}
return (integer)day;
}
integer error = 0;
CheckInv()
{
integer count = llGetInventoryNumber(INVENTORY_OBJECT);
llSetText("floating text disappears after setup\nItems loaded: " + (string)count, <1,1,1>, 1.0);
integer length = llGetListLength(items);
integer i = 0;
do
{
string name = llList2String(items, i);
if(llGetInventoryType(name) != INVENTORY_OBJECT)
{
error++;
llOwnerSay("/me misspelled or missing item: " + name);
}
}
while(++i < length);
if(error == 0)
{
llSetText("", <1,1,1>, 1.0);
}
}
default
{
state_entry()
{
CheckInv();
}
touch_start(integer total_number)
{
key agent = llDetectedKey(0);
integer index = date2num(llGetDate());
if(index > 0 && index < 25) // This means that Advent is limited from 1 - 24
{
string current_item = llList2String(items, index-1);
//llSay(0, current_item);
if(error == 0)
{
if(!group_mode)
{
llGiveInventory(agent, current_item);
}
else if(group_mode)
{
integer group = llSameGroup(agent);
if(group)
{
llGiveInventory(agent, current_item);
}
else
{
llRegionSayTo(agent, 0, "Please join the group secondlife:///app/group/" + (string)group_uuid + "/about first.");
}
}
}
else
{
llOwnerSay("Please correct your list, one or more items cannot be found.");
}
}
else
{
llRegionSayTo(agent, 0, "I'm sorry, it's not the Advent season.");
}
}
changed(integer ch)
{
if(ch & CHANGED_INVENTORY)
{
CheckInv();
}
}
on_rez(integer Dae)
{
llResetScript();
}
}