Need help changing values, possible basic oversight?

Ok, so it’s possible i have missed a section in the manual somewhere, but ive read through the entire thing twice and still have not found an answer.

What i want to do is the basics of all basics lol yet im having trouble.

I simply want a number value to increase after conducting an action. It is basically a very simple crafting/enhancement system. you improve the item, the item changes from a “+1” weapon to a “+2” weapon. Here are the lines of code that pertain to this crafting system (this is just a test game, and is not optimally organized fyi)

[i]A weapon is a kind of thing.
A large bone is a weapon.
A weapon has a number called stats. stats is a kind of value. A large bone has stats 1.
The description of large bone is “A [bold type] [stats] [roman type]large, smooth, heavy bone. Could be used as a weapon.”

Understand “improve [something]” as improving.
improving is an action applying to one carried thing.
Instead of improving [something], say “You improve the [the noun].”:

After improving [the noun]:
increase the stats by 1;[/i]

This has no errors, it plays. However, stats does not increase after improving.

the line “stats is a kind of value” is kind of where I’m stuck, Ideally i’d like the stats to include plus sign (+1. +2, etc) however, because i previously declared this as a number i cannot add the plus sign. BUT i declared it as a number because i wanted to use the increment or increase command so that everytime a weapon is improved it increases its stats by 1, but displays “+1” not just “1”. I can change it to display the “+1” by changing it to “the weapon has a text called stats” but then will i still be able to use increase or increment? as it stands now, increase and increment dont work in either scenario lol.

For example, after running the above code, examining the bone after improving still displays " A 1 large, smooth, heavy bone" not “A 2 large. smooth, heavy bone” which is still not what i want but at least id be headed in the right direction.

So my thoughts were that i could declare the stats value as text, then declare each value? i.e.; “the stats are +1, +2, +3…etc” but this will not work (in my head) because i cannot increase the value with out specifically saying change. I cannot do this because improving the weapon can take place anywhere at anytime.

Im aware that this is not C# and there will be limitations, however (if i do this, then do this) is about as basic as it gets in programming so i doubt this is an Inform limitation, i assume i have missed something.

This is a major part of my game, for instance id also like to add health, mana, and character stats that also improve due to actions… however im not making it very complicated, each stat (while there may be alot of them) will always be (if player does this action, then this value is increased by x). Is this possible in inform?

Last but not least, Adventure Book by Griffiths does not work not matter where i place “include adventure book by…” it simply adds his menu, and plays none of my game. however i get no errors and it plays. This cant possibly mean i may only use the adventure book extension (which apparently cancels out the inform syntax???) none of that seems likely so any help would be appreciated. Thanks so much! Im having a blast with inform.

A couple of things: Because “stats” is a property of weapons, and there are or can be more than one weapon, you need to specify which stats property you mean: “increase the stats of the noun by 1”. The same thing when printing the number: [stats of the large bone].

Secondly, your “Instead of improving” rule overrides the “after improving” rule so it can never be reached; I’d change them to “report” and “carry out” rules.

And finally, although it doesn’t make a difference in this case, brackets outside printed text are considered comments so [the noun] in “After improving [the noun]” is ignored by the compiler. (It doesn’t make a difference because “After improving the noun” is the same as “After improving” – “the noun” is always by definition the thing you’re acting on.)

For printing the + sign you could make a new say phrase like below.

So, all in all:

[code]A weapon is a kind of thing.
A large bone is a weapon.
A weapon has a number called stats. A large bone has stats 1.
The description of large bone is “A [bold type][plus-minus stats of the large bone][roman type] large, smooth, heavy bone. Could be used as a weapon.”

Understand “improve [something]” as improving.
improving is an action applying to one carried thing.

Report improving:
say “You improve the [the noun].”.

Carry out improving:
increase the stats of the noun by 1.

To say plus-minus (X - a number):
if X is greater than 0:
say “+”;
say X.[/code]

[rant=mistaken; see below]In the plus-minus stats phrase you’ll also want to include this:

To say plus-minus (X - a number): if X is greater than 0: say "+"; otherwise: say "-"; say X.

to print the minus if negative.[/rant]

But if stats can’t go negative (which your original post seemed to suggest) then you don’t need a phrase; just write “A [bold type] +[stats] [roman type]large, smooth, heavy bone. Could be used as a weapon.” If the plus sign is always going to be in there then you can just put it in the phrase.

