Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: dikla on Sat 15/05/2004 17:20:15

Title: telephone script
Post by: dikla on Sat 15/05/2004 17:20:15
i have a phone with 9 digits which i have to click the right combination. i thought i was a big girl and know about scripting that i borrow from last topic in the forum - but it doens WORK.

here is the script (i copied it from the room setting)

// room script file
int sequence=0;

function hotspot4_a() {
  // script for hotspot4: Interact hotspot
  if (sequence == 0) sequence++;
   else sequence = 0; // wrong combination, so start again

 
}

function hotspot1_a() {
  // script for hotspot1: Interact hotspot
  if (sequence == 1) sequence++;
   else sequence = 0; // wrong combination, so start again

 
}

function hotspot7_a() {
  // script for hotspot7: Interact hotspot
  if (sequence == 2) sequence++;
   else sequence = 0; // wrong combination, so start again

 
}

function hotspot5_a() {
  // script for hotspot5: Interact hotspot
  if (sequence == 3) sequence++;
   else sequence = 0; // wrong combination, so start again

 
}

function hotspot10_a() {
  // script for hotspot10: Interact hotspot
  if (sequence == 4) sequence++;
   else sequence = 0; // wrong combination, so start again
   
}   
   
function hotspot8_a() {
  // script for hotspot8: Interact hotspot
if (sequence == 5) sequence++;
   else sequence = 0; // wrong combination, so start again
 
}

 


function hotspot3_a() {
  // script for hotspot3: Interact hotspot
   

if (sequence == 6) { // correct combination so
      AddInventory(21); // give player the phone
   }
   else sequence = 0; // wrong combination, so start again

 
}


can someone tell me what is wrong? i double checked it, semicolon, } and everything seems to be right.
thanks
dikla
Title: Re: telephone script
Post by: Ishmael on Sat 15/05/2004 17:26:06
Are you sure you are interacting the hotspots..?
Title: Re: telephone script
Post by: dikla on Sat 15/05/2004 17:36:51
yes i do. 7 hotspots. likd a leopard. and recheck if i worte in each hotspot the script.
Title: Re: telephone script
Post by: Scorpiorus on Sat 15/05/2004 19:59:33
Did you copy and paste all theÃ,  function hotspot4_a(), function hotspot1_a() , etc., didn't you?

You can't write these functions manually (or copy&paste), but instead, for each hotspot you should add Interact interaction and choose the RunScript action. AGS then add all the empty functions itself and you can fill them with the code you need.

EDIT:

In case you already did it the right way try to put a Display command for each hotspot to check if the function is called:

// room script file
int sequence=0;

function hotspot4_a() {
  // script for hotspot4: Interact hotspot
  if (sequence == 0) sequence++;
   else sequence = 0; // wrong combination, so start again

  Display("sequence = %d", sequence);

 
}

function hotspot1_a() {
  // script for hotspot1: Interact hotspot
  if (sequence == 1) sequence++;
   else sequence = 0; // wrong combination, so start again
  Display("sequence = %d", sequence);
 
}

....
....
etc
Title: Re: telephone script
Post by: dikla on Sat 15/05/2004 20:54:53
I'll try that but of course i did not do what you suggested. i just copy and path it from the room script/ to post it. i wrote in each hotspot the script and the room editor add it itself.

i am going to try now and i will tell you!
thx dikla
Title: Re: telephone script
Post by: Scorpiorus on Sat 15/05/2004 21:02:17
Quotei just copy and path it from the room script/ to post it. i wrote in each hotspot the script and the room editor add it itself.
Then you are doing it the right way. I meant that if, for example, someone posted a script with "function hotspot1_a()" etc. you can not just copy it from the post and paste directly into your room script, but you have to create all such functions with the AGS interaction editor first.
Title: Re: telephone script
Post by: dikla on Sat 15/05/2004 21:05:50
Thank you very much. again you saved me. i dont understand how it did the trick, but it did. anyway i cant display a massage every click saying "sequesnce = 6)
so how i can correct it and say something like - you dial "5" exc, or something.
dikla
Title: Re: telephone script
Post by: dikla on Sat 15/05/2004 21:08:33
NO NEED TO ANSWER. I DID IT MYSELF.
again, thank you very much.
dikla
Title: Re: telephone script
Post by: Scorpiorus on Sat 15/05/2004 21:11:32
Do you mean it doesn't display sequece=6 when you click on the 8th hotspot?

function hotspot8_a() {
Ã,  // script for hotspot8: Interact hotspot
if (sequence == 5) sequence++;
Ã,  Ã, else sequence = 0; // wrong combination, so start again
Ã, 
}

Open that hostpot Interact interaction and check if its linked with that function. Just double click on RunScript action and see if it contains the script.

Quote from: dikla on Sat 15/05/2004 21:08:33
NO NEED TO ANSWER. I DID IT MYSELF.
again, thank you very much.
dikla
EDIT: ok, no problem :)