📧 Message Board Archive

Can someone find the error in this script
If you buy a sword $400 and you have the merchant skill you pay $200 for it, now, whats wrong!!!



//script for store manager, actually attached to the bench



void main( void )

{

int &bsword;

int &bnut





int &crap = create_sprite(180,260, 0, 0, 0);

&temphold = &crap;





preload_seq(389);

preload_seq(383);

int &myrand;

sp_brain(&temphold, 0);

sp_base_walk(&temphold, 380);

sp_speed(&temphold, 0);



//set starting pic



sp_pseq(&temphold, 383);

sp_pframe(&temphold, 1);



mainloop:

wait(500);

&myrand = random(8, 1);



 if (&myrand == 1)

 {

 sp_pseq(&temphold, 383);

 }



 if (&myrand == 2)

 {

 sp_pseq(&temphold, 389);

 }



&myrand = random(20, 1);



 if (&myrand == 1)

 {

 say_stop_npc("'6Let me know if I can help you find something.", &temphold);

 }





goto mainloop;

}





void hit( void )

{

sp_speed(&current_sprite, 0);

wait(400);

say_stop_npc("'6Please don't wreck the place, thanks.", &temphold);

wait(800);  

goto mainloop;

}





void buys1( void)

{

int &junk = free_items();





if (&junk < 1)

{

        choice_start()

       set_y 240

       title_start();

You are carrying too much.

       title_end();

        "Ok"

        choice_end()

return;

}



if (&merchant == 0)

{



if (&gold < 400)

 {

         choice_start()

        set_y 240

        title_start();

You don't have enough gold to buy this sword.  Awk!

        title_end();

         "Ok"

         choice_end()

 return;

 }



}



if (&merchant == 1)

{



if (&gold < 200)

 {

         choice_start()

        set_y 240

        title_start();

You don't have enough gold to buy this sword.  Awk!

        title_end();

         "Ok"

         choice_end()

 return;

 }



}



if (&merchant == 1)

 {

 &gold += 200;

 }



&gold -= 400;

add_item("item-sw4",850, 3);



}



void buyb1( void)

{

int &junk = free_items();





if (&junk < 1)

{

        choice_start()

       set_y 240

       title_start();

You are carrying too much.

       title_end();

        "Ok"

        choice_end()

return;

}





if (&gold < 400)

{

        choice_start()

       set_y 240

       title_start();

You don't have enough gold to buy this bow.  Awk!

       title_end();

        "Ok"

        choice_end()

return;

}



&gold -= 400;

add_item("item-b1",438, 8);



}



void buybomb( void)

{

int &junk = free_items();





if (&junk < 1)

{

        choice_start()

       set_y 240

       title_start();

You are carrying too much.

       title_end();

        "Ok"

        choice_end()

return;

}



if (&merchant == 0)

{

if (&gold < 20)

 {

         choice_start()

        set_y 240

        title_start();

You don't have enough gold to buy this bomb.  Awk!

        title_end();

         "Ok"

         choice_end()

 return;

 }

}



if (&merchant == 1)

{

if (&gold < 10)

 {

         choice_start()

        set_y 240

        title_start();

You don't have enough gold to buy this bomb.  Awk!

        title_end();

         "Ok"

         choice_end()

 return;

 }

}



if (&merchant == 1)

 {

 &gold += 10;

 }



&gold -= 20;

add_item("item-bom",438, 3);



}



void sell(void )

{

//let's sell some stuff back



sell:



//how many items do they have?



&bsword = count_item("item-sw4");

&bnut = count_item("item-nut");



        choice_start()

       set_y 240

       set_title_color 6

       title_start();

"We'll buy a few things.  What have you got?"

       title_end();

      (&bsword > 0)  "Sell a Wooden sword - $200"

      (&bnut > 0)  "Sell a nut - $2"

       "Sell nothing"

       choice_end()



if (&result == 1)

   {

    kill_this_item("item-sw4");

    &gold += 200;

   goto sell;

   }



if (&result == 2)

   {

    kill_this_item("item-nut");

    &gold += 2;

   goto sell;

   }

  unfreeze(1);

  goto mainloop;

  return;





}





void buy( void )

{

buy:

        choice_start()

       set_y 240

       set_title_color 6

       title_start();

"Our wares are the finest quality around.  We'll beat any price!"

       title_end();

        (&merchant == 0) "Wooden sword - $400"

        (&merchant == 0) "Bomb - $20"

        (&merchant == 1) "Wooden sword -$200"

        (&merchant == 1) "Bomb - $10"

        "Leave"

        choice_end()



         if (&result == 1)

         {

          buys1();

          unfreeze(1);

          goto mainloop;

          return;



         }

         if (&result == 2)

         {

          buybomb();

          unfreeze(1);

          goto mainloop;

          return;



         }

         if (&result == 3)

         {

          buys1();

          unfreeze(1);

          goto mainloop;

          return;



         }

         if (&result == 4)

         {

          buybomb();

          unfreeze(1);

          goto mainloop;

          return;



         }





  unfreeze(1);

  goto mainloop;

  return;



}