[rant]By the way it would be possible to make the stats be +0, +1, etc. by declaring them as a unit; see section 15.8 of Writing with Inform. (You would say “Stats is a kind of value. +0 specifies a stats.”) Then you could use numerical commands like “Increase the stats of the noun by +2.” But this seems like it’d be more complicated than necessary for your purposes. (Also in this case you can’t do negative numbers, since Inform doesn’t know that the plus sign is meant to apply only to positive numbers.) There’s a lot of new stuff about the treatment of units and numbers in the latest Inform and I haven’t absorbed it yet.[/rant]

Negative numbers already print a minus sign.

That would make “-0” a thing (to say nothing of “–2”). Suggestion: either

To say plusminus (n - a number): say "[if n is at least 0]+[end if][n][run paragraph on]".

or

To say plusminus (n - a number): say "[if n is greater than 0]+[end if][n][run paragraph on]".

depending on whether you want zero to have a plus notation or not.

EDIT: Ah, ninja:ed by Juhana.

Derp. Posting too early in the morning.

Thanks a ton!
this works perfectly.

If i may, id like to take it a step further.

Id like to only be able to improve weapons. Im not sure how to implement this.

I’ve implemented that the player must carry an object in order to improve the weapon, but id like the object to only be able to be used for improving twice, then removed from play.

adding “at least twice” gives me an error.

Your Bunker is a room.
A large bone is here.
A craftstone is here.

A weapon is a kind of thing.
A large bone is a weapon.
A weapon has a number called stats.

A large bone has stats 1.

The description of large bone is “A [bold type][plus-minus stats of the large bone][roman type] large, smooth, heavy bone. Could be used as a weapon.”

Understand “improve [something]” as improving.
improving is an action applying to one carried thing.

A check improving rule:
if craftstone is not carried:
say “You have nothing to improve it with!” instead.

Check improving:
if we have improved the noun at least twice:
say “This cannot be improved further.” instead.

Report improving:
say “You improve the [noun] to a +[stats] [noun].”.

Carry out improving:
increase the stats of the noun by 1.

To say plus-minus (X - a number):
if X is greater than 0:
say “+”;
say X.

I thought changing “one carried thing” to weapon would work for making improve only pertain to weapons, but that doesnt seem to work. Im aware of the remove from play code, im just not sure how to get it to happen after being used (for improving) twice.
For example, if the player used the craftstone to do anything other then improving, this would not count against its being used for improving twice. This seems to be where i run into the problem. I had a seperate line of code removing the craftstone from play after being used twice, but it was if i used the craftstone twice for anything, not just improving.

any help would be appreciated, i am constantly going through the documentation, answering many of my own questions, i just cant seem to find the answer to this one.

Thanks again! you guys are awesome.

oops, the “at least twice” is in that line because id also like a weapon to only be able to be improved twice, as well as the craft stone only able to be used twice.

I haven’t gotten that far in the documentation yet, so there’s probably an easier way to do this, but: my natural inclination is to put an if statement under Check Improving to make it fail if the thing being improved isn’t a weapon.

As far as making the craftstone two-use-only: Perhaps something like “The craftstone has a number called uses remaining. The uses remaining of the craftstone is 2.” Then have a bit in your Carry Out Improving code that takes one away from the uses remaining of the craftstone, and removes it from play if the result is 0. I’m sure there are way better methods, but that’s the one that comes to mind.

(A sidebar: you can use the [code]

[/code] tags to distinguish your I7 code from the rest of your post.)

AH, thanks for code/code , was wondering how to do that.

Yeah, im not sure if inform actually recognizes weapon, im still going through documentation to see how to handle infroms version of “variables”.
At the top i declare a weapon as a thing, but yet using the word weapon gives me an error that inform doesn;t recognize it as a thing, but most likely im using it the wrong way.

The uses suggestion makes sense, (duh, why didnt i think of that?) lol, i’m messing around with it now, thanks a ton.

[code]Your Bunker is a room.

A large bone is here.
A craft stone is here.

A weapon is a kind of thing.
A craft stone has a number called uses. A craft stone has uses 2.
A large bone is a weapon.
A weapon has a number called stats.

A large bone has stats 1.

The description of large bone is “A [bold type][plus-minus stats of the large bone][roman type] large, smooth, heavy bone. Could be used as a weapon.”

Understand “improve [something]” as improving.
improving is an action applying to one carried thing.

A check improving rule:
if craft stone is not carried:
say “You have nothing to improve it with!” instead.

