An Introduction to Module System Syntax and Usage

Users who are viewing this thread

here is a snip of code in module_game_menus.  i set the value of $cattle_following in the camp menu to either 1 or 0 depending on player preference.

Code:
("cattle_herd",mnf_scale_picture,
   "You encounter a herd of cattle.",
   "none",
   [(play_sound, "snd_cow_moo"),
    (set_background_mesh, "mesh_pic_cattle"),
   ],
    [
      ("cattle_drive_away",[],"Drive the cattle onward.",
       [
        (party_set_slot, "$g_encountered_party", slot_cattle_driven_by_player, 1),
       	(party_set_ai_behavior, "$g_encountered_party", ai_bhvr_driven_by_party),
# CATTLE FOLLOW BEGIN =======================================================================================
       	(try_begin)
	    (eq,"$cattle_following",1),				
	    (party_set_ai_behavior, "$g_encountered_party", ai_bhvr_escort_party),
	(try_end)
# CATTLE FOLLOW END =========================================================================================
        (party_set_ai_object,"$g_encountered_party", "p_main_party"),
        (change_screen_return),
        ]
       ),
      ("cattle_stop",[],"Bring the herd to a stop.",
       [
        (party_set_slot, "$g_encountered_party", slot_cattle_driven_by_player, 0),
        (party_set_ai_behavior, "$g_encountered_party", ai_bhvr_hold),
        (change_screen_return),
        ]
       ),
      ("cattle_kill",[(assign, ":continue", 1),
                      (try_begin),
                        (check_quest_active, "qst_move_cattle_herd"),
                        (quest_slot_eq, "qst_move_cattle_herd", slot_quest_target_party, "$g_encountered_party"),
                        (assign, ":continue", 0),
                      (try_end),
                      (eq, ":continue", 1)],"Slaughter some of the animals.",
       [(jump_to_menu, "mnu_cattle_herd_kill"),
        ]
       ),
      ("leave",[],"Leave.",
       [(change_screen_return),
        ]
       ),
      ]
  ),

The problem is when i try to compile i get this: 
Traceback (most recent call last):
  File "process_init.py", line 2, in <module>
    from process_operations import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\process_operations.py"
, line 22, in <module>
    from module_game_menus import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\module_game_menus.py",
line 3670, in <module>
    (eq,"$cattle_following",1),
TypeError: 'int' object is not callable
Traceback (most recent call last):
  File "process_global_variables.py", line 12, in <module>
    from process_operations import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\process_operations.py"
, line 22, in <module>
    from module_game_menus import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\module_game_menus.py",
line 3670, in <module>
    (eq,"$cattle_following",1),
TypeError: 'int' object is not callable
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Traceback (most recent call last):
  File "process_map_icons.py", line 6, in <module>
    from process_operations import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\process_operations.py"
, line 22, in <module>
    from module_game_menus import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\module_game_menus.py",
line 3670, in <module>
    (eq,"$cattle_following",1),
TypeError: 'int' object is not callable
Exporting faction data...
Exporting item data...
Traceback (most recent call last):
  File "process_items.py", line 66, in <module>
    from process_operations import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\process_operations.py"
, line 22, in <module>
    from module_game_menus import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\module_game_menus.py",
line 3670, in <module>
    (eq,"$cattle_following",1),
TypeError: 'int' object is not callable
Exporting scene data...
Traceback (most recent call last):
  File "process_scenes.py", line 15, in <module>
    from process_operations import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\process_operations.py"
, line 22, in <module>
    from module_game_menus import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\module_game_menus.py",
line 3670, in <module>
    (eq,"$cattle_following",1),
TypeError: 'int' object is not callable
Exporting troops data
Exporting particle data...
Traceback (most recent call last):
  File "process_scene_props.py", line 7, in <module>
    from process_operations import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\process_operations.py"
, line 22, in <module>
    from module_game_menus import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\module_game_menus.py",
line 3670, in <module>
    (eq,"$cattle_following",1),
TypeError: 'int' object is not callable
Traceback (most recent call last):
  File "process_tableau_materials.py", line 8, in <module>
    from process_operations import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\process_operations.py"
, line 22, in <module>
    from module_game_menus import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\module_game_menus.py",
line 3670, in <module>
    (eq,"$cattle_following",1),
TypeError: 'int' object is not callable
Traceback (most recent call last):
  File "process_presentations.py", line 8, in <module>
    from process_operations import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\process_operations.py"
, line 22, in <module>
    from module_game_menus import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\module_game_menus.py",
line 3670, in <module>
    (eq,"$cattle_following",1),
TypeError: 'int' object is not callable
Exporting party_template data...
Traceback (most recent call last):
  File "process_parties.py", line 4, in <module>
    from module_game_menus import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\module_game_menus.py",
line 3670, in <module>
    (eq,"$cattle_following",1),
TypeError: 'int' object is not callable
Exporting quest data...
Exporting info_page data...
Traceback (most recent call last):
  File "process_scripts.py", line 7, in <module>
    from process_operations import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\process_operations.py"
, line 22, in <module>
    from module_game_menus import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\module_game_menus.py",
line 3670, in <module>
    (eq,"$cattle_following",1),
TypeError: 'int' object is not callable
Traceback (most recent call last):
  File "process_mission_tmps.py", line 8, in <module>
    from process_operations import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\process_operations.py"
, line 22, in <module>
    from module_game_menus import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\module_game_menus.py",
line 3670, in <module>
    (eq,"$cattle_following",1),
