Sailing Code Question (module system)

Users who are viewing this thread

Xendor

Knight at Arms
Hi again... I have got sailing code from Jubal's tutorial, it works. But just not enough

I put this to town menu
Code:
     ("sail_from_port",[(party_slot_eq,"$current_town",slot_party_type, spt_town),
#                         (party_slot_eq,"$current_town",slot_town_near_shore, 1),
                        ], "Buy a ship (2000 denars)",
      [(assign, "$g_player_icon_state", pis_ship),
       (party_set_flags, "p_main_party", pf_is_ship, 1),
       (troop_remove_gold, "trp_player", 2000),
       (party_get_position, pos1, "p_main_party"),
       (map_get_water_position_around_position, pos2, pos1, 6),
       (party_set_position, "p_main_party", pos2),
       (assign, "$g_main_ship_party", -1),
       (change_screen_return),
       ]),

what I want is:
1) Ship buying selection should being shown only if player has got 2000 denars
2) Also it must disappear and never shown again after the player buy one
Can anyone help me to do this?

And one more thing, is there any way to make this appear in only specific towns? (Like Tihr and Wercheg, or any seaside towns)

Thanks...
 
Easy.

Put this in the condition block:

[
(party_slot_eq,"$current_town",slot_party_type, spt_town),
(store_troop_gold, ":gold", "trp_player"),
(ge, ":gold", 2000),
(this_or_next|eq, "$current_town", "p_town_2"), #Tihr
(eq, "$current_town", "p_town_12"), #Wercheg
(eq, "$ship_bought", 0),

  ],

And put this in the consequences block

      [(assign, "$g_player_icon_state", pis_ship),
      (party_set_flags, "p_main_party", pf_is_ship, 1),
      (troop_remove_gold, "trp_player", 2000),
      (party_get_position, pos1, "p_main_party"),
      (map_get_water_position_around_position, pos2, pos1, 6),
      (party_set_position, "p_main_party", pos2),
      (assign, "$g_main_ship_party", -1),
      (assign, "$ship_bought", 1),
      (change_screen_return),
      ]),
 
To  make it only show up in Tihr or Wercheg, put this instead:
  ("sail_from_port",[(this_or_next|eq,"$current_town","p_town_2"),(eq,"$current_town","p_town_12"),
                        ], "Buy a ship. (1500 denars)",
      [(store_troop_gold,":money","trp_player"),
      (try_begin),
        (gt,":money",1499),
        (troop_remove_gold,"trp_player",1500),
        (assign, "$g_player_icon_state", pis_ship),
        (party_set_flags, "p_main_party", pf_is_ship, 1),
        (party_get_position, pos1, "p_main_party"),
        (map_get_water_position_around_position, pos2, pos1, 6),
        (party_set_position, "p_main_party", pos2),
        (assign, "$g_main_ship_party", -1),
        (change_screen_return),
      (else_try),
        (display_message,"str_toopoor"),
      (try_end),
        ]),
      ]
  ), (Awwww Fei Dao beat me to it!)

Now, making it disappear after you've already bought a ship is different. I'm not sure what the code would be exactly, but I think you just need to assign a local variable like ":player_has_ship,0" and then the option shows up, but then ":player_has_ship,1" and then it skips over it, yadda yadda yadda.

I'll test this thing out and get back to you in a bit...
 
Nah, you need to assign a global variable.

Anyways, if you're wondering what the difference between mine and Ruthven's is, the difference is that in mine, the menu option will not even appear. Ruthven's uses a custom string that tells you that you're too poor to buy a ship if you have less than the required denars.
 
Fei Dao said:
Nah, you need to assign a global variable.

Anyways, if you're wondering what the difference between mine and Ruthven's is, the difference is that in mine, the menu option will not even appear. Ruthven's uses a custom string that tells you that you're too poor to buy a ship if you have less than the required denars.
Oh, right, global variable.  :oops:

Yeah, just use Fei's code.
 
Fei's code:
Code:
Initializing...
Traceback (most recent call last):
  File "process_global_variables.py", line 11, in <module>
    from process_operations import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\process_ope
rations.py", line 22, in <module>
    from module_game_menus import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\module_game
_menus.py", line 7756, in <module>
    (store_troop_gold, ":gold", trp_player),
NameError: name 'trp_player' is not defined
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 "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\process_ope
rations.py", line 22, in <module>
    from module_game_menus import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\module_game
_menus.py", line 7756, in <module>
    (store_troop_gold, ":gold", trp_player),
