Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Addition to Notecard Dispenser

ConductorX Nieuport
NO LONGER RELEVANT
Join date: 29 Nov 2007
Posts: 86
01-23-2008 11:11
- - -
_____________________
Madhu Maruti
aka Carter Denja
Join date: 6 Dec 2007
Posts: 749
01-23-2008 11:37
CX, I am very new to scripting myself but the first script I wrote from start to finish (yay me) was very much like this except it gives an object rather than a notecard. Following the guidance of other scripts, I put in a state_entry{} event with a call to llSetText that places text over the object at all times. I hope that helps. Here's the full script it you are interested:

// Give a single object in inventory
// a simple script that assumes there is only a single object in the inventory
// by Madhu Maruti


// text to display to users - modify as you like
string display_text = "Touch for a glass\nof masala chai"; // text displayed over giver
string touch_text = "Enjoy your glass of masala chai, "; // said to user upon delivery

// other variables
string item;
key user;



// states
default
{
state_entry()
{
llSetText(display_text, <1,1,1>, 1.0);
item = llGetInventoryName(INVENTORY_OBJECT, 0);
}

touch_start(integer total_number)
{
user = llDetectedKey(0);
llSay(0, touch_text + llKey2Name(user));
llGiveInventory(user, item);
}
}
_____________________

Visit Madhu's Cafe - relax with your friends in our lush gardens, dance with someone special, enjoy the sounds of classic Bollywood and Monday Night World Music parties - http://slurl.com/secondlife/Milyang/39/16/701/
Avion Raymaker
Palacio del Emperador!
Join date: 18 Jun 2007
Posts: 980
01-23-2008 12:15
From: ConductorX Nieuport
I am using this script to give out note cards. I would like the object to display text that tells the person what they are going to get. I have tried adding in the code to display text above the object but then the script crashes.

Thanks in advance for any help.
"CX"


ConductorX, I have notecard givers with hovertext on them all over the place. If you contact me in-world, I'd be happy to give you the 2 compatible scripts I'm using.

The hovertext script is one I got from searching either the forums here, or the wiki. It's a color-change one.
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
01-23-2008 12:40
Though the script Madhu posted here are good, yours looks ok too, CX.

What do you mean when you say the script crashes? Are you sure that the inventory of the object that your script is in also contains a notecard named My Notecard?

edit: might also want to do something like this..
CODE
touch_start(integer total_number)
{
integer noteCount = llGetInventoryNumber (INVENTORY_NOTECARD);
integer noteNum;

for (noteNum = 0; noteNum < noteCount; ++noteNum)
{
string noteName = llGetInventoryName (INVENTORY_NOTECARD, noteNum);
integer user;
for (user = 0; user < total_number; ++user)
{
llGiveInventory(llDetectedKey(user), noteName);
}
}
}

...which I haven't even compiled (at work here) let alone tested. :)

It will give anybody who touches it all notecards in the object inventory and you can add/change notecards without having to reset the script.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
ConductorX Nieuport
NO LONGER RELEVANT
Join date: 29 Nov 2007
Posts: 86
01-23-2008 13:31
I am writing the script inworld, when I save the script with my changes I get a compile error. So it doesn't actually crash... it just never compiles.

I'll try out everyone's script and report back. I appreciate the help.

"CX"
_____________________
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
01-23-2008 13:41
From: ConductorX Nieuport
I am writing the script inworld, when I save the script with my changes I get a compile error. So it doesn't actually crash... it just never compiles.

I'll try out everyone's script and report back. I appreciate the help.

"CX"

Oooohhh..

edit: never mind.. crap advice..
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
01-23-2008 13:44
/me does not see a problem with it. Can you post the entire script again? What error does it say when the compile fails?
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
ConductorX Nieuport
NO LONGER RELEVANT
Join date: 29 Nov 2007
Posts: 86
01-23-2008 15:18
From: Meade Paravane
/me does not see a problem with it. Can you post the entire script again? What error does it say when the compile fails?


What I posted works fine. It is my changes that mess it up. I didn't keep a copy because I never could get it to function.

"G"
_____________________
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
01-23-2008 17:31
From: ConductorX Nieuport
What I posted works fine. It is my changes that mess it up. I didn't keep a copy because I never could get it to function.

"G"

Hopefully you do know about LSLEditor, writing offline and checking with lslint?
_____________________
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
ConductorX Nieuport
NO LONGER RELEVANT
Join date: 29 Nov 2007
Posts: 86
01-24-2008 10:11
From: Jesse Barnett
Hopefully you do know about LSLEditor, writing offline and checking with lslint?


I have the editor, just haven't used it much.

I loaded Madhu's script and when I touch the cube the right info comes out but the script tries to give me the cube itself instead of the note card. So I am doing something wrong.

"CX"
_____________________
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
01-24-2008 10:13
From: ConductorX Nieuport
I loaded Madhu's script and when I touch the cube the right info comes out but the script tries to give me the cube itself instead of the note card. So I am doing something wrong.

Typo in that script. Change INVENTORY_OBJECT to be INVENTORY_NOTECARD.

edit: well, not really a typo - the script is for giving objects. If you want it to do a notecard instead, you need to tell it so by using INVENTORY_NOTECARD.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
ConductorX Nieuport
NO LONGER RELEVANT
Join date: 29 Nov 2007
Posts: 86
01-24-2008 17:56
From: Meade Paravane
Typo in that script. Change INVENTORY_OBJECT to be INVENTORY_NOTECARD.

edit: well, not really a typo - the script is for giving objects. If you want it to do a notecard instead, you need to tell it so by using INVENTORY_NOTECARD.


It is those tiny little things that make programmers pull their hair out. Luckily mine grows back.
_____________________
Madhu Maruti
aka Carter Denja
Join date: 6 Dec 2007
Posts: 749
01-24-2008 20:06
Sorry, I should have been clearer - I think I said my script was for an object rather than a notecard, but I should have also told you how to change it for a notecard. :/ Sorry!

(and it wasn't a typo at all ... :) )
_____________________

Visit Madhu's Cafe - relax with your friends in our lush gardens, dance with someone special, enjoy the sounds of classic Bollywood and Monday Night World Music parties - http://slurl.com/secondlife/Milyang/39/16/701/
ConductorX Nieuport
NO LONGER RELEVANT
Join date: 29 Nov 2007
Posts: 86
01-25-2008 07:42
Madhu, it was easily fixed, no harm, no foul.

The dispenser works great and it gives out a New Joke everyday. I set up another one to dispense notecards about my mall.

"G"
_____________________