In inform 7 I am trying to put together a rudimentary RPG system to make into a game.
here is the routine I’m having a problem with
Instead of attacking a person (called foe):
let hitamount be a number;
let weaponName be some text;
now weaponName is "your bare fists";
now hitamount is 1;
if the player carries a weapon (called tmpWeapon) begin;
now weaponName is "[tmpWeapon]";
now hitamount is the damage of tmpWeapon;
end if;
decrease the HitPoints of the foe by hitamount;
say "You swing at [the foe] with [weaponName].";
say "You hit [the foe] for [hitamount] point[if hitamount > 1]s[end if] of damage.".
the problem is on the line
now weaponName is "[tmpWeapon]";
I’m using tmpWeapon to be sure there’s no conflict with the “weapon” which is “a kind of thing”
If I comment out that line it works fine and I get the hit amount adjusted properly, but I can’t seem to simply say the name of the weapon being used.
if I replace it with a specific object like “[the wooden training sword]” then it works fine, but when I try to use the variable (as I am in the above example) I get an error on that line that states that “tmpWeapon = something unrecognized”.
this is especially odd since it’s recognized in the next line
now hitamount is the damage of tmpWeapon;
I’m assuming the []'s can’t be used in strings at run time and any values put in there need to exist at compile time. If this is the case is there another way to simply say the name of whatever weapon is being used?