Why some scripts do not compile?

Anything to do with GTA1/GTA2 modding (tools, scripts and more).
Post Reply
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Why some scripts do not compile?

Post by B-$hep »

Why this doesnt compile with miss2?
What else it wants? Bunch of do_nowt's thrown around?

Code: Select all

counter ctr=1

levelstart
	DO 
		ctr = ctr + 1
	WHILE_TRUE ( ctr < 100 ) 

levelend
"Unrecognised token in scriptfile"
'ctr' on line 5 (ctr = ctr + 1)

Stupid compiler or stupid me?
I tried to remove all spaces and things, still doesnt work.

Does anybody have a working example for WHILE_TRUE ?
I need it.

Or this command is broken and never compiled?

TIA.
Always wear safety glasses while programming.
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Why some scripts do not compile?

Post by Sektor »

Forgot to use SET? I've done that before. You don't need SET if you do ++ctr but you need it for ctr = ctr +1.

Code: Select all

SET ctr = (ctr + 1)
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: Why some scripts do not compile?

Post by B-$hep »

Didnt know because i dont see this in docs or im just blind.
I know about set but i didnt know i have to use it for such things.

Thanks.
Always wear safety glasses while programming.
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: Why some scripts do not compile?

Post by T.M. »

There is such a command as DO-WHILE_TRUE ? Didnt know. I cant find that in my decompiler sources either. Probably because its implemented by the GOTO commands? I wonder if those can be decompiled at all, by the GOTO structures.

SET command is so useless waste of typing... wish we could have the mis2 syntax already ;)

Any news on GOTO format figuring?
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: Why some scripts do not compile?

Post by B-$hep »

It's kinda "lol" :) that you TM didnt know about DO WHILE_TRUE. Its in docs.
But the WHILE_EXEC and WHILE ENDWHILE are the same.
Its just 1 command with 2 different names.

If im wrong correct me. But i didnt see any differences inside .scr
Its weird, because docs clearly say that WHILE_EXEC is "special" one.

GOTO is pretty much clear, im already compiling WHILE_EXEC and WHILE ENDWHILE's. Including nested ones !!!
I have to write some docs for you, until i forget this all, lol.

But i will implement the IF ELSE ENDIF now. These are the most difficult ones (i mean "if else endif, while, do while").
But now its only IF ELSE ENDIF and DO WHILE_TRUE left.

EDIT:
And yes, its all pretty much "GOTO" and "IF_JUMP"
But the whole logic behind this all is pretty "sick". I spent 3 weeks till i got compiled result similar to miss2.
The are still the 1 unknown byte / bit whatever thats unknown. But if zeroed out, nothing happens. Still working
But by looking miss2 generated stuff, it shows these unknown ones arent used. Who knows..
Always wear safety glasses while programming.
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: Why some scripts do not compile?

Post by T.M. »

Well its been 2 years since i read the docs, and even then i just copypasted the code :D So no wonder if i didnt remember that command. If its in the docs i probably tried it once then.

Is it really same? Usually do-while loops execute the stuff before while check, and while loops check before executing the stuff after check.

What is the GOTO command format and those extra 2 variables in the end?
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: Why some scripts do not compile?

Post by B-$hep »

GOTO just uses 1 value, the command index to GO TO, the rest 2 should be ignored, they make no sense. Sometimes it points to 0A (10) (just rough example) when there is only 6 commands in script. And if i look the values, they really do not even look like something from the script.

They are probably left over from something.

But still, one should make some more complex test script with some WHILE commands and zero out the unknown values. And see if it changes the behaviour or crashes the game. The scripts i have so far tested (very simple ones) do not crash it.
But i repeat more testing should be done. On the other side if i look the values, they are not used at all. Go figure.


DO WHILE_TRUE is also implemented now. I was surprised it was so easy. (Actually copy paste of some existing code). Even the nested ones. Tested few variants of scripts, did a hex compare between miss2 and my compiler generated .scr files and they seem to be fine.
Only difference are these unknown values.


Now only the IF ELSE ENDIF left.


The Sektor bossman script seems interesting enough, with all good commands i need now: including WHILE and IF_THEN
http://gtamp.com/forum/viewtopic.php?p=1620#p1620

Will make it compile after i implement IF THEN endif


EDIT
Someone here wrote that ELSE doesnt work very well or doesnt work at all.
What exactly doesnt work?

I did simplest script with while_exec loop. One counter with specific value.
Put in a "if else endif" checking for if counter value is equal to something, if yes then: display_brief(xx)
else display_brief(xxx).

It worked when i executed GTA2. I modified the variable value, recompiled and it shows me different brief after else.
So whats not working? Nested IF_ELSE_ENDIF maybe??
Always wear safety glasses while programming.
User avatar
elypter
Immortal
Posts: 1120
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: Why some scripts do not compile?

Post by elypter »

B-$hep wrote: EDIT
Someone here wrote that ELSE doesnt work very well or doesnt work at all.
What exactly doesnt work?

I did simplest script with while_exec loop. One counter with specific value.
Put in a "if else endif" checking for if counter value is equal to something, if yes then: display_brief(xx)
else display_brief(xxx).

It worked when i executed GTA2. I modified the variable value, recompiled and it shows me different brief after else.
So whats not working? Nested IF_ELSE_ENDIF maybe??
from an old post of mine:
>I also didn't add yet the problem with the ELSE statement. sometimes it is linked with the wrong IF.
unfortunately i dont have an example for when and how this happenes exactly.

edit: i just read the other thread. that was exactly it
yur sa'nok ngeyä
Post Reply