I want to overwrite a row in one of my tables. I think I’ve followed the instructions properly, and even copied the code in the example (section 16.4), but still I get parser errors. Can someone help?
I am trying to overwrite the number of Items in the table with this:
now money of player is money of player + price;
now weight of cash is cashWeight;
say "You now have [cash] ([cashWeight] lb)";
increment qty of noun;
now noun is nowhere;
now the Nbr corresponding to an Item of noun in the Table of Arms is qty;
What error is the compiler showing you? In the absence of anything else, I think that in this line of code, the problem may be with “qty” which, as I understand it, is a variable value of something else. Perhaps we should instead write:
now the Nbr corresponding to an Item of noun in the Table of Arms is qty of noun;
I hope this snippet is closer to what you’re looking for. One method you can use is to choose the row you want to update first, and then using now ... is ... on the entry.
Here, I’ll grab the current Nbr for the arrow row, add 5 to it, then update the value back.
Laboratory is a room.
arrow, axe battle, and sword short are things.
Table of Arms
Item Nbr Cost Weight Damage
arrow 36 0.2 0.1 "d6"
axe battle 3 5 9 "d6"
sword short 15 8 10 "d6"
When play begins:
say "The table before:[line break]";
showme the contents of Table of Arms;
say "[line break]";
choose row with an Item of arrow in Table of Arms;
let currentNbr be the Nbr entry;
now the Nbr entry is currentNbr + 5;
say "The table after:[line break]";
showme the contents of Table of Arms.
I’m being purposely long-winded in this example, and directly choosing the arrow row, but the idea is that you should be able to choose the row you need, pull out the chosen row’s desired value with the ___ entry, and then you can use now the ___ entry is .... to update the new value back into the table.
inside source code, it does not work as a command line action. Also, the word ‘the’ must precede ‘contents of’ or it doesn’t parse.
I set up a test file that only displays the table. Apparently, tables are not objects and only table names are text objects. Confirmed by the INDEX also.