TypeError: 'int' object is not callable
Traceback (most recent call last):
  File "process_game_menus.py", line 5, in <module>
    from module_game_menus import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\module_game_menus.py",
line 3670, in <module>
    (eq,"$cattle_following",1),
TypeError: 'int' object is not callable
Traceback (most recent call last):
  File "process_simple_triggers.py", line 5, in <module>
    from process_operations import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\process_operations.py"
, line 22, in <module>
    from module_game_menus import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\module_game_menus.py",
line 3670, in <module>
    (eq,"$cattle_following",1),
TypeError: 'int' object is not callable
Traceback (most recent call last):
  File "process_dialogs.py", line 9, in <module>
    from process_operations import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\process_operations.py"
, line 22, in <module>
    from module_game_menus import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\module_game_menus.py",
line 3670, in <module>
    (eq,"$cattle_following",1),
TypeError: 'int' object is not callable
Traceback (most recent call last):
  File "process_global_variables_unused.py", line 3, in <module>
    from process_operations import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\process_operations.py"
, line 22, in <module>
    from module_game_menus import *
  File "C:\Users\Eric\MY Mods\Warband\Module_system 1.143\module_game_menus.py",
line 3670, in <module>
    (eq,"$cattle_following",1),
TypeError: 'int' object is not callable
Exporting postfx_params...

______________________________

Script processing has ended.
Press any key to exit. . .



any help?  do i need to specifically declare the variable $cattle_following somewhere?  or is it dynamically created the first time i try to use it?  it does not hiccup on the code for the camp menu where i set this to 1 or 0 depending on the user input, so i was assuming it is dynamically defined.  sorry i am quite versed in programming but this is my first foray into python and Warband modding so i am very frustrated trying to learn this with no documentation.  i feel like i am back in highschool, trying to learn fortran, but sleeping through class and trying to figure it out the night before the term project is due by looking at sample bits of code.
 
eswallie said:
Code:
       	(try_begin)
	    (eq,"$cattle_following",1),
Whenever you get a module system error message with something about "is not callable", it almost always means that you missed a comma either at the end of the line above (comma after try_begin in this case), or before the start of an operations block if the last line of it is shown. If the error is something about "indices must be integers, not" a comma is probably missing as well, but before a list block [] rather than a tuple (). This is because python reads the module system data as "X()" which is for calling x as a function, or  "X[]", which is for indexing a python data structure, rather than "X,()" or "X,[]".
 
ah yes i see the missing comma now.  however i just fixed it by not using a variable at all.  rather than setting a global variable in the camp menu i just added a "lead the cattle onward" menu item to the cattle themselves.  thus each time you meet cattle you can chose to "drive them on" or "lead them on."


Any way thanks for the reply.  i knew it must be something easy, as i was basically just copying code verbatim from other portions of the module system.

 
Does this language have a garbage collector like java, or do you need to manually delete every variable that isn't going to be used anymore?
 
Rangerplus10 said:
Does this language have a garbage collector like java, or do you need to manually delete every variable that isn't going to be used anymore?
There's no deletion/declaration of variables in the Module System scripting language, so no there isn't any manual deletion.
Local variables are only defined for the specific code block (list of operations, which are actually tuples) and then get re-used in the next code block. Global variables, slots, and registers exist throughout the game.
 
The Global Variables in multiplayer bypass the server and client? I mean, if you set a global variable in a server script, you can use it on client and viceversa?

Thanks.

Edit: Solved.
 
CTCCoco said:
The Global Variables in multiplayer bypass the server and client? I mean, if you set a global variable in a server script, you can use it on client and viceversa?

Thanks.

Edit: Solved.
As you seem to have discovered, they are only on the client or the server...you'll need to send them via an event to get the values from one to the other.
 
Hi, i dont know where to ask, but i got a problem when i run the build_mode.bat it says that it doesnt recognize python as a command and blablabla. I just installed python 2.7 and rebooted my pc. Please help.

I just created an account to ask this :razz: And sorry for bad english
 
Adrian160596 said:
Hi, i dont know where to ask, but i got a problem when i run the build_mode.bat it says that it doesnt recognize python as a command and blablabla. I just installed python 2.7 and rebooted my pc. Please help.

I just created an account to ask this :razz: And sorry for bad english

first thing you should do is read the stick threads on Forge and in this tutorial section. This one will help you: https://forums.taleworlds.com/index.php/topic,240255.0.html
 
For the record; I'm a total noob at coding. I'm trying to make a soldier take action if an ally is 3 meters in his vicinity. Is this somewhat correct?

(assign, ":break_loop", 0),¨
(try_for_agents, ":agent"),
    (eq, ":break_loop", 0),
    (agent_is_alive, ":agent"),
    (agent_is_non_player, ":agent"),
(agent_is_human, ":agent"),
(agent_get_position, pos0, ":agent"),
(assign, ":break_loop", 1),
(try_end),
(assign, ":break_loop", 0),
(try_for_agents, ":agent"),
    (eq, ":break_loop", 0),
    (agent_is_alive, ":agent"),
    (agent_is_non_player, ":agent"),
            (agent_is_ally, ":agent")
(agent_is_human, ":agent"),
(agent_get_position, pos1, ":agent"),
        (get_distance_between_positions_in_meters, ":distance_to_target_pos", pos0, pos1),
(lt, ":distance_to_target_pos", 3),
(assign, ":agent_at_target", ":agent"),
                (assign, ":break_loop", 1),
(try_end),

Sigh Yes help would be appriciated
 
Back
Top Bottom