Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

~Setting an integer using note card line ~

Shippou Oud
The Fox Within
Join date: 11 Jul 2005
Posts: 141
11-23-2007 13:49
I've been trying to set an integer using a note card line, and using error checking to make sure whats in the note card is numbers, and not letters.
Any ideas what's wrong, here's an example of the part of the script that does it.

pri is a string: pric is the integer I dump to: mo is the integer I'm trying to get the value on the note card to.


CODE

pri = llGetNotecardLine("Price",0);
pric = (integer) pri;

if (pric > 0)
{
mo = pric;
}
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
11-23-2007 14:15
What problems do you encounter with it?

Without knowing anything about the issue I would say to make sure that the line has nothing in front of actual numbers, as casting a string to an integer works on the basis of the first numeric character to the one before the next non-numeric one, i.e. if there are spaces in front of it it will evaluate to 0. But that probably isn't the issue.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!

http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal

http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
Shippou Oud
The Fox Within
Join date: 11 Jul 2005
Posts: 141
11-23-2007 14:19
It reads as "0", regardless of the number I put on the first line of the script.
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
11-23-2007 14:22
Well, it shouldn't, if it is reading the line properly.

Try putting in a llOwnerSay("pri='" + pri + "'";); line to check that there are no extra spaces etc.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!

http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal

http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
11-23-2007 14:58
If 'pri' doesn't begin with an integer then (integer)pri will return 0.

However, as your code stands it makes no sense. llGetNotecardLine triggers the dataserver event it does not in itself return the contents of the notecard line. It returns the key that will be supplied to the dataserver event as its queryid parameter.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-23-2007 15:00
Try this:

CODE

key note_key;//key of data request

default {
touch_start(integer total_number) {
note_key = llGetNotecardLine("Price",0);//"Price" is name of notecard
}
dataserver(key requested, string data)
{
integer price = (integer)data;
llOwnerSay((string)price);
}
}


Notecard named "Price"
CODE

50

When touched this says:

Object: 50
_____________________
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
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
11-23-2007 15:03
Yes, blast it, I was too held up by the details of parsing to notice that; apologies. It may well be just an lack of proper use of the dataserver.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!

http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal

http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names