Jump to content

Photo

Whenever I Press EX1 or EX 2 or EX 3 or EX 4 no item comes


  • Please log in to reply
2 replies to this topic

#1 LikeLike888

LikeLike888

    Spicy food lover!!

  • Members
  • Real Name:Jason
  • Location:North America

Posted 28 August 2020 - 11:23 PM

It is true that numeral mean number

 

 

 

III is the roman numeral for three (3)

 

 

 

II is the roman numeral for two (2)

 

 

 

RPG stands for Role Playing Game

 

 

 

RPGs stands for Role Playing Games

 

 

 

PS1 stands for PlayStation 1

 

 

 

Here is the code:

import "std.zh"
int One = 1;
int I_X = 0;
int I_Y = 0;
int IT_STAYFAIRY = 69;
int IT_CLOCK = 4;
int IT_KILLALLENEMIES = 62;
int IT_LARGEMAGICJAR = 60;
 
 
 
item script TakeAwayEveryShieldPlease
{
  void run()
  {
    while(One==1)
    {
      Link->Item[93] = false;
      Link->Item[37] = false;
      Link->Item[8] = false;
      Waitframe();
    }
  }
}
 
 
 
global script Gobli_III_Global_Script
{
  void run()
  {
    while(One==1)
    {
      I_X = Link->X;
      I_Y = Link->Y;
      if (Link->InputEx1)
      {
        item StayFairy;
        StayFairy = Screen->CreateItem(IT_STAYFAIRY);
        StayFairy->X = I_X;
        StayFairy->Y = I_Y;
      }
      if (Link->InputEx2)
      {
        item Clock;
        Clock = Screen->CreateItem(IT_CLOCK);
        Clock->X = I_X;
        Clock->Y = I_Y;
      }
      if (Link->InputEx3)
      {
        item KillAllEnemiesItem;
        KillAllEnemiesItem = Screen->CreateItem(IT_KILLALLENEMIES);
        KillAllEnemiesItem->X = I_X;
        KillAllEnemiesItem->Y = I_Y;
      }
      if (Link->InputEx4)
      {
        item LargeMagicJar;
        LargeMagicJar = Screen->CreateItem(IT_LARGEMAGICJAR);
        LargeMagicJar->X = I_X;
        LargeMagicJar->Y = I_Y;
      }
      Waitframe();
    }
  }
}


#2 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 29 August 2020 - 12:56 AM

There are so many things wrong with how this is coded, but, way too much to spend time on. Firstly, it should work, as long as the 'IT_' things are correct. But, a few problems:

 

The IT_ numbers will never change in the middle of playing the quest. Those should be CONSTANTS, not variables; change them from 'int' to 'const int'. Having those be variables is wasting your global variable count, which there IS a limit on. It also makes the code run slower, by a sizable margin.

 

Why the hell do you have a global variable 'One' set to '1'? And why do you have 'while(One == 1)'???? Just do 'while(true)' for an infinite loop.....

 

Neither of those issues would actually make the script not work, though; they just make it a poorly written script. If it's not working, then the issue is likely that you didn't set the script up in ZQuest properly. Did you assign the global script to the Active slot?


Also, one more thing: this is also bad coding:

'item Clock;'

'Clock = Screen->CreateItem(IT_CLOCK);'

 

you should instead just do

 

'item Clock = Screen->CreateItem(IT_CLOCK);'. Do it as one line, not two; doing it as two lines is pointless, makes it harder to read, and makes it slower.


Also, why do you have 'I_X' and 'I_Y'? You're just setting them to Link->X and Link->Y, and then using them for spawning the item. That's really poor, compared to just using Link->X and Link->Y to set them (Ex: 'Clock->X = Link->X;')


  • Twilight Knight, Jared and LikeLike888 like this

#3 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 29 August 2020 - 11:34 PM

import "std.zh"

item script TakeAwayEveryShieldPlease
// Cannot run for more than one frame in versions < 2.55.0 Alpha 2
// While loop with Waitrame is useless here in 2.50.x, or 2.53.x (or 2.54.x)
{
    void run()
    {
        Link->Item[I_SHIELD1] = false; // Use item constants from std.zh
        Link->Item[I_SHIELD2] = false;
        Link->Item[I_SHIELD3] = false;
    }
}
 
 
 
global script Gobli_III_Global_Script
{
    void run()
    {
        while(1) // No need to do a comparison unless something would change the loop condition. 
        {
            if (Link->PressEx1) //You want Press here, not Input. 
            {
                // Did you mean I_FAIRY, or I_FAIRYSTILL ?
                item tmpitem = Screen->CreateItem(I_FAIRYSTILL); // Use item constants from std.zh
                // Above line: Allocation is initialisation.
                tmpitem->X = Link->X; // Link's coordinates do not need to be cached for this.
                tmpitem->Y = Link->Y;
            }
            if (Link->PressEx2)
            {
                item tmpitem = Screen->CreateItem(I_CLOCK);
                tmpitem->X = Link->X;
                tmpitem->Y = Link->Y;
            }
            if (Link->PressEx3)
            {
                item tmpitem = Screen->CreateItem(I_KILLALL);
                tmpitem->X = Link->X;
                tmpitem->Y = Link->Y;
            }
            if (Link->PressEx4)
            {
                item tmpitem = Screen->CreateItem(I_MAGICJAR2);
                tmpitem->X = Link->X;
                tmpitem->Y = Link->Y;
            }
            
            Waitframe();
        }
    }
}
You want it to look like this.


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users