Page 1 of 1

FOR loops

Posted: 13 Sep 2010, 21:22
by Gustavob
I tried using a FOR loop (GTA2 Scripting.doc page 10, line 42) in 9/11 script so I dont need to use 4 LOWER_LEVEL commands, but it didnt work. It gets bolded in MisPad but it doesnt compile.

Code: Select all

[...]
  EXPLODE_LARGE ( 59.5 , 201.5 , 6.0 )
  EXPLODE_LARGE ( 59.5 , 201.5 , 6.0 )
  FOR wtc1_collapsed = 1 TO 4
  LOWER_LEVEL ( 111 , 124 ) ( 114 , 128 )
  ENDFOR
  CHANGE_BLOCK LID ( 111 , 124 , 2 ) NOT_FLAT NOT_FLIP 0 0 132
  CHANGE_BLOCK LID ( 112 , 124 , 2 ) NOT_FLAT NOT_FLIP 0 0 133
[...]
It displays this error:

Image

That happens in both Official Compiler and in MisPad compiler

Viiiiiiiike :P

Re: FOR loops

Posted: 13 Sep 2010, 21:54
by Sektor
They don't work. I guess that feature was never finished.

If it was more than 4 lines then you could use a while loop do a similar thing.

WHILE ( counter < 5 )
++counter
ENDWHLIE

Re: FOR loops

Posted: 13 Sep 2010, 21:56
by Gustavob
Yea I actually use a WHILE loop now, but its still a pity FOR loops werent finished :\

Although the code I use is kinda different:

Code: Select all

WHILE_EXEC ( loop = 1 )
  WHILE ( wtc1_collapsed < 4 )
  LOWER_LEVEL ( 111 , 124 ) ( 114 , 128 )
  ++wtc1_collapsed
  ENDWHILE
ENDWHILE

Re: FOR loops

Posted: 14 Sep 2010, 01:40
by Vike the Hube
Not fixing that, you have while loops :P

Re: FOR loops

Posted: 14 Sep 2010, 01:43
by Gustavob
No need to fix, just explain what that error means :P

please ;P

Re: FOR loops

Posted: 14 Sep 2010, 03:19
by Vike the Hube
It's a pretty obscure error message for an end user... because it's spit out directly by the Parse++ compiler writing framework which miss2 is built with. A production is a rule which describes an option for the next token or tokens in the compiler input string.

For example:
state-induced-by-FOR followed-by counter
state-induced-by-FOR followed-by integer
would be two production rules for the same starting state. The compiler would then figure out which it had actually found, and change its state to "state-induced-by-FOR-counter". It's lower level than the grammar of the miss2 language, but a direct implication of the grammar... like machine code is a direct descendant of assembly language.

Because it actually has a number for production 85 the rule for FOR must be there otherwise it would say that FOR is unrecognised. When it says production 85 is missing, it either means: that the rest of the grammar after FOR is unspecified, and what to do once you're in the state after FOR is recognised is undefined (extremely unlikely because in Parse++ you'd write the grammar for each command in one hit, you wouldn't leave FOR's parameters missing with FOR implemented); or it means that when the production rule for the entire FOR command is matched, the action is missing.

I.e. they implemented FOR in the grammar early on in the process when they were still doing conceptual design for the compiler, but when they were implementing each command in the compiler they were running out of time and decided that FOR was a low priority because it would just be a translation into a WHILE anyway :P

To make sense of the place_token_in_buffer bit you'd have to see the Parse++ code... I'm guessing that place_token_in_buffer is a function, and once it's got the token in the buffer it attempts to call the associated action for the production that matched that token.