Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Script employment. Help wanted!

Peej Makira
Registered User
Join date: 18 Oct 2006
Posts: 6
10-29-2006 08:49
Just to get this straight I am not soliciting. I attempted to read all of the boards rules and guidelines, but did you see how long that thing is?

I'm trying to figure out a script that would go into an object (yea, i know, they all do), when the user clicked on it it would ask for a handful of pieces of information. For example perhaps a poll:

How do you like the general appearance of this land?

How many times have you visited here approximately?


The script would then email the inputed material to my email address stating at the least the answers. if questions could be included, that'd be swell too but not necessary.
Then make the script automatically send me an email with the persons answers. Any suggestions or ideas. Though I cannot solicit on here I don't think, I'd be much obliged and would offer a gift of some Lindens for being so kind.

The email could have a subject but I wouldn't lose any sleep if it didnt? It would be super neat and best case scenario if in fact it would also offer, not mandate, the person making the comments a confirmation email of what they had submitted. If i need to clarify anything or if this isnt possible could someone please let me know. I really am not sure what I am game for on second life right now but i want to get serious. Script learning to me isnt for everyone i guess.

thanks in advance either way!
Thanto Usitnov
Lord Byron wannabe
Join date: 4 Aug 2006
Posts: 68
10-29-2006 09:55
What kind of answers are you looking for? Is this a multiple choice or open question kind of deal? If it's the former, you could use a series of llDialog()s. If the latter, you'll have to use llListen()s keyed to the user who just touched it. In both cases, you should probably create a list, then plug the strings from your information gathering method (llDialog or llListen) into it, then convert it into a CSV (Comma Seperated Value) using llList2CSV(), which you can then email to yourself using llEmail.
Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
10-29-2006 11:24
You might just want to have the object give them a notecard with all the questions on it when they touch it. Then they can fill in their answers any way they like and either drop it in another prim which you can check and/or have notify you when it receives a new card, or you can ask them to just drop the card on your profile and it will come directly to you.

I've seen this done with a research project a college student was doing on SL and it worked fine (she just had us drop the card on her profile.)

You could even use the lldialog menu to ask them if they even want to participate, as in click yes or no. Yes gets the notecard, no gets a polite message thanking them for their time.
_____________________
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
10-29-2006 14:24
if you did something like Thanto Usitnov suggested you can take tha CSV you get in your email and drop all your data into a spreadsheet and make a spiffy chart or average it out (ect fun spreadsheet things)

Vares Solvang's idea seems like alot less PITA if your not interested in learning scripting itself
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
10-29-2006 15:58
From: Osgeld Barmy
if you did something like Thanto Usitnov suggested you can take tha CSV you get in your email and drop all your data into a spreadsheet and make a spiffy chart or average it out (ect fun spreadsheet things)

Vares Solvang's idea seems like alot less PITA if your not interested in learning scripting itself



There are no FUN SPREADSHEET THINGS!!!!!!!
Jesseaitui Petion
king of polynesia :P
Join date: 2 Jan 2006
Posts: 2,175
10-29-2006 16:09
not sure if you are wanting this to market but if youre just looking for somehting to put in your store luc aubert sells a clipboard that does this over at his shop in Jessie. (I think he has other shops too, but thats where i got mine)
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
10-29-2006 17:16
From: Newgate Ludd
There are no FUN SPREADSHEET THINGS!!!!!!!


im sorry i forgot to hit the sarcastic button
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
10-30-2006 04:52
From: Osgeld Barmy
im sorry i forgot to hit the sarcastic button



No I worked with a Guy who did think Excel was fun to play with,
mind you he was a stamp collector...

Having just had to wriet and then rewrite some C++ code to generate Excel spreadsheets because the managers are too dumb and too lazy to read in a CSV file I HATE Excel more than ever.
Peej Makira
Registered User
Join date: 18 Oct 2006
Posts: 6
Thanks!
10-30-2006 08:49
Your answers were rewarding as always. Thanks!
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
11-01-2006 15:06
Knocked this up, not sure if its anything like what you where after but....


Basically a notecard driven 'Quiz' Engine with emailed answers

