Jump to content

Photo

I cannot compile a talking script. Please help


  • Please log in to reply
8 replies to this topic

#1 LikeLike888

LikeLike888

    Spicy food lover!!

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

Posted 16 March 2018 - 09:26 PM

Here is the script text

import "std.zh"
const int OUTPUT_LAYER = 6;
const int STRING_X = 12;
const int STRING_FONT = 0;
const int STRING_COLOUR = 0x01;
const int COLOUR_BLACK = 0x0F;
const int INTRO_MIDI = 1;
 
ffc script ScrollingStrings
{
     void run()
     {
          Game->PlayMIDI(INTRO_MIDI);  
          int q;
          int introDur =100;
          int outroDur = 100;
          int fontHeight = 8;
          int lineSpacing = 2;
          int numLines = 24;
          int line_with_spacing = lineSpacing+fontHeight;
          int screenHeight = 200;
          int totalHeight = numLines * line_with_spacing + screenHeight;
          int tempOffset = screenHeight;
          int scrollMinY = totalHeight * -1;
          int drawpos = 0;
          bool drawing = true;
 
          int line01[]="String line 1.";
          int line02[]="String line 2.";
          int line03[]="String line 3.";
          int line04[]="String line 4.";
          int line05[]="String line 5.";
          int line06[]="String line 6.";
          int line07[]="String line 7.";
          int line08[]="String line 8.";
          int line09[]="String line 9.";
          int line10[]="String line 10.";
          int line11[]="String line 11.";
          int line12[]="String line 12.";
          int line13[]="String line 13.";
          int line14[]="String line 14.";
          int line15[]="String line 15.";
          int line16[]="String line 16.";
          int line17[]="String line 17.";
          int line18[]="String line 18.";
          int line19[]="String line 19.";
          int line20[]="String line 20.";
          int line21[]="String line 21.";
          int line22[]="String line 22.";
          int line23[]="String line 23.";
          int line24[]="String line 24.";
          int strings[]={
               line01, line02, line03, line04, line05, line06,
               line07, line08, line09, line10, line11, line12,
               line13, line14, line15, line16, line 17, line18,
               line19, line20, line21, line22, line23, line24
          };
          //Intro black screen
          for ( q = 0; q < introDur; ++q )
          {
               Screen->Rectangle(OUTPUT_LAYER, 0,0,256,176, COLOUR_BLACK, 100, 0,0,0,true, 128);
               Waitframe();
          }
          while((tempOffset-=0.25) > scrollMinY)
          {
               Screen->Rectangle(OUTPUT_LAYER, 0,0,256,176, COLOUR_BLACK, 100, 0,0,0,true, 128);
 
               for (q = 0; q < numLines; ++q)
               {
                     Screen->DrawString(OUTPUT_LAYER, STRING_X, drawpos+(tempOffset<<0), STRING_FONT, STRING_COLOUR, 0, 0, strings[q], 128);
drawpos += line_with_spacing;
               }
               Waitframe();
          } //end scrolling loop loop
          //Outro Black Screen
          for ( q = 0; q < outroDur; ++q )
          {
               Screen->Rectangle(OUTPUT_LAYER, 0,0,256,176, COLOUR_BLACK, 100, 0,0,0,true, 128);
               Waitframe();
          }
     } //end run()
} //end script


#2 Deedee

Deedee

    Bug Frog Dragon Girl

  • Moderators
  • Real Name:Deedee
  • Pronouns:She / Her, They / Them
  • Location:Canada

Posted 16 March 2018 - 10:39 PM

Huh, blank compile errors? Maybe the script didn't get imported. Are you sure you set it up right? Make sure your import line doesn't have a // in front of it. This is the only way I could see the compiler not telling us anything.


  • LikeLike888 likes this

#3 James24

James24

    Adept

  • Banned
  • Real Name:James
  • Location:Australia

Posted 16 March 2018 - 10:41 PM

int line01[]="String line 1.";

 

I think this is a little suspicious.  An array of integers should contain, well, integers - not characters.  And from what Zoria told me, string literals don't exist in ZC.



#4 Orithan

