Talk:SCM language

From GTAMods Wiki
Jump to navigation Jump to search

Rework ETA?

It seems pointless to edit the page on the wiki while the rework is going on, since the reworked page will presumably completely replace the current one entirely (correct me if I am wrong on that). Is there any ETA for the rework? Additionally, would it be possible for the rework to be done entirely on the wiki – section by section maybe – so that people can actively contribute to the page during the rework? – Squ1dd13 (talk) 11:39, 3 September 2020 (UTC)

If you are willing to help, send me a modified version of the work-in-progress article privately on GTAF. I will then pick up myself what's worth and discard the rest. – Wesser (talk) 19:37, 3 September 2020 (UTC)
Ok, I'm a bit busy at the moment but I'll probably do that at some point. Cheers. – Squ1dd13 (talk) 18:08, 4 September 2020 (UTC)

Miss2

I'm not going to update the article by myself because I'm not good with words, my english is not so good... I'm going to left informations here to fix the article... All information here is based on the reverse engineering of the SCM compiler left on Vice City 10th Anniversary, I will refer to this compiler here only by miss2 (Yeah, the name is the same as GTA 2 Script Compiler)

About the 'SCM' meaning

SCM may stand for "Script Multifile", since the button to compile a scm is named "Run MultiFile parser", we have also the button "Run Parser" that produces a .scc file, it's unknown about the usage of that .scc Somewhere in the compiler code we have something like

if(IsMultifile)
    strcat(OutputFilename, "m")
else
    strcat(OutputFilename, "c")


Comments

One mistake on the article about comments, the article say:

Limit
   Multiline comments cannot be nested. 

But actually multiline comments CAN BE nested.

Round brackets

They are replaced by ' ' in the first compilation step, so probably they are really for reading or highlighting purposes. ',' is also replaced with ' '

Types

About VAR_CONST

There is not VAR_CONST, but actually 04AE (and others) are used to assign a constant value into a VAR_INT, example:

VAR_INT a
a = PAD2
TERMINATE_THIS_SCRIPT

>>

04AE: $303 = 1
004E: end_thread

About SHORT STRINGS VARIABLE

The 8 byte string variable is called VAR_TEXT_LABEL

About LONG STRINGS VARIABLE

No trace about that variable type in miss2, but I can guess it was called VAR_STRING

Arrays

The article is right about how arrays are declared (VAR_INT array[size]), but we have a strange behaviour around arrays... The index seem to start from 1 instead of 0, very strange, let's see a example

VAR_INT a[4]
a[0] = 0
a[1] = 1
a[2] = 2
a[3] = 3
a[4] = 4
//a[5] = 0 -- WOULD OUTPUT A ERROR ABOUT ARRAY OUT OF RANGE
TERMINATE_THIS_SCRIPT

>>

0004: $303 = 0
0004: $303 = 1
0004: $304 = 2
0004: $305 = 3
0004: $306 = 4
004E: end_thread 

The array support on miss2 is not good since Vice City don't have arrays, using array[var] would output a messed file, so we can't say much about it.

Operators

Time Step operator

The time step operator is not =- or =+, but [email protected] or [email protected], example:

VAR_FLOAT a
a [email protected] 1.0
a [email protected] 1.0
a = 1.0 [email protected] 2.0
a = a [email protected] 3.0
TERMINATE_THIS_SCRIPT

>>

0078: $303 += time_step * 1.0
007E: $303 -= time_step * 1.0
0005: $303 = 1.0
0078: $303 += time_step * 2.0
007E: $303 -= time_step * 3.0
004E: end_thread 

Compare String

No COMPARE_STRING, string comparision is done with the comparision operator (at least for VAR_TEXT_LABEL)

Constants

Constants are hardcoded (as everything in the compiler). Maybe they changed this on the SA Compiler or maybe AudioEvents.txt is a constant dump file.


The script files

File gosubs

They are called "main extension files" and "foreign gosubs" and are called using GOSUB_FILE Example:

GOSUB_FILE sub_label sub_file.sc

START_NEW_SCRIPT, LAUNCH_MISSION & LOAD_AND_LAUNCH_MISSION

START_NEW_SCRIPT is 004F, LAUNCH_MISSION is 00D7 and LOAD_AND_LAUNCH_MISSION is 0417 Okay, you may say: "Somewhere in GTA III Script files we have a commented block where LAUNCH_MISSION is launching a mission (0417)...", Yes, but this has probably been changed during the time, look again at that commented part and look the final code in sanny, the code is different.

There's also LOAD_AND_LAUNCH_MISSION_EXCLUSIVE, I don't know the purposes of it, okay.

LAUNCH_MISSION scripts are called Subscripts

The START_NEW_SCRIPT target label MUST be inside a scope block... The compiler also checks for the variables in that scope block to see if the START_NEW_SCRIPT extra params can be accept by the variables in the script scope block.

The foreign scripts MUST be inside a folder with the same name as the main script file, inside another folder or not. Example:

 main.sc
 main\
   subscript1.sc
   subscript2.sc
   initial_mission.sc
   mission_guy\
      mission_guy1.sc
      mission_guy2.sc
   darkel\
      darkel1.sc
      darkel2.sc
      darkel3.sc   

Usage Example:

START_NEW_SCRIPT label 1
LAUNCH_MISSION subscript1.sc // launch a subscript
LOAD_AND_LAUNCH_MISSION darkel1.sc // launch a mission
TERMINATE_THIS_SCRIPT

{
label:
LVAR_INT number_1
TERMINATE_THIS_SCRIPT
}

Statements

There's no DO..WHILE_TRUE and probably there's no FOR..ENDFOR too But we have a new statement over here, REPEAT..ENDREPEAT

REPEAT num_times var
  // code here
ENDREPEAT

This is like a FOR (for that reason I said there's no FOR...ENDFOR), will repeat the code num_times, using the var as the counter variable.

Example:

VAR_INT x k
REPEAT 4 x
 k *= 10
ENDREPEAT
TERMINATE_THIS_SCRIPT

>>

0004: $303 = 0 

:Noname_7
0010: $304 *= 10
0008: $303 += 1
0028:   $303 >= 4 
004D: jump_if_false @Noname_7 
004E: end_thread 


128 Byte Strings

128 bytes strings are enclosed in quotation marks, example:

"128B STRING"


Models constant

They are read from the IDE files in maps folder... Actually miss2 read default.ide and gta_vc.dat, after parsing gta_vc.dat, miss2 will read all listed IDE files.

Entity Variables

miss2 doesn't permit you to assign more than one entity to a specific variable, for example:

VAR_INT var
CREATE_CAR 400 0.0 0.0 0.0 var
CREATE_CHAR 4 1 0.0 0.0 0.0 var   // error: Variable has already been used to create a entity of a different type
TERMINATE_THIS_SCRIPT

Link2012 (talk) 12 December 2012 (UTC)