void talk( void )

{



freeze(1);

        choice_start()

       set_y 240

       set_title_color 6

       title_start();

"What can I do for you today, sir?"

       title_end();

        "Buy"

        "Sell"

        "Leave"

        choice_end()



  if (&result == 1)

          {

           goto buy;

          }



  if (&result == 2)

          {

           goto sell;

          }





  unfreeze(1);

  goto mainloop;

  return;



}



Re: Can someone find the error in this script
//script for store manager, actually attached to the bench



void main( void )

{

int &bsword;



//You need a semicolon here!

int &bnut;



//I allways put local integers in the very beginning of a script, because that makes it easier for others to help. ;)

int &myrand;

int &junk;



//This is the same as you wrote, but in an easier way.

&temphold = create_sprite(180,260, 0, 0, 0);



preload_seq(389);

preload_seq(383);



//What is this!? ;)

sp_brain(&temphold, 0);

sp_base_walk(&temphold, 380);

sp_speed(&temphold, 0);



//set starting pic



sp_pseq(&temphold, 383);

sp_pframe(&temphold, 1);



mainloop:

wait(500);

&myrand = random(8, 1);



if (&myrand == 1)

{

sp_pseq(&temphold, 383);

}



if (&myrand == 2)

{

sp_pseq(&temphold, 389);

}



&myrand = random(20, 1);



if (&myrand == 1)

{

//I changed to say() here..

say("'6Let me know if I can help you find something.", &temphold);

}





goto mainloop;

}





void hit( void )

{

//You don't need this for anything, because the bench doesn't move anyway.. :p

sp_speed(&current_sprite, 0);



wait(400);



//I changed to say() here..

say("'6Please don't wreck the place, thanks.", &temphold);

wait(800);  

goto mainloop;

}



void buys1( void)

{

//I put "int &junk;" in the beginning of the script, and only "&junk" here..

&junk = free_items();





if (&junk < 1)

{

       choice_start()

      set_y 240

      title_start();

You are carrying too much.

      title_end();

       "Ok"

       choice_end()

//Go back to mainloop here, if you don't want to exit the script..

goto mainloop;

}



//I rewrite this section..

if (&merchant == 0)

{



if (&gold < 400)

{

        choice_start()

       set_y 240

       title_start();

You don't have enough gold to buy this sword.  Awk!

       title_end();

        "Ok"

        choice_end()

//mainloop here too..

goto mainloop;

}

&gold -= 400;

add_item("item-sw4",850, 3);

}



if (&merchant == 1)

{



if (&gold < 200)

{

        choice_start()

       set_y 240

       title_start();

You don't have enough gold to buy this sword.  Awk!

       title_end();

        "Ok"

        choice_end()

//mainloop here too.. Hmmmm... I'm too lazy to comment the rest of the changes.. ;)

goto mainloop;

}

&gold -= 200;

add_item("item-sw4",850, 3);

}

goto mainloop;

}



void buyb1( void)

{

&junk = free_items();



if (&junk < 1)

{

      choice_start()

      set_y 240

      title_start();

You are carrying too much.

      title_end();

       "Ok"

       choice_end()

goto mainloop;

}





if (&gold < 400)

{

      choice_start()

      set_y 240

      title_start();

You don't have enough gold to buy this bow.  Awk!

      title_end();

       "Ok"

       choice_end()

goto mainloop;

}



&gold -= 400;

add_item("item-b1",438, 8);



}



void buybomb( void)

{

&junk = free_items();





if (&junk < 1)

{

      choice_start()

      set_y 240

      title_start();

You are carrying too much.

      title_end();

       "Ok"

       choice_end()

goto mainloop;

}



if (&merchant == 0)

{

if (&gold < 20)

{

        choice_start()

       set_y 240

       title_start();

You don't have enough gold to buy this bomb.  Awk!

       title_end();

        "Ok"

        choice_end()

goto mainloop;

}

&gold -= 20;

add_item("item-bom",438, 3);

}



if (&merchant == 1)

{

if (&gold < 10)

{

        choice_start()

       set_y 240

       title_start();

You don't have enough gold to buy this bomb.  Awk!

       title_end();

        "Ok"

        choice_end()

goto mainloop;

}

&gold -= 10;

add_item("item-bom",438, 3);

}

}



