Getting Compile error for and undefined name.

Users who are viewing this thread

I've been trying to modify the well-used Geoffrey Ashe Tavern Recruitment code to make slave traders buy and sell slaves, rather than just buy, and I keep getting the error: NameError: 'name 'slot_town_slave_market' is not defined.  Code as follows:

module_constants.py:
##########################################################
# Test : Slave Market Begin ########################
##########################################################
slot_town_slave_market = 72
slave_market_parties_begin = "p_town_slave_market_2"
slave_market_parties_end = "p_salt_mine"
#########################################################
# Test : Slave Market End #########################
#########################################################

module_dialogs.py:
## Slave Market Begin
  [trp_ramun_the_slave_trader|plyr,"ramun_talk", [], "I want to buy some slaves.", "ramun_slaves",[]],
  [trp_ramun_the_slave_trader,"ramun_slaves", [], "Of course. Have a look.", "ramun_slaves2", [(store_encountered_party,reg(2)),(party_get_slot,"$slave_market_party",reg(2),slot_town_slave_market),(set_mercenary_source_party,"$slave_market_party"),(change_screen_buy_mercenaries)]],
  [trp_ramun_the_slave_trader,"ramun_slaves2", [], "Anything else?", "ramun_talk",[]],
## Slave Market End 

module_parties.py:
## Slave Markets Begin
  ("town_slave_market_2","Seals-ey Slave Market",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[(trp_ramun_the_slave_trader,1,0),(trp_looter,13,0,pmf_is_prisoner),(trp_refugee,13,0,pmf_is_prisoner)]),
  ("town_slave_market_7","Caer_Ligualid Slave Market",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[(trp_looter,6,0,pmf_is_prisoner),(trp_refugee,6,0,pmf_is_prisoner)]),
  ("town_slave_market_13","Din_Gonwy Slave Market",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[(trp_looter,6,0,pmf_is_prisoner),(trp_refugee,6,0,pmf_is_prisoner)]),  ("town_slave_market_2","Seals-ey Slave market",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[(trp_ramun_the_slave_trader,1,0),(trp_looter,13,0,pmf_is_prisoner),(trp_refugee,13,0,pmf_is_prisoner)]),
  ("town_slave_market_17","Caer_Uisc Slave Market",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[(trp_looter,6,0,pmf_is_prisoner),(trp_refugee,6,0,pmf_is_prisoner)]),  ("town_slave_market_2","Seals-ey Slave market",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[(trp_ramun_the_slave_trader,1,0),(trp_looter,13,0,pmf_is_prisoner),(trp_refugee,13,0,pmf_is_prisoner)]),
  ("town_slave_market_27","Bebbanburh_Slave Market",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[(trp_looter,6,0,pmf_is_prisoner),(trp_refugee,6,0,pmf_is_prisoner)]),
  ("town_slave_market_33","Aileach Slave Market",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[(trp_looter,6,0,pmf_is_prisoner),(trp_refugee,6,0,pmf_is_prisoner)]),
  ("town_slave_market_37","Duin Foither Slave Market",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[(trp_looter,6,0,pmf_is_prisoner),(trp_refugee,6,0,pmf_is_prisoner)]),
  ("town_slave_market_42","Din Cado Slave Market",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[(trp_looter,13,0,pmf_is_prisoner),(trp_refugee,13,0,pmf_is_prisoner)]),
## Slave Markets End
 
  ("salt_mine","Salinae",icon_town_snow|pf_is_static|pf_always_visible|pf_hide_defenders, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(-32.08,79.95),[]),

module_scripts.py, part 1:
# Towns (loop)
      (try_for_range, ":town_no", towns_begin, towns_end),
        (store_sub, ":eek:ffset", ":town_no", towns_begin),
        (party_set_slot,":town_no", slot_party_type, spt_town),
        #(store_add, ":cur_object_no", "trp_town_1_seneschal", ":eek:ffset"),
        #(party_set_slot,":town_no", slot_town_seneschal, ":cur_object_no"),
###################################################################
# Test : Slave Market Begin #################################
#####################################################################
        (store_add, ":cur_object_no", "p_town_slave_market_2", ":eek:ffset"),
(party_set_slot,":town_no", slot_town_slave_market,":cur_object_no"),
#####################################################################
# Test : Slave Market End ###################################
#####################################################################
(store_add, ":cur_object_no", "scn_town_1_center", ":eek:ffset"),
        (party_set_slot,":town_no", slot_town_center, ":cur_object_no"),

module_scripts.py, part 2:
###################################################################################
# Test : Slave Market Begin ###############################################
###################################################################################
(call_script, "script_add_slaves"),
###################################################################################
# Test : Slave Market End #################################################
###################################################################################

module_triggers.py:
#NPC system changes begin
#Move unemployed NPCs around taverns
  (24 * 15 , 0, 0,
  [
    (call_script, "script_update_companion_candidates_in_taverns"),
    ],
  []
  ),
#######################################################################################
# Test : Slave Market Begin ###################################################
#######################################################################################

(24.0, 0, 0.0, [],
  [
      (call_script, "script_add_slaves"),
               
  ],
  ),

#######################################################################################
# Test : Slave Market End #####################################################
#######################################################################################
 

The code doesn't vary markedly from the original, and I'm at a loss as to why it comes up as undefined, since it is in module_constants.py.
 
Numerically, as I assume you mean, it follows right after the last used party slot:

slot_party_last_in_any_center          = 71 #used for AI

slot_castle_exterior    = slot_town_center

#slot_town_rebellion_contact  = 76
#trs_not_yet_approached  = 0
#trs_approached_before  = 1
#trs_approached_recently = 2

##########################################################
# Test : Slave Market Begin ########################
##########################################################
slot_town_slave_market = 72
slave_market_parties_begin = "p_town_slave_market_2"
slave_market_parties_end = "p_salt_mine"
#########################################################
# Test : Slave Market End #########################
#########################################################
 
Sanctus Ferri said:
Numerically, as I assume you mean, it follows right after the last used party slot:

slot_party_last_in_any_center          = 71 #used for AI

slot_castle_exterior    = slot_town_center

#slot_town_rebellion_contact  = 76
#trs_not_yet_approached  = 0
#trs_approached_before  = 1
#trs_approached_recently = 2

##########################################################
# Test : Slave Market Begin ########################
##########################################################
slot_town_slave_market = 72
slave_market_parties_begin = "p_town_slave_market_2"
slave_market_parties_end = "p_salt_mine"
#########################################################
# Test : Slave Market End #########################
#########################################################

put this line  slot_town_slave_market = 72

directly after this line slot_party_last_in_any_center          = 71 #used for AI

so you get this


slot_party_last_in_any_center          = 71 #used for AI
slot_town_slave_market = 72
 
Done:
slot_party_last_in_combat              = 68 #used for AI
slot_party_last_in_home_center        = 69 #used for AI
slot_party_leader_last_courted        = 70 #used for AI
slot_party_last_in_any_center          = 71 #used for AI
slot_town_slave_market                = 72
slave_market_parties_begin  = "p_town_slave_market_2"
slave_market_parties_end    = "p_salt_mine"
Okay, now that I changed the right module_constant.py, (too many open in editor) that worked. Thank you very much.  Now, why did that work?  I'd like to understand this better.
 
Back
Top Bottom