Need help with a script
|
|
JustinMichael Torok
Old builder, new scripter
Join date: 29 Jul 2008
Posts: 23
|
11-19-2008 13:24
I've been working on this script for a couple hours now. I have most of it figured out, but I need to know a couple things before I can finish it. The script needs to reset after one week. How can I do this? I'm getting errors with the following line: llDialog(llDetectedKey(0), "Please hold CTRL while dragging your picture and application, at the same time, onto this panel.", MENU_MAIN, CHANNEL); Can anyone see a problem with it? That's all for now. Thank you 
|
|
Jeredin Denimore
Romani Ite Domum
Join date: 5 Jul 2008
Posts: 95
|
11-19-2008 13:37
From: JustinMichael Torok I've been working on this script for a couple hours now. I have most of it figured out, but I need to know a couple things before I can finish it. The script needs to reset after one week. How can I do this? I'm getting errors with the following line: llDialog(llDetectedKey(0), "Please hold CTRL while dragging your picture and application, at the same time, onto this panel.", MENU_MAIN, CHANNEL); Can anyone see a problem with it? That's all for now. Thank you  reset after a week, not tested, use at own risk on_rez( integer start_param ) { string desc = llGetObjectDesc(); list desc_parts = llParseString2List(desc,["_"],[]); integer lpos = listFindList(desc_parts,["WEEKDIE"]); if (lpos == -1) { llSetObjectDescription(desc + "_WEEKDIE_" + (string)llGetUnixTime(); } else { integer nowTime = llGetUnixTime(); integer rezTime = llList2Integer( desc_parts, lPos + 1 ); if ((nowTime - rezTime)>= 604800) { string newDesc = ""; for (integer i = 0; i<lPos;i++){ newDesc += llListToString(desc_parts,i); } llSetObjectDesc(newDesc+"_WEEKDIE_"+(string)llGetUnixTime()); llResetScript(); } } }
What is stored in MENU_MAIN and CHANNEL?
|
|
JustinMichael Torok
Old builder, new scripter
Join date: 29 Jul 2008
Posts: 23
|
11-19-2008 13:38
integer CHANNEL = 7; list MENU_MAIN = [];
MENU_MAIN is set to nothing at the moment, but may be changed in the future. That's why I used a variable; to make it easier to change.
|
|
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
|
11-19-2008 13:48
I think dialogs need to have at least one button for them to work, so you could do it like this:
list MENU_MAIN = ["OK"];
|
|
JustinMichael Torok
Old builder, new scripter
Join date: 29 Jul 2008
Posts: 23
|
11-19-2008 14:02
Same error. I'm getting two: 1 } expected Dating_Agency.lsl 35 151 2 Type or namespace definition, or end-of-file expected Dating_Agency.lsl 46 1 I checked and my braces are all in order :\ Here's the entire codeblock: default { state_entry() { llSetStatus(STATUS_BLOCK_GRAB, TRUE); llSetPayPrice(PRICE, [PRICE, PAY_HIDE, PAY_HIDE, PAY_HIDE]); //Set the price to rent this panel } touch_start(integer total_number) {
} money(key id, integer amount) { if(amount >= PRICE) { renter_id = id; llListen(CHANNEL, "",key id, ""); llDialog(llDetectedKey(0), "Please hold CTRL while dragging your picture and application, at the same time, onto this panel.", MENU_MAIN, CHANNEL);
listen(integer CHANNEL, string name, key id, string message) { avatar_name = name; //Set global avatar_name to avatar's name if (message == "OK") llSay(0, "Please enjoy our service, " name "! =D"); } state pay(); } } }
Thanks 
|
|
Jeredin Denimore
Romani Ite Domum
Join date: 5 Jul 2008
Posts: 95
|
11-19-2008 14:05
From: Pedro McMillan I think dialogs need to have at least one button for them to work, so you could do it like this:
list MENU_MAIN = ["OK"]; As far as I know, an empty list defaults to using one "OK" button.
|
|
Jeredin Denimore
Romani Ite Domum
Join date: 5 Jul 2008
Posts: 95
|
11-19-2008 14:13
From: JustinMichael Torok money(key id, integer amount) { if(amount >= PRICE) { renter_id = id; llListen(CHANNEL, "",key id, ""  ; llDialog(llDetectedKey(0), "Please hold CTRL while dragging your picture and application, at the same time, onto this panel.", MENU_MAIN, CHANNEL); listen(integer CHANNEL, string name, key id, string message) { avatar_name = name; //Set global avatar_name to avatar's name if (message == "OK"  llSay(0, "Please enjoy our service, " name "! =D"  ; } state pay(); } } } You appear to have a listen event handler inside a money event handler here in this snippet.
|
|
JustinMichael Torok
Old builder, new scripter
Join date: 29 Jul 2008
Posts: 23
|
11-19-2008 14:18
Thanks, didn't see that.
|
|
JustinMichael Torok
Old builder, new scripter
Join date: 29 Jul 2008
Posts: 23
|
11-19-2008 14:25
Is this allowed? default { state_entry() { llSetStatus(STATUS_BLOCK_GRAB, TRUE); llSetPayPrice(PRICE, [PRICE, PAY_HIDE, PAY_HIDE, PAY_HIDE]); //Set the price to rent this panel } touch_start(integer total_number) {
} money(key id, integer amount) { if(amount >= PRICE) state moni(); } }
state moni() { state_entry() { renter_id = id; llListen(CHANNEL, "",key id, ""); llDialog(llDetectedKey(0), "Please hold CTRL while dragging your picture and application, at the same time, onto this panel.", MENU_MAIN, CHANNEL);
listen(integer CHANNEL, string name, key id, string message) { avatar_name = name; //Set global avatar_name to avatar's name if (message == "OK") llSay(0, "Please enjoy our service, " name "! =D"); } state pay(); }
}
|
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
11-19-2008 17:30
I am open to correction here, but I suspect you will need to define renter as a global variable and set the value in the money event in order to use it in state moni().
|
|
JustinMichael Torok
Old builder, new scripter
Join date: 29 Jul 2008
Posts: 23
|
11-19-2008 19:35
I just started learning LSL today, so this is probably pretty messed up. I'm still getting errors. Here's the ENTIRE code: integer PRICE = 50; integer CHANNEL = 7; list MENU_MAIN = ["OK"]; list MENU_PAID = ["Card", "Like"]; list MENU_RENTER = ["Card", "Terminate"]; list MENU_SURE = ["Yes", "No"]; integer ilike = 0; integer likedby = 0; string avatar_name; string renter_id;
integer text(string name, integer ilike, integer likedby) { llSetText("Name: " avatar_name "\nI like: " ilike "\nLiked By: " likedby, <1,1,0>, 1.0); }
default { state_entry() { llSetStatus(STATUS_BLOCK_GRAB, TRUE); llSetPayPrice(PRICE, [PRICE, PAY_HIDE, PAY_HIDE, PAY_HIDE]); //Set the price to rent this panel } touch_start(integer total_number) {
} money(key id, integer amount) { renter_id = id; if(amount >= PRICE) state moni(); } state_exit() { llSay(0, "Processing Payment..."); } }
state moni() { state_entry() { llListen(CHANNEL, "",key id, ""); llDialog(llDetectedKey(0), "Please hold CTRL while dragging your picture and application, at the same time, onto this panel.", MENU_MAIN, CHANNEL); }
listen(integer CHANNEL, string name, key id, string message) { avatar_name = name; //Set global avatar_name to avatar's name if (message == "OK") llSay(0, "Please enjoy our service, " name "! =D"); } state_exit() { state pay(); }
}
state pay() { state_entry() { llAllowInventoryDrop(TRUE); //Allow avatars to drag and drop items into the panel } changed(integer mask) { if(mask & (CHANGED_ALLOWED_DROP | CHANGED_INVENTORY)) //If the panel's inventory is changed state paid(); //Then begin state paid } }
state paid() { state_entry() { llAllowInventoryDrop(FALSE); //Turn off allow to prevent errors llSetTexture(INVENTORY_TEXTURE, ALL_SIDES); //Set texture to avatar's picture } touch_start(integer total_number) { llListen(CHANNEL, "", key id, ""); if (id != renter_id) { llDialog(llDetectedKey(0), "To read " avatar_name "'s information card, click 'Card'. If you like " avatar_name ", click 'Like'", MENU_PAID, CHANNEL);
listen(integer CHANNEL, string name, key id, string message) { if (message == "Card") llGiveInventory(llDetectedKey(0),llGetInventoryName(INVENTORY_NOTECARD, 0)); //Give application notecard else if (message == "Like") { likedby += 1; //Increase likedby by 1 text(avatar_name, ilike, likedby); } } } else { llDialog(llDetectedKey(0), "To take a copy of your card, click 'Card'. To cancel your service, click 'Terminate'", MENU_RENTER, CHANNEL);
listen(integer CHANNEL, string name, key id, string message) { if (message == "Card") llGiveInventory(llDetectedKey(0),llGetInventoryName(INVENTORY_NOTECARD, 0)); //Give application notecard else if (message == "Terminate") { llDialog(llDetectedKey(0), "Are you sure you wish to terminate your profile with us?", MENU_SURE, CHANNEL); listen(integer CHANNEL, string name, key id, string message2) { if (message2 == "Yes") llResetScript(); else llSay(0, "Thank you for continuing to use our services! =D"); } } } } } } state text() { llSetText("Name: " avatar_name "\nI like: " ilike "\nLiked By: " likedby, <1,1,0>, 1.0); }
|
|
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
|
11-19-2008 19:40
From: Jeredin Denimore for (integer i = 0; i<lPos;i++) Sadly can't do that in LSL - no declaring variables within a for..
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
11-19-2008 19:51
gah, use php tags... please, I'm begging..
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
JustinMichael Torok
Old builder, new scripter
Join date: 29 Jul 2008
Posts: 23
|
11-19-2008 20:03
How? What I tried didn't work :\
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
11-19-2008 20:08
From: JustinMichael Torok How? What I tried didn't work :\ It works now JustinMichael and thank you! Makes digesting code and helping much easier on us. You can also use php inside the brackets instead of code.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
JustinMichael Torok
Old builder, new scripter
Join date: 29 Jul 2008
Posts: 23
|
11-19-2008 20:13
All I see is and before and after my text :\ Is there a reason it won't display for me?
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
11-19-2008 20:19
From: JustinMichael Torok All I see is and before and after my text :\ Is there a reason it won't display for me? /327/b2/188445/1.htmlWe use a GreaseMonkey script which will work for Opera, Firefox and now Google Chrome for which you would have to install GreaseMetal instead. With that installed, urls, code tags and other bits of necessary forum formatting work correctly. If you need any help just post back here with which browser you are using and one of us will help you along.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
JustinMichael Torok
Old builder, new scripter
Join date: 29 Jul 2008
Posts: 23
|
11-19-2008 20:26
Thanks, I installed the addon and the script and it works now  Back on topic: Can anybody fix my code? Or tell me what to do with it? Like I said, I just started learning LSL today, so I probably missed some key things. Thanks 
_____________________
Error 407: Unhandled exception in Galaxy 9. Reboot Universe? Y/N
|
|
JustinMichael Torok
Old builder, new scripter
Join date: 29 Jul 2008
Posts: 23
|
11-19-2008 22:30
Anyone? It's been a while now...
_____________________
Error 407: Unhandled exception in Galaxy 9. Reboot Universe? Y/N
|
|
Wouter Hobble
Registered User
Join date: 25 Mar 2008
Posts: 21
|
11-20-2008 02:13
In the start of your script you are composing a string with variables: llSetText("Name: " avatar_name "\nI like: " ilike "\nLiked By: " likedby, <1,1,0>, 1.0); This should be: llSetText("Name: " + avatar_name + "\nI like: " + ilike + "\nLiked By: "+ likedby, <1,1,0>, 1.0); In the money event you try to change state: state moni(); this should be: state moni; The state should also be written without the (): state moni() should be state moni in the money state you define a listener: llListen(CHANNEL, "",key id, ""  ; change this to: llListen(CHANNEL, "", NULL_KEY, ""  ; or whatever id you want to filter on In the say under the listen event you compile a string again: llSay(0, "Please enjoy our service, " name "! =D"  ; should be: llSay(0, "Please enjoy our service, " + name + "! =D"  ; the pay state should be referenced without brackets: state pay(); should be: state pay; and the state definition should also not use brackets: state pay() should be: state pay state paid is referenced wrong: state paid(); should be: state paid; same with definition just below the reference in state paid there is another listen defined wrong: llListen(CHANNEL, "", key id, ""  ; should be: llListen(CHANNEL, "", NULL_KEY, ""  ; the menu further along has a string concatenation again: llDialog(llDetectedKey(0), "To read " avatar_name "'s information card, click 'Card'. If you like " avatar_name ", click 'Like'", MENU_PAID, CHANNEL); should be: llDialog(llDetectedKey(0), "To read " + avatar_name + "'s information card, click 'Card'. If you like " + avatar_name + ", click 'Like'", MENU_PAID, CHANNEL); You define a listen event in an if loop, which is just wrong. Change that in the paid state, for you cannot compile like this. finally state text is defined and referenced wrong: state text() should be state text
|
|
Jeredin Denimore
Romani Ite Domum
Join date: 5 Jul 2008
Posts: 95
|
11-20-2008 06:29
The text function will never work as you intend it to. Some suggestions... remove the integer return type. You're ignoring returns in your code and not using a return statement in the function. Rename the function parameters to something different than your global variables to avoid confusing the two. Use the correct parameter name(s) inside the function. You still have listen events inside of other event handlers in state paid, they should be directly under the state scope of the state they are in. You have an excess curly brace in state paid. State moni has a state change in state_exit... which will never get called as far as I know. Once state moni is entered, there is no way out of it. Same with state text, no exit from this state either. My suggestion would be to, on paper, block out the flow of this script so that you can follow the state changes from state to state. Make sure each state has a defined entry and exit point. Make sure all event handlers are directly under the state scope they are in and not inside other event handlers. For each action that can generate an event have an event handler for that. An example would be llListen, it requires a listen event handler... and that handler should not be inside another event handler like touch_start. Learn the scoping rules and the difference between variables at differing scopes. Try to avoid using function parameters with the same names as global variables, they will replace the global variable while you are inside the function. I would also suggest using an editor like LSLEditor or any other editor capable of highlighting LSL syntax so you can spot simple errors such as extra curly braces, missing string concatenation characters and such. Hope this helps 
|
|
JustinMichael Torok
Old builder, new scripter
Join date: 29 Jul 2008
Posts: 23
|
11-20-2008 09:21
Awesome, thanks for the help, I'll get working on it right away =D
And I actually am using LSLEditor XD I can't get on second life in my dorm room; we have a bandwidth limit each week -_-*
_____________________
Error 407: Unhandled exception in Galaxy 9. Reboot Universe? Y/N
|
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
11-20-2008 09:38
you also cannot use llDetectedKey in any events other than touch, collision or sensor as i think it will just return NULL_KEY
|
|
JustinMichael Torok
Old builder, new scripter
Join date: 29 Jul 2008
Posts: 23
|
11-20-2008 11:14
I got that from the lsl wiki O.o
_____________________
Error 407: Unhandled exception in Galaxy 9. Reboot Universe? Y/N
|
|
JustinMichael Torok
Old builder, new scripter
Join date: 29 Jul 2008
Posts: 23
|
11-20-2008 12:29
Thanks for all the help so far! =D I have another question: I want the script to reset depending on how much the user pays. For every 50L$ they pay, it needs to extend the life of the script by one week. So, 50 = 1 week, 100 = 2 weeks, etc. Here's the code from the first page after some editing (to get it to work): default { on_rez( integer start_param ) { string desc = llGetObjectDesc(); list desc_parts = llParseString2List(desc,["_"],[]); integer lpos = llListFindList(desc_parts,["WEEKDIE"]); if (lpos == -1) { llSetObjectDesc(desc + "_WEEKDIE_" + (string)llGetUnixTime()); } else { integer nowTime = llGetUnixTime(); integer rezTime = llList2Integer( desc_parts, lpos + 1 ); if ((nowTime - rezTime)>= 604800) { string newDesc = ""; for (integer i = 0; i<lpos;i++){ newDesc += llList2String(desc_parts,i); } llSetObjectDesc(newDesc+"_WEEKDIE_"+(string)llGetUnixTime()); llResetScript(); } } }
}
Any ideas? Thanks 
_____________________
Error 407: Unhandled exception in Galaxy 9. Reboot Universe? Y/N
|