Okey doke, just started scripting, and doing well until I tried to get this script to run for one of my inventory items:
#sectionstart inventory6_aÃ, // DO NOT EDIT OR REMOVE THIS LINE
function inventory6_a() {
// script for inventory6: Look at inventory itemÃ, Ã,Â
Ã, if (my_counter == 0) {
Ã, Ã, Display("Mufkin's big book of Secret Bookcase Passageways");
Ã, }
Ã, if (my_counter == 1) {
Ã, Ã, Display("Chapter 1 - Holes in bookcases often reveal passagewqays if the right book is put into them.");Ã,Â
Ã, }
Ã, if (my_counter == 2) {
Ã, Ã, Display("Chapter 2 - Books are often cunningly titled to suggest their secret use.");
Ã, }
Ã, if (my_counter == 3) {
Ã, Ã, Display("Funny, that's all it says...");Ã,Â
Ã, }
Ã, if (my_counter < 3) {
Ã, Ã, my_counter += 1;
Ã, }Ã,Â
}
then, I set the constant for my_counter at the top of the script. Waaay up the top around this bit:
#sectionstart game_startÃ, // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {
Ã, int my_counter
Ã, }
Ã, // called when the game starts, before the first room is loaded
No doubt I am doing something wrong - numerous messages appear, but the most common one is 'unexpected "}"'
any ideas?
first don't forget the ;
try declaring int my_counter on line 1.
Okay, that half worked. Now, for some reason, it says that 'nested functions are not supported' on a line I haven't edited:
#sectionstart repeatedly_execute // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
// put anything you want to happen every game cycle here
maybe you forgot a }
It says I've forgotten a closing brace, but I can't see where to put it...
Can you post your whole script here for us to see?
Alright, I think the main problem is this:
In the 'Examine Inventory' script I have this:
#sectionstart inventory6_a // DO NOT EDIT OR REMOVE THIS LINE
function inventory6_a() {
// script for inventory6: Look at inventory item
if (my_counter == 0) {
Display("You see a bookshelf.");
}
if (my_counter == 1) {
Display("Looking closer, you see a book called Hamlet.");
}
if (my_counter == 2) {
Display("There is also a book called Harry Potter.");
}
if (my_counter == 3) {
Display("There is nothing else of interest on the shelf.");
}
if (my_counter < 3) {
my_counter += 1;
}
}
#sectionend inventory6_a // DO NOT EDIT OR REMOVE THIS LINE
And I need to insert this somewhere in the global script:
int my_counter;
But whereever I place it it creates problems. If I put it in the inventory part of the globalscript, it just resets to 0 every time the script is run, just like it says in the tutorial. Putting it anywhere else just means that it doesn't understand what counter I'm talking about.
any help?
Solved! Thankyou very much, I have learnt much!