[Outdated9] MoBo Precompiler for 0.89x

Users who are viewing this thread

Manitas

Grandmaster Knight

as far as I have tested, it works with 0.891, please let me know if there are any problems

V 0.04: Bugfix - fixed a bug with quoted identifiers in arithmetic expressions

V 0.03: Bugfix - fixed a bug in config file causing module_mission_templates not being processed



I find the official module scripting syntax somewhat puzzling in the long run, and not very  readable.
The tool introduces alternative syntax to use in your scripts, while maintaining full backward compatibility with traditional system.

Features:
- Compatible with all module system versions so far, expected to be compatible with all upcoming .8xx versions, probably will be compatible with upcoming major releases too
- Brand new programming-like syntax, symbolic arithmetic operations, no redundant parentheses and commas
- Customizable aliases for the most frequently used operations.
- Can be applied to mods being in progress already.

Installation:
1. Unzip contents of the archive into the module system directory, preserving directory structure (all 5 files must be present in the 'mobo' folder)
2. Run install_mobo.bat. This does the following:
- create backup[timestamp].zip archive in your official module directory containing all the module*.py files
- import all the module* files into the mobo directory, from now on you will edit these files instead those from official module.
3. After the install completes successfully, it's advised to delete install_mobo.bat and init_mobo.py.


Usage:

Just place your code between #mobo# tags like this:

Code:
("script_name",
[#mobo#
  :var = 12
  {agents    reg(5) begin end
         
      |!agent_is_alive    reg(5)
      agent_is_ally
      agent_get_position reg(10) :xxx
      $v2 = 5
      {
          $v1 == 3
          reg(2) += $var1
	  reg3 = 2/2
      ?
          $varabool = reg(5) % 2
      }
  }
#mobo#
]),
The above translates to:
Code:
("script_name",
[
      (assign,':var',12),
      (try_for_agents,reg(5),begin,end),
        (this_or_next|neg|agent_is_alive,reg(5)),
        (agent_is_ally),
        (agent_get_position,reg(10),':xxx'),
        (assign,'$v2',5),
        (try_begin),
          (eq,'$v1',3),
          (val_add,reg(2),'$var1'),
          (store_div,reg3,2,2),
        (else_try),
          (assign,':mobo_tmp',reg(5)),
          (val_mod,':mobo_tmp',2),
          (assign,'$varabool',':mobo_tmp'),
        (try_end),
      (try_end),
]),
Note the last arithmetic operation. There's no corresponding operation in modsys, so it translates to three instead. You can customize the :mobo_temp temporary variable name in the config file.

To build a module: just run the mobo.bat. If precompile phase finishes without errors build_module.bat from official module system will be invoked automaticly.

Additional remarks:
- no need to enclose variables in quotes (identifiers should still be enclosed in quotes though)
- operation modifiers: "!" stands for neg|,  "|" - this_or_next|
- a += b works like a = a + b, other operators work analogicly: -=, *=, /=, %=




Ok, this is not gonna be very helpfull if you are going to write a three-liner, but if you try to deal with something more complex with lots of math, this might come in handy.

Please let me know if it will be of any use to anyone.
 
So, is anybody using this, anny comments?
I 'm planning to integrate it into the modsys directly, but if it's not needed I won't bother.
 
I think this is the way to go to make stuff easier, and I will use it if I can use it everywhere (for all M&B operations), if I don't have to rewrite old code, and if it is stable. Except from that, I really think this is the way to go.

Edit: tested it now, looking good. If integrated, I would definately use this. A quick altering of build_module.bat would do the trick I guess.
 
Yes, the idea is to let the two systems coexist, so no rewriting old code. About the stability part, we'll see, it's a question of testing.
 
The first update.

Now instead compiling script by script and copy&pasting , you just type directly in module system files and let it go.
No original module system files were harmed or altered in the process.
more details in the title post.

Please, let me know if there are any bugs
 
Great!

Nice work.  Now that you can write it right into the python scripts themselves it should be much more useable. 
At some stage I'd like to add support for it to MBDev if thats ok?
 
A little bugfix:
The file module_mission_templates was not included in the config file, preventing it from being processed.

Fixed now.
 
Good looking stuff, Manitas! If you are interested, I would like to integrate this into the Pythonic Module Editor.
 
I have just done a quick check, and it seems it works with the .891 module system already (a benefit of not using hardcodes :wink: )
Dont know if anybody's using this (besides me), but just in case.
 
Back
Top Bottom