Be a Supporter!

What's wrong with this var script?

  • 317 Views
  • 5 Replies
New Topic Respond to this Topic
Gdark1
Gdark1
  • Member since: Aug. 7, 2007
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
What's wrong with this var script? 2008-10-10 15:22:55 Reply

Hey, I'm making a stat menu for my game, and I can't get it to stop subtracting "Available Points"

on (release) {
if (_root.availablepoints>0) {
_root.strength+=1
}
_root.availablepoints-=1
}

That's my script, and it'll stop adding to Strength once 'availablepoints' reaches 0, but it won't stop subtracting from availablepoints. Can someone help?

UnknownFury
UnknownFury
  • Member since: Aug. 10, 2005
  • Offline.
Forum Stats
Member
Level 26
Programmer
Response to What's wrong with this var script? 2008-10-10 15:28:30 Reply

At 10/10/08 03:22 PM, Gdark1 wrote: Hey, I'm making a stat menu for my game, and I can't get it to stop subtracting "Available Points"

on (release) {
if (_root.availablepoints>0) {
_root.strength+=1
}
_root.availablepoints-=1
}

That's my script, and it'll stop adding to Strength once 'availablepoints' reaches 0, but it won't stop subtracting from availablepoints. Can someone help?

Because you've close the if statement before you've subtracted 1 from avaliablepoints.

on (release) {
if (_root.availablepoints>0) {
_root.strength+=1
_root.availablepoints-=1
}
}
Gdark1
Gdark1
  • Member since: Aug. 7, 2007
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to What's wrong with this var script? 2008-10-10 15:29:47 Reply

Egad! I would never have thought to have two '}'s.

Lul.

Thanks! =D

Gdark1
Gdark1
  • Member since: Aug. 7, 2007
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to What's wrong with this var script? 2008-10-10 15:36:56 Reply

Wait!
Then what's wrong with this?

on (release) {
if (_root.availablepoints>0) {
_root.availablepoints+=1
_root.strength-=1
}
}

Gdark1
Gdark1
  • Member since: Aug. 7, 2007
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to What's wrong with this var script? 2008-10-10 15:49:17 Reply

Anybody? ._.

sckum555
sckum555
  • Member since: Oct. 1, 2008
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to What's wrong with this var script? 2008-10-10 19:06:28 Reply

on (release) {
if (_root.availablepoints>0) {
_root.availablepoints+=1;
_root.strength+=1;
}
}

lol you put _root.availablepoints+=1; insted of _root.availablepoints-=1; that means it will add. you got them backwards