https://mediawiki.middlebury.edu/LIS/index.php?title=Terra_Voting_Box&feed=atom&action=historyTerra Voting Box - Revision history2024-03-28T14:11:01ZRevision history for this page on the wikiMediaWiki 1.35.14https://mediawiki.middlebury.edu/LIS/index.php?title=Terra_Voting_Box&diff=41996&oldid=prevCynthia Slater at 21:26, 29 November 20222022-11-29T21:26:13Z<p></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 21:26, 29 November 2022</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l38" >Line 38:</td>
<td colspan="2" class="diff-lineno">Line 38:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>}<br></div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>}<br></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">[[Category:TDXNO]]</ins></div></td></tr>
</table>Cynthia Slaterhttps://mediawiki.middlebury.edu/LIS/index.php?title=Terra_Voting_Box&diff=6142&oldid=prevBrendan Smith at 18:59, 23 June 20092009-06-23T18:59:00Z<p></p>
<a href="https://mediawiki.middlebury.edu/LIS/index.php?title=Terra_Voting_Box&diff=6142&oldid=6138">Show changes</a>Brendan Smithhttps://mediawiki.middlebury.edu/LIS/index.php?title=Terra_Voting_Box&diff=6138&oldid=prevBrendan Smith at 17:28, 23 June 20092009-06-23T17:28:25Z<p></p>
<a href="https://mediawiki.middlebury.edu/LIS/index.php?title=Terra_Voting_Box&diff=6138&oldid=6137">Show changes</a>Brendan Smithhttps://mediawiki.middlebury.edu/LIS/index.php?title=Terra_Voting_Box&diff=6137&oldid=prevBrendan Smith: New page: === The code below is the Voting template script for the Terra Project === //Created by Brendan Smith 9/26/08<br>//Edited 3/9/09: Added additional comments throughout code for easier read...2009-06-23T17:23:18Z<p>New page: === The code below is the Voting template script for the Terra Project === //Created by Brendan Smith 9/26/08<br>//Edited 3/9/09: Added additional comments throughout code for easier read...</p>
<p><b>New page</b></p><div>=== The code below is the Voting template script for the Terra Project ===<br />
<br />
//Created by Brendan Smith 9/26/08<br>//Edited 3/9/09: Added additional comments throughout code for easier readability and changed all names to "Party #" to make things easier to customize<br />
<br />
// In order to customize this Voting Box you must:<br> <br> // 1.make sure there is one integer variable in Section 1 for each party in the election. You can comment out any that you don't need but if you need more than 6 than you will have to create a new addParty#Vote method (simply copy the model) and you will need to create a new if statement in the listen method at the bottom of the page in order to catch the output of your additional party from the dialogue box.<br />
<br />
// 2.Edit list l to include all of your parties instead of the 6 examples. These strings are what will be displayed as button choices in the dialogue box and then picked up when they are clicked by the listen method. It will be set up so that the votes for the first party in l will be stored in the integer variable Party1_VOTES and so on.<br> <br> // 3.This is where the results of the election are messaged to the voting box owner when they click on it. Change the names of the parties to reflect your previous changes in the same order.<br />
<br />
// 4. This is where you set the text for the dialogue box. Change to include all of the parties in the election in the same order.<br />
<br />
// 5. There is one "if( llToLower(message) == "party #" )" statement for each integer variable used at the beginning of the script. Make sure that "party #" is changed to a lowercase version of whatever you put in list l in Section 2. There must be a matching conditional if statement for each element in list l.<br />
<br />
// 6. Test the script to see that all of the party names assigned to the dialogue box buttons are recognized and that it logs past votes and users correctly.<br> <br> <br> <br> <br>// Voting script, only allows one vote per avi<br>// Also only shows results to the owner of the scripted object<br>// @author Brendan Smith<br />
<br />
// ------------------------------------------------------------------------<br>// Feb 16, 2008 v1.1 - one avi, one vote<br>// Feb 14, 2008 v1.0 - simple voting, orig code<br>// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=<br>// this message will be IM'd to the voter after they successfully vote for the first time<br>string g_THANKS_MSG = "Thanks for voting";<br>// this message will be IM'd to the voter if they have already voted<br>string g_SORRY_MSG = "Sorry, but you have already voted";<br>// this will be in the hover text over the prim<br>string g_HOVER_TEXT = "Vote for a political party.";<br> <br>// -- dont need to edit anything below here probably unless you want to change <br>// how the message is delivered when someone votes. see: touch_start --<br />
<br />
//*********<br>//Section 1<br>//*********<br>//These keep track of the total # of votes for each "party". There must be one integer variable for each party<br>integer party1_VOTES = 0;<br>integer party2_VOTES = 0;<br>integer party3_VOTES = 0;<br>integer party4_VOTES = 0;<br>integer party5_VOTES = 0;<br>integer party6_VOTES = 0;<br>//********<br />
<br />
<br>// list of avis that voted<br>list g_VOTERS;<br />
<br />
integer CHANNEL = -10;<br />
<br />
<br>// ------------------------------------------------------------------------<br>update()<br>{<br> //llSetText( g_HOVER_TEXT + "\n" + (string)a_VOTES + " votes for Arbitrary Governance" + "\n" + (string)b_VOTES + " votes for Bold Moose" + "\n" + (string)f_VOTES + " votes for Freedom Alliance" + "\n" + (string)g_VOTES + " votes for Glory Through Unity" + "\n" + (string)gu_VOTES + " votes for Grubb Moose" + "\n" + (string)r_VOTES + " votes for Robots for Peace" , &lt;1,1,1&gt;, 1.0 );<br> llSetText("", &lt;0.0,0.0,0.0&gt;, 0.0);<br>}<br> <br>// ------------------------------------------------------------------------<br>//There must be an add"_"vote method for each party/integer variable<br />
<br />
integer addParty1Vote( key id )<br>{<br> // check memory and purge the list if we are getting full<br> if( llGetFreeMemory() &lt; 1000 ) {<br> g_VOTERS = [];<br> }<br> <br> // make sure they have not voted already<br> if( llListFindList( g_VOTERS, [id] ) == -1 ) {<br> party1_VOTES++;<br> g_VOTERS = (g_VOTERS=[]) + g_VOTERS + [id];<br> update();<br> return TRUE;<br> <br> } else {<br> //llWhisper (0, "Sorry, but you have already voted");<br> llInstantMessage(id, g_SORRY_MSG);<br> } <br> <br> return FALSE;<br>}<br />
<br />
integer addParty2Vote( key id )<br>{<br> // check memory and purge the list if we are getting full<br> if( llGetFreeMemory() &lt; 1000 ) {<br> g_VOTERS = [];<br> }<br> <br> // make sure they have not voted already<br> if( llListFindList( g_VOTERS, [id] ) == -1 ) {<br> party2_VOTES++;<br> g_VOTERS = (g_VOTERS=[]) + g_VOTERS + [id];<br> update();<br> return TRUE;<br> <br> } else {<br> //llWhisper (0, "Already Voted");<br> llInstantMessage(id, g_SORRY_MSG);<br> } <br> <br> return FALSE;<br>}<br />
<br />
integer addParty3Vote( key id )<br>{<br> // check memory and purge the list if we are getting full<br> if( llGetFreeMemory() &lt; 1000 ) {<br> g_VOTERS = [];<br> }<br> <br> // make sure they have not voted already<br> if( llListFindList( g_VOTERS, [id] ) == -1 ) {<br> party3_VOTES++;<br> g_VOTERS = (g_VOTERS=[]) + g_VOTERS + [id];<br> update();<br> return TRUE;<br> <br> } else {<br> //llWhisper (0, "Sorry, but you have already voted");<br> llInstantMessage(id, g_SORRY_MSG);<br> } <br> <br> return FALSE;<br>}<br />
<br />
integer addParty4Vote( key id )<br>{<br> // check memory and purge the list if we are getting full<br> if( llGetFreeMemory() &lt; 1000 ) {<br> g_VOTERS = [];<br> }<br> <br> // make sure they have not voted already<br> if( llListFindList( g_VOTERS, [id] ) == -1 ) {<br> party4_VOTES++;<br> g_VOTERS = (g_VOTERS=[]) + g_VOTERS + [id];<br> update();<br> return TRUE;<br> <br> } else {<br> //llWhisper (0, "Sorry, but you have already voted");<br> llInstantMessage(id, g_SORRY_MSG);<br> } <br> <br> return FALSE;<br>}<br />
<br />
<br />
<br />
integer addParty5Vote( key id )<br>{<br> // check memory and purge the list if we are getting full<br> if( llGetFreeMemory() &lt; 1000 ) {<br> g_VOTERS = [];<br> }<br> <br> // make sure they have not voted already<br> if( llListFindList( g_VOTERS, [id] ) == -1 ) {<br> party5_VOTES++;<br> g_VOTERS = (g_VOTERS=[]) + g_VOTERS + [id];<br> update();<br> return TRUE;<br> <br> } else {<br> //llWhisper (0, "Sorry, but you have already voted");<br> llInstantMessage(id, g_SORRY_MSG);<br> } <br> <br> return FALSE;<br>}<br />
<br />
integer addParty6Vote( key id )<br>{<br> // check memory and purge the list if we are getting full<br> if( llGetFreeMemory() &lt; 1000 ) {<br> g_VOTERS = [];<br> }<br> <br> // make sure they have not voted already<br> if( llListFindList( g_VOTERS, [id] ) == -1 ) {<br> party6_VOTES++;<br> g_VOTERS = (g_VOTERS=[]) + g_VOTERS + [id];<br> update();<br> return TRUE;<br> <br> } else {<br> //llWhisper (0, "Already Voted");<br> llInstantMessage(id, g_SORRY_MSG);<br> } <br> <br> return FALSE;<br>}<br> <br>// ------------------------------------------------------------------------<br>// D E F A U L T<br>// ------------------------------------------------------------------------<br>default<br>{<br> // --------------------------------------------------------------------<br> state_entry()<br> {<br> update();<br> // llListen(CHANNEL, "", NULL_KEY, "");<br> }<br> <br> // --------------------------------------------------------------------<br> touch_start(integer total_number)<br> {<br> <br> //*********<br> //Section 2<br> //*********<br> //List of "Parties" to vote for. There must be a party for each integer variable at the beginning of the script<br> list l = ["Party 1","Party 2","Party 3","Party 4","Party 5","Party 6"];<br> //******<br />
<br />
key who = llDetectedKey(0);<br> //Checks to see if the owner touched the object with this script in it. If so then it will whisper the results to the owner<br> if (who == llGetOwner()) {<br> <br> <br> //*********<br> //Section 3<br> //*********<br> //This instant message spits out the results. Needs to be formatted each time parties are changed so that the names of the correct parties are displayed next to the output of the integer variables used to store the votes<br> llInstantMessage(who, "\n" +(string)party1_VOTES + " votes for Party 1" + "\n" + (string)party2_VOTES + " votes for Party 2" + "\n" + (string)party3_VOTES + " votes for Party 3" + "\n" + (string)party4_VOTES + " votes for Party 4" + "\n" + (string)party5_VOTES + " votes for Party 5" + "\n" + (string)party6_VOTES + " votes for Party 6");<br> //******<br> <br> <br> //Otherwise the script will raise a dialogue box with the options of who to vote for<br> } else {<br> <br> //*********<br> //Section 4<br> //*********<br> //The text in this dialogue box must be changed every election to reflect the parties that are running. Don't worry about the order of the names. The order should be the same as from list l above.<br> llDialog(who, "Vote for one of the following political parties: \n 1. Party 1 \n 2. Party 2 \n 3. Party 3 \n 4. Party 4 \n 5. Party 5 \n 6. Party 6 \n (Note: You can only vote once and once you cast your vote you cannot change it.)", l, CHANNEL);<br> //******<br> <br> <br> //Listen for the person to click on a name in the dialogue box<br> llListen(CHANNEL, "", who, "");<br> //<br> }<br> }<br> <br> //*********<br> //Section 5<br> //*********<br> //Tells the script what to do depending on which name is clicked in the dialogue box<br> //(Important) the names in the "llToLower(message) ==" line must match names of Parties from the dialogue box list (in all lowercase!!!) for the listener to catch the button click correctly. There must be an if statement checking for each possible party from list l that is input into the dialogue box.<br> listen(integer channel, string name, key id, <br> string message) <br> { <br />
<br />
if( llToLower(message) == "party 1" )<br> {<br> if( addParty1Vote(id)) {<br> if( g_THANKS_MSG != "" ) {<br> // uncomment one and only one of these next 3 lines<br> //llWhisper( 0, g_THANKS_MSG );<br> //llSay( 0, g_THANKS_MSG ); <br> llInstantMessage(id, g_THANKS_MSG); <br> } <br> }<br> }<br> <br> <br> if( llToLower(message) == "party 2" )<br> {<br> if( addParty2Vote(id)) {<br> if( g_THANKS_MSG != "" ) {<br> // uncomment one and only one of these next 3 lines<br> //llWhisper( 0, g_THANKS_MSG );<br> //llSay( 0, g_THANKS_MSG ); <br> llInstantMessage(id, g_THANKS_MSG); <br> } <br> }<br> }<br> <br> <br> if( llToLower(message) == "party 3" )<br> {<br> if( addParty3Vote(id)) {<br> if( g_THANKS_MSG != "" ) {<br> // uncomment one and only one of these next 3 lines<br> //llWhisper( 0, g_THANKS_MSG );<br> //llSay( 0, g_THANKS_MSG ); <br> llInstantMessage(id, g_THANKS_MSG); <br> } <br> }<br> }<br />
<br />
if( llToLower(message) == "party 4" )<br> {<br> if( addParty4Vote(id)) {<br> if( g_THANKS_MSG != "" ) {<br> // uncomment one and only one of these next 3 lines<br> //llWhisper( 0, g_THANKS_MSG );<br> //llSay( 0, g_THANKS_MSG ); <br> llInstantMessage(id, g_THANKS_MSG); <br> } <br> }<br> }<br> else if( llToLower(message) == "party 5" )<br> { <br> if( addParty5Vote(id)) {<br> if( g_THANKS_MSG != "" ) {<br> // uncomment one and only one of these next 3 lines<br> //llWhisper( 0, g_THANKS_MSG );<br> //llSay( 0, g_THANKS_MSG ); <br> llInstantMessage(id, g_THANKS_MSG); <br> } <br> }<br> }<br> else if( llToLower(message) == "party 6" )<br> {<br> if( addParty6Vote(id)) {<br> if( g_THANKS_MSG != "" ) {<br> // uncomment one and only one of these next 3 lines<br> //llWhisper( 0, g_THANKS_MSG );<br> //llSay( 0, g_THANKS_MSG ); <br> llInstantMessage(id, g_THANKS_MSG); <br> } <br> }<br> }<br> }<br />
<br />
}<br></div>Brendan Smith