void sell(void )

{

//let's sell some stuff back



sell:



//how many items do they have?



&bsword = count_item("item-sw4");

&bnut = count_item("item-nut");



       choice_start()

      set_y 240

      set_title_color 6

      title_start();

"We'll buy a few things.  What have you got?"

      title_end();

     (&bsword > 0)  "Sell a Wooden sword - $200"

     (&bnut > 0)  "Sell a nut - $2"

      "Sell nothing"

      choice_end()



if (&result == 1)

  {

   kill_this_item("item-sw4");

   &gold += 200;

  goto sell;

  }



if (&result == 2)

  {

   kill_this_item("item-nut");

   &gold += 2;

  goto sell;

  }

 unfreeze(1);

 goto mainloop;

}





void buy( void )

{

buy:

       choice_start()

      set_y 240

      set_title_color 6

      title_start();

"Our wares are the finest quality around.  We'll beat any price!"

      title_end();

       (&merchant == 0) "Wooden sword - $400"

       (&merchant == 0) "Bomb - $20"

       (&merchant == 1) "Wooden sword -$200"

       (&merchant == 1) "Bomb - $10"

       "Leave"

       choice_end()



        if (&result == 1)

        {

         buys1();

         unfreeze(1);

         goto mainloop;

         return;



        }

        if (&result == 2)

        {

         buybomb();

         unfreeze(1);

         goto mainloop;

         return;



        }

        if (&result == 3)

        {

         buys1();

         unfreeze(1);

         goto mainloop;

         return;



        }

        if (&result == 4)

        {

         buybomb();

         unfreeze(1);

         goto mainloop;

         return;



        }





 unfreeze(1);

 goto mainloop;

}





void talk( void )

{



freeze(1);

       choice_start()

      set_y 240

      set_title_color 6

      title_start();

"What can I do for you today, sir?"

      title_end();

       "Buy"

       "Sell"

       "Leave"

       choice_end()



 if (&result == 1)

         {

          goto buy;

         }



 if (&result == 2)

         {

          goto sell;

         }





 unfreeze(1);

 goto mainloop;

}
Re: Can someone find the error in this script
: //script for store manager, actually attached to the bench

: void main( void )

: {

: int &bsword;

: //You need a semicolon here!

: int &bnut;

: //I allways put local integers in the very beginning of a script, because that makes it easier for others to help. ;)

: int &myrand;

: int &junk;

: //This is the same as you wrote, but in an easier way.

: &temphold = create_sprite(180,260, 0, 0, 0);

: preload_seq(389);

: preload_seq(383);

: //What is this!? ;)

: sp_brain(&temphold, 0);

: sp_base_walk(&temphold, 380);

: sp_speed(&temphold, 0);

: //set starting pic

: sp_pseq(&temphold, 383);

: sp_pframe(&temphold, 1);

: mainloop:

: wait(500);

: &myrand = random(8, 1);

:  if (&myrand == 1)

:  {

:  sp_pseq(&temphold, 383);

:  }

:  if (&myrand == 2)

:  {

:  sp_pseq(&temphold, 389);

:  }

: &myrand = random(20, 1);

:  if (&myrand == 1)

:  {

: //I changed to say() here..

:  say("'6Let me know if I can help you find something.", &temphold);

:  }

: goto mainloop;

: }

: void hit( void )

: {

: //You don't need this for anything, because the bench doesn't move anyway.. :p

: sp_speed(&current_sprite, 0);

: wait(400);

: //I changed to say() here..

: say("'6Please don't wreck the place, thanks.", &temphold);

: wait(800);

: goto mainloop;

: }

: void buys1( void)

: {

: //I put "int &junk;" in the beginning of the script, and only "&junk" here..

: &junk = free_items();

: if (&junk < 1)

: {

:   choice_start()

:   set_y 240

:   title_start();

: You are carrying too much.

:   title_end();

:   "Ok"

:   choice_end()

: //Go back to mainloop here, if you don't want to exit the script..

: goto mainloop;

: }

: //I rewrite this section..

: if (&merchant == 0)

: {

: if (&gold < 400)

:  {

:   choice_start()

:   set_y 240

:   title_start();

: You don't have enough gold to buy this sword. Awk!

:   title_end();

:   "Ok"

:   choice_end()

: //mainloop here too..

: goto mainloop;

:  }

: &gold -= 400;

: add_item("item-sw4",850, 3);

: }

: if (&merchant == 1)

: {

: if (&gold < 200)

:  {

:   choice_start()

:   set_y 240

:   title_start();

: You don't have enough gold to buy this sword. Awk!

:   title_end();

:   "Ok"

:   choice_end()

: //mainloop here too.. Hmmmm... I'm too lazy to comment the rest of the changes.. ;)

: goto mainloop;

:  }

: &gold -= 200;

: add_item("item-sw4",850, 3);

: }

: goto mainloop;

: }

