FOR loops

Anything to do with GTA1/GTA2 modding (tools, scripts and more).
Post Reply
User avatar
Gustavob
Immortal
Posts: 407
Joined: 18 May 2009, 21:40
GH nick: Gustavob
|Gustavob|
Location: Nowhere.
Contact:

FOR loops

Post 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
You just lost the game.
User avatar
Sektor
Boss
Boss
Posts: 1426
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: FOR loops

Post 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
User avatar
Gustavob
Immortal
Posts: 407
Joined: 18 May 2009, 21:40
GH nick: Gustavob
|Gustavob|
Location: Nowhere.
Contact:

Re: FOR loops

Post 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
You just lost the game.
User avatar
Vike the Hube
Hitman
Hitman
Posts: 145
Joined: 28 Feb 2010, 22:34
GH nick: vike

Re: FOR loops

Post by Vike the Hube »

Not fixing that, you have while loops :P
User avatar
Gustavob
Immortal
Posts: 407
Joined: 18 May 2009, 21:40
GH nick: Gustavob
|Gustavob|
Location: Nowhere.
Contact:

Re: FOR loops

Post by Gustavob »

No need to fix, just explain what that error means :P

please ;P
You just lost the game.
User avatar
Vike the Hube
Hitman
Hitman
Posts: 145
Joined: 28 Feb 2010, 22:34
GH nick: vike

Re: FOR loops

Post 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.
Post Reply