Check improving:
if we have improved the noun:
say “This cannot be improved further.” instead.

Check improving:
if the noun is the craft stone:
say “Umm…no.” instead.

Report improving:
say “You improve the [noun] to a [bold type]+[stats] [roman type] [noun].”.

Carry out improving:
increase the stats of the noun by 1.

Carry out improving:
decrease the uses of the craft stone by 1.

To say plus-minus (X - a number):
if X is greater than 0:
say “+”;
say X.
[/code]

ok so i just found out (i think) that i cannot have more than one statement under each Check, carry out, or report. Because as soon as i made a single statement for each one, it works . (might need to reread first couple chapters lol)

I still need to remove the craft stone from play when its uses equal 0, however im not sure where to put this.

My idea is… add a check for uses to be greater than zero, then add a carry out that if uses now equals zero remove from play? does this sound right? im toying around with it but i cant seem to get it to work.

Perhaps:

Carry out improving:
	increase the stats of the noun by 1;
	decrease the uses of the craft stone by 1;
	if the uses of the craft stone is equal to 0, remove the craft stone from play.

I haven’t gotten to the point where I’m messing around much with actions, but I think that’ll work. At least this way you only need one Carry Out rule.

Ok so i have improved upon this greatly, this is all working properly. However i am going to have two differently named actions, one called improve, one called modify. improve will pertain to melee weapons, modify will pertain to range weapons. how can i do this? Meaning i dont want to be able to improve a pistol with a craft stone . (the names of the actions are not definite, im just calling them that for now) which brings me to a question…
How may i refactor (rename) a word in the source?

(sidenote the genre and details of the story are not completely fleshed out thats why the objects involved may seem obscure lol)


A melee weapon is a kind of thing.
A melee weapon has a number called level.
A melee weapon has a number called damage.
A melee weapon has a number called decay.

A range weapon is a kind of thing.
A range weapon has a number called level.
A range weapon has a number called damage.
A range weapon has a number called range.
A range weapon has a number called ammo.


A large bone is here.
A large bone is a melee weapon.
A large bone has damage 13.
A large bone has decay 8. 
The description of large bone is "A [bold type][plus-minus level of the large bone][roman type] large, smooth, heavy bone. This can be used as a weapon.  It does [bold type][damage][roman type] damage.  It has a decay of [bold type][decay][roman type]."

A craft stone is here.
A craft stone has a number called uses. A craft stone has uses 2.

A 9mm pistol is here.
A 9mm pistol is a range weapon.
A 9mm has damage 34.
A 9mm has range 25.
A 9mm has ammo 12.
The description of a 9mm pistol is "A [bold type] [plus-minus level of the 9mm pistol][roman type] common firearm.  This can be used as a weapon.  It does [bold type][damage][roman type] damage, has a range of [bold type][range][roman type] and contains [bold type][ammo][roman type] rounds of ammo."




The description of craft stone is "A coarse and rounded stone used to improve weapons.  It can be used [bold type][uses][roman type] more times."


Understand "improve [something]" as improving.
improving is an action applying to one carried thing.

Check improving:
	if craft stone is not carried:
		say "You have nothing to improve it with!" instead.
		
Check improving:
	if we have improved the noun:
		say "This cannot be improved further." instead.
	
Check improving:
	if the noun is the craft stone:
		say "Umm...no." instead.
		
Check improving:
	if the uses of the craft stone is 0:
		remove the craft stone from play;
		say "The craft stone breaks into tiny pieces before you can start the improvement." instead.
					
Report improving:
	say "You improve the [noun] to a [bold type]+[level][roman type] [noun].".

Carry out improving:
	increase the level of the noun by 1.
	
Carry out improving:
	decrease the uses of the craft stone by 1.
	
To say plus-minus (X - a number):
	if X is 0:
		say "+";
	say X.

oh nevermind, it does recognize the weapons now, maybe because im am much more organized then my original post… and ive been on inform for like 9 hours now today lol. sorry for the spam, thanks everyone for your help… i will be expanding upon this weapon/enhancement system so if you have any suggestions please let me know.

My next idea is to have the weapons decay with each attack then break. Ill make “enemies can be either range or melee” and add a few different categories of range pertaining to the number value of the range of the weapon.
Along with a set of skills for the player that increase depending on the action, which means i will most likely need to define exactly which actions are used. actually that brings up a question also, can i negate built in actions?

Yep, just as i thought… I’m in the begging of a “oh wow its 5 am already?” night haha, i love it.