CODE
// Quiz Master v1.0
//
// Simple Dialog based question system with email support
// Primary reason would be as questionaire but could be adapted to a quiz by using the PRIZE and WIN Options
// Use the first answer as always being the right one, the answer order is randomised each time it is read.
// To Give a prize every time use PRIZE or PRIZE MONEY
// To give only if they win use WIN and WIN MONEY
//
// Uses a single Notecard to define all of the questions.
//
// Format of Note Card
//
// QUIZ NAME=My Silly little Quiz
// EMAIL=myemail@myserver
// +-START OF QUIZ-+
// QUESTION=What would you like to do?
// ANSWER=My Answer 1
// ANSWER=My Answer 2
// ANSWER=My Answer 3
// PRIZE=MyPrize
// PRIZE MONEY=5
// WIN=MyPrize
// WIN MONEY=5
// +-END OF QUESTION-+
// QUESTION=Where would you like to do it?
// ANSWER=My Answer 1
// ANSWER=My Answer 2
// ANSWER=My Answer 3
// +-END OF QUESTION-+
// PRIZE=MyPrize
// PRIZE MONEY=5
// +-END OF QUIZ-+
//
// PRIZE will give this gift wether the user answers the question correctly or not
// PRIZE MONEY will give the user the amount wether they are right or not
// WIN will only give the prize if they win
// WIN MONEY will like wise only give that amount if they win.
//
string notecard = "Questions";
integer lineCounter;
key dataRequestID;

string Email;
string QuizName;
string Question;
list Answers;
string Prize;
integer PrizeMoney = 0;
string WinPrize;
integer WinMoney = 0;

list Randomised;

integer listenchannel = 0;
integer Listening = 0;
integer i;

key User;
string UserName;
string results;

integer first;
integer pagesize = 10;

integer len;

//-------------------------------------------------------
ErrorMessage(string error)
{
llInstantMessage(llGetOwner(),llGetObjectName() + " : " + error);
}
//-------------------------------------------------------
UpdateListen(key id)
{
CancelListen();
Listening = llListen(listenchannel,"",id,"");
llSetTimerEvent(30);
}
//-------------------------------------------------------
CancelListen()
{
if(Listening > 0) llListenRemove(Listening);
Listening = 0;
llSetTimerEvent(0);
}
//-------------------------------------------------------
ProcessData(string data)
{
list ldata = llParseString2List(data, ["="], [""]);
string command = llList2String(ldata,0);
string value = llList2String(ldata,1);
if("QUESTION" == command)
{
Question = value;
Answers = [];
Prize = "";
PrizeMoney = 0;
WinPrize = "";
WinMoney = 0;
}
else if("ANSWER" == command)
{
Answers = (Answers = []) + Answers + [ value ];
}
else if("QUIZ NAME" == command)
{
QuizName = value;
}
else if("EMAIL" == command)
{
Email = value;
}
else if("PRIZE" == command)
{
Prize = value;
}
else if("PRIZE" == command)
{
Prize = value;
}
else if("PRIZE MONEY" == command)
{
PrizeMoney = (integer)value;
}
else if("WIN" == command)
{
WinPrize = value;
}
else if("WIN MONEY" == command)
{
WinMoney = (integer)value;
}
}
//-------------------------------------------------------
AskTheQuestion()
{
list choices = ["Quit"];

// Now add the Answers
len = llGetListLength( Randomised );
if(first > 0)
choices += "Prev";
if(len > (first + pagesize))
{
choices += "Next";
}

for(i = 0;i < pagesize;i++)
{
string strname = llList2String(Randomised,(i+first));
if( llStringLength(strname) > 0)
{
choices += (strname);
}
}
// finally show the dialog
llDialog(User,Question,choices,listenchannel);
UpdateListen(User);

}
//-------------------------------------------------------
HandlePrizes(string gift, integer amount)
{
if(llStringLength(gift) > 0)
{
if(llGetInventoryType(gift) != INVENTORY_NONE)
llGiveInventory(User,gift);
}
if(amount > 0)
{
llGiveMoney(User, amount);
}
}
//-------------------------------------------------------
GivePrizes(integer right)
{
HandlePrizes(Prize, PrizeMoney);
if(right == 0) HandlePrizes(WinPrize, WinMoney);
}
//-------------------------------------------------------
default
{
state_entry()
{
lineCounter = 0;
Question = "";
Answers = [];
User = NULL_KEY;
UserName = "";
Prize = "";
PrizeMoney = 0;
WinPrize = "";
WinMoney = 0;
// we need this permission to give change / winnings
integer perms = llGetPermissions();
if((perms & PERMISSION_DEBIT) ==0)
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);

llSetText(llGetScriptName() + " Initialisation in Progress\nPlease Wait",<1.0,0.0,0.0>, 1);

state ReadPrelim;
}

