Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Problem with Stats

edited October 2016 in Help! with 2.0
I got this code from a couple of other discussions. Thank you to those.

My problem is whenever I increase the speed attribute and then click on health-1 (when health is say '0') it decreases the health to negative values , and makes the total attribute point increase which helps in again increasing the speed attribute.

Code in my stat
(set: $Apointsplus to true)

Attribute Points = [$Attripoints]<attripoints|

Health = [$Health]<health| (link-repeat: "Health +1")[{
	(if: $Attripoints >= 1)[
		(set: $Apointsplus to true)
	]
	(if: $Attripoints <=$Attripoints  and $Apointsplus is true)[
		(set: $Health to it + 1)
		(set: $Attripoints to it - 1)
		(replace: ?health)[$Health]
		(replace: ?attripoints)[$Attripoints]
		(if: $Attripoints is 0)[
			(set: $Apointsplus to false)
		]
	]
}] (link-repeat: "Health -1")[{	(if: $Attripoints <= 1)[
		(set: $Apointsplus to true)
	]
	(if: $Attripoints <$tot and $Apointsplus is true)[
		(set: $Health to it - 1)
		(set: $Attripoints to it + 1)
		(replace: ?health)[$Health]
		(replace: ?attripoints)[$Attripoints]
	]
}]

(set: $Apointsplus to true)
Speed = [$Speed]<Speed| (link-repeat: "Speed +1")[{
	(if: $Attripoints >= 1)[
		(set: $Apointsplus to true)
	]
	(if: $Attripoints <=$Attripoints  and $Apointsplus is true)[
		(set: $Speed to it + 1)
		(set: $Attripoints to it - 1)
		(replace: ?Speed)[$Speed]
		(replace: ?attripoints)[$Attripoints]
		(if: $Attripoints is 0)[
			(set: $Apointsplus to false)
		]
	]
}] (link-repeat: "Speed -1")[{	(if: $Attripoints <= 1)[
		(set: $Apointsplus to true)
	]
	(if: $Attripoints <$tot and $Apointsplus is true and $Speed > 0)[
		(set: $Speed to it - 1)
		(set: $Attripoints to it + 1)
		(replace: ?Speed)[$Speed]
		(replace: ?attripoints)[$Attripoints]
	]
}]

Code in my passage
(set: $Attripoints to it + 3)
(set: $tot to $Attripoints)

I tried setting if condition to make the health attribute '0' if it is less than '0'. It helped in making the health stay at 0 but it still increased the total attribute points regardless.

English is not my first language.

Comments

  • Argh. I really dislike harlowe syntax. But lemme figure this out.

    This line:
    (if: $Attripoints <=$Attripoints  and $Apointsplus is true
    

    Attpoints compared to itself is probably breaking everything. It will always evaluate to true. One of those should probably be $tot.
  • edited October 2016
    I am just a casual coder with no experience at all, but let me just state the obvious flaw if health is 0 shouldn't you die or lose or whatever, shouldn't you obviously create a code where if
    (if:$Health<= 0)[[[you lose]]]
    
    and that should lead to the "you lose" passage, I mean the code is not problem, it's you're logic that is messed up, I'm pretty sure you're just tired and sleepy, take it from me if you're tired you will just fuck up and code is really picky one [ or ( is what separates us from major errors, so take a good night's rest and work on it another time
  • Khaloodxp wrote: »
    I am just a casual coder with no experience at all, but let me just state the obvious flaw if health is 0 shouldn't you die or lose or whatever, shouldn't you obviously create a code where if
    (if:$Health<= 0)[[[you lose]]]
    
    and that should lead to the "you lose" passage, I mean the code is not problem, it's you're logic that is messed up, I'm pretty sure you're just tired and sleepy, take it from me if you're tired you will just fuck up and code is really picky one [ or ( is what separates us from major errors, so take a good night's rest and work on it another time
    The health is like total health thing. Meaning say the starting health is 100 and if I add 3 more it becomes something like 103 and so on. So in the stat 0 implies the base health that is 100. And yes, I was sleepy. Lol.

Sign In or Register to comment.