Orithan

    Studying Scientist - Commission from Silvixen

  • Members
  • Location:Australia

Posted 16 March 2018 - 11:13 PM

int line01[]="String line 1.";

 

I think this is a little suspicious.  An array of integers should contain, well, integers - not characters.  And from what Zoria told me, string literals don't exist in ZC.

 

This is allowed in ZScript - it declares and sets a string all at once.



#5 Deedee

Deedee

    Bug Frog Dragon Girl

  • Moderators
  • Real Name:Deedee
  • Pronouns:She / Her, They / Them
  • Location:Canada

Posted 16 March 2018 - 11:14 PM

int line01[]="String line 1.";

 

I think this is a little suspicious.  An array of integers should contain, well, integers - not characters.  And from what Zoria told me, string literals don't exist in ZC.

Nah, that should work. You can "declare" a string using that method (since a string in ZC is just an array of "characters" (or numbers corresponding to them)), and IIRC this script was made by Zoria himself. I think it's clear from the lack of given error reporting in his post, that the script isn't being loaded at all. he might want to doublecheck to make sure he's actually importing the script.

Alternatively, the topic title could imply that he is physically unable to load the script for other reasons. Perhaps his laptop is glued shut and he's asking another person to compile his script for him. Or perhaps a villain is holding him hostage and he needs to compile this script to unlock the door and escape, and he's asking us for help to decipher the code by compiling the script and finding the secret message. Or, perhaps, he has fallen and he can't get up, and he need the inspiration to get up by having someone compile his script for him. Ya know, there could be many possible reasons why he cannot compile a talking script. Speaking of which, a talking script sounds valuable, you should sell it for money to science as "proof" of magic!



Remove the space in between "Line" and "17", and remove the "-= 0.25" from the while loop and place "tempOffset-=0.25;" right before Screen->Rectangle a few lines down.
 


Edited by Dimentio, 16 March 2018 - 11:26 PM.


#6 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 17 March 2018 - 10:40 AM

int[/size] line01[/size][]=[/size]"String line 1."[/size];[/size]
 
I think this is a little suspicious.  An array of integers should contain, well, integers - not characters.  And from what Zoria told me, string literals don't exist in ZC.


ZScript uses int, instead of char, but otherwise follows the same syntax as a char array in C.

(String literals are another matter, and do work in 2.54+.)

I'll need to look at some issues with decrements inside statements. That seems to be the problem here, as the parser can do:

while(--n > 0)
...but, apparently not:

while((n-=2) > 0)
This is likely because there is no flex rule for a left paren inside a while statement.

It's possible that this (below) would work, but I said that it was untested for a reason...

while ( n-=2 > 0 )
I do not recall if that has similar lexing issues.

#7 Deedee

Deedee

    Bug Frog Dragon Girl

  • Moderators
  • Real Name:Deedee
  • Pronouns:She / Her, They / Them
  • Location:Canada

Posted 18 March 2018 - 01:43 AM

Nah, it was the equal sign that screwed it up when I tested my compile.



#8 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 19 March 2018 - 02:39 AM

Nah, it was the equal sign that screwed it up when I tested my compile.


Ah, so, it's a lexing rule issue, but different than I expected.

You can use a function there.

int Decrement(int n, int decr)
{
     n-=decr; return n;
}

while(Decrement(n,2) > 0)
{
     //do, whatever
}
I happen to like having the decrement and the test condition in the same place. It's tidier, IMO.

#9 Deedee

Deedee

    Bug Frog Dragon Girl

  • Moderators
  • Real Name:Deedee
  • Pronouns:She / Her, They / Them
  • Location:Canada

Posted 19 March 2018 - 02:58 AM

Ah, so, it's a lexing rule issue, but different than I expected.

You can use a function there.
 

int Decrement(int n, int decr)
{
     n-=decr; return n;
}

while(Decrement(n,2) > 0)
{
     //do, whatever
}
I happen to like having the decrement and the test condition in the same place. It's tidier, IMO.

 

That wouldn't work either, cause while it would return n - value, n itself remains unchanged, meaning if you started at 20, it will forever return 19.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users