on_rez(integer number)
{
llResetScript();
}

changed(integer change)
{
if (change & CHANGED_INVENTORY)
{
llResetScript();
}
}
}
//-------------------------------------------------------
state StartQuiz
{
state_entry()
{
Question = "";
Answers = [];
User = NULL_KEY;
UserName = "";
Prize = "";
PrizeMoney = 0;
WinPrize = "";
WinMoney = 0;

llSetText(QuizName + " Ready.\nPlease Touch me to answer the questions",<0.0,1.0,0.0>, 1);
lineCounter++;
}

on_rez(integer number)
{
llResetScript();
}

touch_start(integer num_detected)
{
User = llDetectedKey(0);
UserName = llDetectedName(0);
llSetText("In Use by " + UserName + ". Please Wait",<0.7,0.3,0.7>, 1);
lineCounter = 0;
state ReadQuestion;
}

changed(integer change)
{
if (change & CHANGED_INVENTORY)
{
llResetScript();
}
}
}
//-------------------------------------------------------
state AnswerQuestion
{
state_entry()
{
listenchannel = (integer)llFrand(4000);
AskTheQuestion();
}

on_rez(integer number)
{
llResetScript();
}

changed(integer change)
{
if (change & CHANGED_INVENTORY)
{
llResetScript();
}
}

timer()
{
CancelListen();
results = (results = "") + results + Question + " = TIMED OUT. (Should have been " + llList2String(Answers,0) + ")\n";
llSay(0, UserName + ", Oh dear you took too long. Next Question.");
lineCounter++;
state ReadQuestion;
}

listen(integer number, string name, key id, string message)
{
// Cancel the listen timer
CancelListen();

if("Quit" == message)
{
state GoodBye;
}
else if("Prev" == message)
{
first -= pagesize;
AskTheQuestion();
}
else if("Next" == message)
{
len = llGetListLength( Answers );
if((first + pagesize) < len)
first += pagesize;
AskTheQuestion();
}
else
{
// Check for a valid answer
integer selection = llListFindList(Answers, [ message ]);
if(selection >= 0)
{
results = (results = "") + results + Question + " = " + message;
if(selection == 0)
{
results += " (CORRECT)\n";
}
else
{
results += " (Should have been " + llList2String(Answers,0) + ")\n";
}

// Handle Prizes
GivePrizes(selection);

lineCounter++;
state ReadQuestion;
}
}
}
}
//--------------------------------------------------------------------------------
state EndOfQuiz
{
state_entry()
{
GivePrizes(1);
llSay(0, UserName + ", Thank you for taking part in our quiz.");
llSetText("Processing Answers. Please Wait",<1.0,0.0,0.0>,1);
// Email The quiz details to the specified Email Address.
llEmail(Email, QuizName, UserName + "\n" + results );
lineCounter = 0;
state ReadPrelim;
}

on_rez(integer number)
{
llResetScript();
}
}
//--------------------------------------------------------------------------------
state GoodBye
{
state_entry()
{
Prize = "";
PrizeMoney = 0;
WinPrize = "";
WinMoney = 0;
state EndOfQuiz;
}

on_rez(integer number)
{
llResetScript();
}
}
//--------------------------------------------------------------------------------
state ErrorCondition
{
state_entry()
{
llSetText("Sorry I'm broken.\nPlease Try again later.",<1.0,0.0,0.0>,1);
}

changed(integer change)
{
if (change & CHANGED_INVENTORY)
{
llResetScript();
}
}

on_rez(integer number)
{
llResetScript();
}
}
//--------------------------------------------------------------------------------
state ReadPrelim
{
state_entry()
{
lineCounter = 0;
integer itemtype = llGetInventoryType(notecard);
if(INVENTORY_NOTECARD == itemtype)
{
llSetTimerEvent(10);
dataRequestID = llGetNotecardLine( notecard, lineCounter ); // start reading the notecard
}
else
{
ErrorMessage("Unable to read Quiz");
state ErrorCondition;
}
}

dataserver( key query_id, string data ) // read from the notecard
{
if(dataRequestID == query_id)
{
if (data != EOF)
{
if(llGetSubString(data, 0,0) != ";")
{
if("+-START OF QUIZ-+" == data)
{
llSetTimerEvent(0);
if(llStringLength(Email) == 0)
{
ErrorMessage("Email Address Not Specified.");
state ErrorCondition;
}
else
state StartQuiz;
}
else
{
ProcessData(data);
}
}
lineCounter++;
dataRequestID = llGetNotecardLine( notecard, lineCounter );
}
else
{
llSetTimerEvent(0);
state AnswerQuestion;
}
}
}

timer()
{
llSetTimerEvent(0);
ErrorMessage("Timeout reading Quiz");
state ErrorCondition;
}


on_rez(integer number)
{
llResetScript();
}
}
//--------------------------------------------------------------------------------
state ReadQuestion
{
state_entry()
{
llSetTimerEvent(10);
dataRequestID = llGetNotecardLine( notecard, lineCounter ); // start reading the notecard
}

dataserver( key query_id, string data ) // read from the notecard
{
if(dataRequestID == query_id)
{
if (data != EOF)
{
if(llGetSubString(data, 0,0) != ";")
{
if("+-END OF QUIZ-+" == data)
{
llSetTimerEvent(0);
state EndOfQuiz;
}
else if("+-END OF QUESTION-+" == data)
{
llSetTimerEvent(0);
Randomised = llListRandomize(Answers, 1);
state AnswerQuestion;
}
else
{
ProcessData(data);
}
}
lineCounter++;
dataRequestID = llGetNotecardLine( notecard, lineCounter );
}
else
{
llSetTimerEvent(0);
state AnswerQuestion;
}
}
}

timer()
{
llSetTimerEvent(0);
ErrorMessage("Timeout reading Quiz");
state ErrorCondition;
}


on_rez(integer number)
{
llResetScript();
}
}



