Parsalin Gullwing
The big PG
Join date: 16 Aug 2004
Posts: 32
|
01-24-2005 04:11
how do i make a money even count how much it has been paid all in all like say i have
Pot = Pot + (string) amount; llsay(0,Pot);
if i pay it twice it says 11 rather then 2
whats wrong?
|
Al Bravo
Retired
Join date: 29 Jun 2004
Posts: 373
|
01-24-2005 04:14
I'm not sure I understand the question. But, don't do math with strings. integer pot; integer amount;
pot = 0; amount = 1; pot += amount; llWhisper(0, (string)pot); This should produce "1".
|
Jason Keegan
Registered User
Join date: 20 Apr 2004
Posts: 26
|
01-24-2005 04:16
Try this.
touch_start(integer total_number) { pot += amount; llSay(0, (string) pot); }
- Jason
|
Tread Whiplash
Crazy Crafter
Join date: 25 Dec 2004
Posts: 291
|
Clarification...
01-24-2005 04:54
The solutions have already been posted, but I feel explaining might help you for the future: You were "adding" two items together - at least one of which is a "string" data-type (which is treated as text, not numbers). When you "add" strings together with the "+" sign, the computer automatically thinks that you want to append one string onto the end of the other. If you want to do math, you always need to have your items as "float" or "integer" data-types ("floats" are for numbers with decimals or fractions - "integers" are for whole numbers). As a general rule, always try to store numbers as numbers (i.e. integers & floats) - and only convert them to a string (with the " string)" type-cast) when you need to print them out.Take care, happy scripting! --Noel "HB" Wade (Tread Whiplash)
|