OPL2 is written in Python/C++, however, like the original PL2 game it supports a simple in-house scripting language, which is very similar to the BASIC programming language, but with only few dozen commands available for doing tasks related to GUI, camera controls, models, animations and lightning, as well as some general commands for defining and jumping to labels, going to other scripts, pausing script execution, etc.
OPL2 has a parser-interpreter which calls the corresponding Python function when encountering a PL2 script command.
Statement | Action | Example |
---|---|---|
:<StrA:Label>; | Label | :next; |
&<0=male, 1=female> | Replaced with the character's name; If used in %n it is automatically colored Defaults are "Oniiーchan" for male and "Sanae" for female |
&0 |
Bool: 0 for False, 1 for True
Dec: Decimal Number
Flt: Floating Point Number
StrA: ASCII Text
StrJ: Shift-JIS Text
Command | Function | Example |
---|---|---|
Flow Control | ||
%f<Dec:0=3D only, 1=Everything>,<Dec:Opacity>,<Dec:Frames>; | Fade screen [Notes] |
%f1,255,120; |
%G<StrA:.txt File>; | Run script | %Gtitle; |
%i{*}<StrJ:Text>,<StrA:Label>; | Define button that goes to label when clicked [Notes] |
%iTalk to Her,zen01; %i*Talk to Her,zen01; |
%I | Show defined buttons and wait for one to be clicked [Notes] |
%I |
%J<StrA:Label>; | Go to label in current script file | %Jnext; |
%Q | Exit the game | %Q |
%w<Dec:Frames>; | Wait specified time | %w100; |
Variables | ||
%S<StrA:Var Name>,<Operation>,<Dec:Number>; | Set variable | %S18,=,1; |
%E<StrA:Var Name>,<Comparison>,<Dec:Number>,<StrA:Label>; | Compare variable and goto Label if true | %E18,=,1,h_mode; |
Character Model Interactions | ||
%ma<Dec:Char Index>,<Dec:Part Index>,<StrA:.tmb File>; | Load item | %ma0,1,imo_eye_01; |
%mc<Dec:Char Index>,<0=Lower front, 1=Lower behind, 2=Mouth>,<Bool:Censor>; | Censor area | %mc0,0,1; |
%md<Dec:Char Index>,<Dec:Part Index>; | Remove item | %md0,5; |
%mh<Dec:Char Index>,<0=Upper UW, 1=Lower UW>,<0=On, 1=Half Off, 2=Off>; | Toggle underwear state | %mh0,1,1; |
%ml<Dec:Char Index>,<StrA:.tmb File>; | Load body; Removes all other items | %ml0,imo_bodyA_00; |
%mm<Dec:Char Index>,<StrA:.tsb File>; | Load animation | %mm0,event_01; |
%mp<Dec:Char Index>,<StrA:Position>; | Set position in room; If invalid, resets to (0,0,0) | %mp0,loc_pos00; |
%mr | Resets animation to first frame; Also clears the text field (not including %n text) | %mr |
%mv<Dec:Char Index>,<Bool:Show>; | Show or hide character | %mv1,1; |
Room Model Interactions | ||
%mb<Dec:Room Index>,{<StrA:.tmb File>}; | Load specified TMB to object; If no file specified, remove the object | %mb1,room_03A; %mb1,; |
%mn<Dec:Room Index>,<StrA:.tsb File>; | Load animation | %mn1,room_03A; |
%mV<Dec:Room Index>,<Bool:Show>; | Show or hide room | %mV0,0; |
Lighting [Notes] | ||
%lv<Dec:Light Index>,<Flt:X>,<Flt:Y>,<Flt:Z>; | Sets the rotation of the directional light | %lv1,1,1,1; |
%la<Dec:Light Index>,<Flt:Red>,<Flt:Green>,<Flt:Blue>; | Set the ambient color | %la1,0.2,0.2,0.2; |
%ld<Dec:Light Index>,<Flt:Red>,<Flt:Green>,<Flt:Blue>; | Set the diffuse color | %ld1,0.2,0.2,0.2; |
%le<Dec:Light Index>,<Bool:Show>; | Show or hide light | %le1,1; |
%ls<Dec:Light Index>,<Flt:Red>,<Flt:Green>,<Flt:Blue>; | Set the specular color | %ls1,0.8,0.8,0.8; |
Camera | ||
%c{<StrA:.tcm File>},<0=Once, 1=Repeat>; | Runs camera file | %ccam2_3,0; %c,0; |
%cl<Bool:Lock>; | Lock or unlock camera | %cl0; |
%cp<StrA:Position>; | Set position in room; Only works when camera is locked | %cploc_pos00; |
Audio | ||
%M{<StrA:.ogg File>},0; | Plays audio file as music; If no file specified, stop current music Uses music volume and repeats |
%MBGM01,0; %M,0; |
%MA{<StrA:.ogg File>},0; | Plays audio file as environment sound; If no file specified, stop current ES Uses effect volume and repeats |
%MAse09,0; %MA,0; |
%MS{<StrA:.ogg File>},0; | Plays audio file as sound effect; If no file specified, stop current SE Uses effect volume and does not repeat |
%MSse30,0; %MS,0; |
%o{<StrA:.ogg File>}; | Plays audio file as voice; If no file specified, stop current voice Uses voice volume and does not repeat |
%o0002; %o; |
%oR0,<Dec:.ogg File 1>,<Dec:.ogg File 2>,<Flt:Time boundary>,<Flt:Time boundary>; | Play both voice files with random delays, which is between the boundaries. See notes! Uses voice volume and repeats randomly |
|
User Interface Control | ||
%g{<StrA:.psd File>}; | Show image on-screen; Only shows the first layer If no file specified, hide any currently showing image |
%gtitle2; %g; |
%q<Bool:Enabled>; | Enable or Disable Esc Key | %q1; |
%T<Bool:Show>; | Show or hide title image | %T1; |
%w<Dec:Frames>; | Wait specified time | %w100; |
%W<Bool:Show>; | Show or hide text field | %W1; |
%WG<Bool:Show>; | Show or hide character gauges [Notes] | %WG1; |
%X | Close the dressing room Only useful in ':SystemExit;', as code execution pauses when in the dressing room. |
%X |
%Z1; | Open dressing room | %Z1; |
Text Output (into Text Field) [Notes] | ||
%k | Pause the text field (Press enter to continue); Does not clear the field. | %k |
%K | Pause the text field (Press enter to continue), then clears the text field (not including %n text) | %K |
%n{<Color code>}{<StrJ:Text>}; | Set header text; This appears on the first line, is usually a name, and is not cleared until %n is called again. Can color the text based on the color code. Does NOT print any text from before the color code (if there is one). If the options aren't specified, this clears the text field. |
%nText; %n&0; %n; |
%r | Line break | %r |
%R | Clear the text field (not including %n text) | %R |
Unknown Commands | ||
%cu<Dec>,<Flt>,<Flt>,<Flt>; | ? (Calls sub_403920) | %cu0,0.0,1.0,0.0; |
%cv<Dec>,<Dec>; | ? (Calls sub_403920) | %cv0,1; |
Character gauges are controlled by two variables: 128 for the female bar and 129 for the male bar.
The bar is full if the var is 100 or higher.
Operation | Action |
---|---|
= | Sets the variable equal to the number |
+ | Adds the number to the variable |
- | Subtracts the number from the variable |
Comparison | True if |
---|---|
= | The value is equal to the number |
!= | The value is not equal to the number |
< | The value is less then the number |
> | The value is greater then the number |
>= | The value is greater then OR equal to the number |
Note that there is no "less then or equal to" comparison.
Character | Color | Hex Code |
---|---|---|
Blue | 01 | |
Pink | 02 |