A very silly sample quiz

CODE

QUIZ NAME=My Silly little Quiz
EMAIL=myemail@myserver
+-START OF QUIZ-+
QUESTION=What would you like to do?
ANSWER=My Answer 1
ANSWER=My Answer 2
ANSWER=My Answer 3
+-END OF QUESTION-+
QUESTION=Where would you like to do it?
ANSWER=My Answer 1
ANSWER=My Answer 2
ANSWER=My Answer 3
+-END OF QUESTION-+
+-END OF QUIZ-+


PRIZE, PRIZE MONEY, WIN and WIN MONEY allow you to offer prizes for either answering a question or for getting it right.

If you want to give out an object for just answering the question use
CODE

QUESTION=What would you like to do?
ANSWER=My Answer 1
ANSWER=My Answer 2
ANSWER=My Answer 3
PRIZE=myobject
+-END OF QUESTION-+


If you want to give out an object only for getting it right use
CODE

QUESTION=What would you like to do?
ANSWER=My Answer 1
ANSWER=My Answer 2
ANSWER=My Answer 3
WIN=myobject
+-END OF QUESTION-+


where myobject is the name of an object in inventory

PRIZE MONEY and WIN MONEY are the finanical versions

if you put PRIZE between the end of the last question and the end of the quiz then it will be given only if they user completes the whole quiz:-

CODE

+-END OF QUESTION-+
PRIZE=MyPrize2
+-END OF QUIZ-+


Enjoy.
Peej Makira
Registered User
Join date: 18 Oct 2006
Posts: 6
WoW
11-02-2006 03:41
I didnt expect all this help. That script is nearly exactly what i was looking for. Cheers!
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
11-02-2006 04:49
From: Peej Makira
I didnt expect all this help. That script is nearly exactly what i was looking for. Cheers!


YW. had a spare hr or so yesterday lunchtime so knocked it up.
Then spend a further 2 hrs tweaking and adding the prize and win options.
Let me know what you want that it doesn't cater for and I'll think about how to add it.
Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
12-13-2006 12:23
From: Newgate Ludd
YW. had a spare hr or so yesterday lunchtime so knocked it up.
Then spend a further 2 hrs tweaking and adding the prize and win options.
Let me know what you want that it doesn't cater for and I'll think about how to add it.




Ok, what's the British slang for "computer nerd"? :D


*Hugs Newgy*
_____________________
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-13-2006 13:29
From: Vares Solvang
Ok, what's the British slang for "computer nerd"? :D


*Hugs Newgy*


Newgate?