NameError: name 'trp_player' is not defined
Exporting faction data...
Exporting item data...
Traceback (most recent call last):
  File "process_items.py", line 59, in <module>
    from process_operations import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\process_ope
rations.py", line 22, in <module>
    from module_game_menus import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\module_game
_menus.py", line 7756, in <module>
    (store_troop_gold, ":gold", trp_player),
NameError: name 'trp_player' is not defined
Exporting scene data...
Traceback (most recent call last):
  File "process_scenes.py", line 15, in <module>
    from process_operations import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\process_ope
rations.py", line 22, in <module>
    from module_game_menus import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\module_game
_menus.py", line 7756, in <module>
    (store_troop_gold, ":gold", trp_player),
NameError: name 'trp_player' is not defined
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 "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\process_ope
rations.py", line 22, in <module>
    from module_game_menus import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\module_game
_menus.py", line 7756, in <module>
    (store_troop_gold, ":gold", trp_player),
NameError: name 'trp_player' is not defined
Traceback (most recent call last):
  File "process_tableau_materials.py", line 8, in <module>
    from process_operations import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\process_ope
rations.py", line 22, in <module>
    from module_game_menus import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\module_game
_menus.py", line 7756, in <module>
    (store_troop_gold, ":gold", trp_player),
NameError: name 'trp_player' is not defined
Traceback (most recent call last):
  File "process_presentations.py", line 8, in <module>
    from process_operations import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\process_ope
rations.py", line 22, in <module>
    from module_game_menus import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\module_game
_menus.py", line 7756, in <module>
    (store_troop_gold, ":gold", trp_player),
NameError: name 'trp_player' is not defined
Exporting party_template data...
Traceback (most recent call last):
  File "process_parties.py", line 4, in <module>
    from module_game_menus import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\module_game
_menus.py", line 7756, in <module>
    (store_troop_gold, ":gold", trp_player),
NameError: name 'trp_player' is not defined
Exporting quest data...
Traceback (most recent call last):
  File "process_scripts.py", line 7, in <module>
    from process_operations import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\process_ope
rations.py", line 22, in <module>
    from module_game_menus import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\module_game
_menus.py", line 7756, in <module>
    (store_troop_gold, ":gold", trp_player),
NameError: name 'trp_player' is not defined
Traceback (most recent call last):
  File "process_mission_tmps.py", line 8, in <module>
    from process_operations import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\process_ope
rations.py", line 22, in <module>
    from module_game_menus import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\module_game
_menus.py", line 7756, in <module>
    (store_troop_gold, ":gold", trp_player),
NameError: name 'trp_player' is not defined
Traceback (most recent call last):
  File "process_game_menus.py", line 5, in <module>
    from module_game_menus import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\module_game
_menus.py", line 7756, in <module>
    (store_troop_gold, ":gold", trp_player),
NameError: name 'trp_player' is not defined
Traceback (most recent call last):
  File "process_simple_triggers.py", line 5, in <module>
    from process_operations import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\process_ope
rations.py", line 22, in <module>
    from module_game_menus import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\module_game
_menus.py", line 7756, in <module>
    (store_troop_gold, ":gold", trp_player),
NameError: name 'trp_player' is not defined
Traceback (most recent call last):
  File "process_dialogs.py", line 9, in <module>
    from process_operations import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\process_ope
rations.py", line 22, in <module>
    from module_game_menus import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\module_game
_menus.py", line 7756, in <module>
    (store_troop_gold, ":gold", trp_player),
NameError: name 'trp_player' is not defined
Traceback (most recent call last):
  File "process_global_variables_unused.py", line 3, in <module>
    from process_operations import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\process_ope
rations.py", line 22, in <module>
    from module_game_menus import *
  File "D:\Games\Mount&Blade\Modules\Age of Machinery R\ModuleSystem\module_game
_menus.py", line 7756, in <module>
    (store_troop_gold, ":gold", trp_player),
NameError: name 'trp_player' is not defined

______________________________

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

:sad:
 
ok, it passed from build_module, lemme test it in game

works perfectly, you guys are little code gods  :grin:

one little more thing: to add more towns, if I just write it like

(ge, ":gold", 2000),
(this_or_next|eq, "$current_town", "p_town_2"), #Tihr
(this_or_next|eq, "$current_town", "p_town_*"), #Suno
(this_or_next|eq, "$current_town", "p_town_*"), #Dhirim
(this_or_next|eq, "$current_town", "p_town_*"), #whatewa
(eq, "$current_town", "p_town_12"), #Wercheg
(eq, "$ship_bought", 0),

is it works too?
 
Back
Top Bottom