: void buyb1( void)

: {

: &junk = free_items();

: if (&junk < 1)

: {

:   choice_start()

:   set_y 240

:   title_start();

: You are carrying too much.

:   title_end();

:   "Ok"

:   choice_end()

: goto mainloop;

: }

: if (&gold < 400)

: {

:   choice_start()

:   set_y 240

:   title_start();

: You don't have enough gold to buy this bow. Awk!

:   title_end();

:   "Ok"

:   choice_end()

: goto mainloop;

: }

: &gold -= 400;

: add_item("item-b1",438, 8);

: }

: void buybomb( void)

: {

: &junk = free_items();

: if (&junk < 1)

: {

:   choice_start()

:   set_y 240

:   title_start();

: You are carrying too much.

:   title_end();

:   "Ok"

:   choice_end()

: goto mainloop;

: }

: if (&merchant == 0)

: {

: if (&gold < 20)

:  {

:   choice_start()

:   set_y 240

:   title_start();

: You don't have enough gold to buy this bomb. Awk!

:   title_end();

:   "Ok"

:   choice_end()

: goto mainloop;

:  }

: &gold -= 20;

: add_item("item-bom",438, 3);

: }

: if (&merchant == 1)

: {

: if (&gold < 10)

:  {

:   choice_start()

:   set_y 240

:   title_start();

: You don't have enough gold to buy this bomb. Awk!

:   title_end();

:   "Ok"

:   choice_end()

: goto mainloop;

:  }

: &gold -= 10;

: add_item("item-bom",438, 3);

: }

: }

: void sell(void )

: {

: //let's sell some stuff back

: sell:

: //how many items do they have?

: &bsword = count_item("item-sw4");

: &bnut = count_item("item-nut");

:   choice_start()

:   set_y 240

:   set_title_color 6

:   title_start();

: "We'll buy a few things. What have you got?"

:   title_end();

:   (&bsword > 0) "Sell a Wooden sword - $200"

:   (&bnut > 0) "Sell a nut - $2"

:   "Sell nothing"

:   choice_end()

: if (&result == 1)

:   {

:   kill_this_item("item-sw4");

:   &gold += 200;

:   goto sell;

:   }

: if (&result == 2)

:   {

:   kill_this_item("item-nut");

:   &gold += 2;

:   goto sell;

:   }

:  unfreeze(1);

:  goto mainloop;

: }

: void buy( void )

: {

: buy:

:   choice_start()

:   set_y 240

:   set_title_color 6

:   title_start();

: "Our wares are the finest quality around. We'll beat any price!"

:   title_end();

:   (&merchant == 0) "Wooden sword - $400"

:   (&merchant == 0) "Bomb - $20"

:   (&merchant == 1) "Wooden sword -$200"

:   (&merchant == 1) "Bomb - $10"

:   "Leave"

:   choice_end()

:   if (&result == 1)

:   {

:   buys1();

:   unfreeze(1);

:   goto mainloop;

:   return;

:   }

:   if (&result == 2)

:   {

:   buybomb();

:   unfreeze(1);

:   goto mainloop;

:   return;

:   }

:   if (&result == 3)

:   {

:   buys1();

:   unfreeze(1);

:   goto mainloop;

:   return;

:   }

:   if (&result == 4)

:   {

:   buybomb();

:   unfreeze(1);

:   goto mainloop;

:   return;

:   }

:  unfreeze(1);

:  goto mainloop;

: }

: void talk( void )

: {

: freeze(1);

:   choice_start()

:   set_y 240

:   set_title_color 6

:   title_start();

: "What can I do for you today, sir?"

:   title_end();

:   "Buy"

:   "Sell"

:   "Leave"

:   choice_end()

:  if (&result == 1)

:   {

:   goto buy;

:   }

:  if (&result == 2)

:   {

:   goto sell;

:   }

:  unfreeze(1);

:  goto mainloop;

: }



heh.. well.. i didn't actually rewrite that section.. :p
Re: Can someone find the error in this script
Well i dint look through it completly, but as far as i can see, the line "int &merchant" is missing you've used the variable and never int'd it!
Re: Can someone find the error in this script
: Well i dint look through it completly, but as far as i can see, the line "int &merchant" is missing you've used the variable and never int'd it!



lol, its in main.c as global