OSP Code QoL [WB] Merchant's Trade Ledger

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Caba`drin

Count
M&BWBWF&SNWVC
Best answers
0
A ledger presentation system, that relies on the dynamic array scripts by sphere, conveniently packaged and made modmerger-ready here.

The ledger uses the "Assess Prices" option in market places to track the prices of items the player learns about. The ledger presentation is then sort-able by production town, destination town, item, or estimated profit. It can be trimmed by any of the things it can be sorted by. It also allows the player to specify certain items to ask about in every marketplace, based on their trade skill. A basic note-taking function is also included, though WSE would be required for editing and the like (so that code is not included...as it isn't written yet).



excuse the misspelling of caret, the lack of a subtitle, and the mis-sized buttons...these problems aren't in the code, I just don't have a more current screenshot. the top screenshot is how the current presentation appears

Code:
spt_array = -1
slot_troop_trade_ledger = 155
#sub-array party ID storage as ledger array element:
date_array        = 0
town_array        = 1
item_array        = 2
destination_array = 3
profit_array      = 4
num_ledger_sub_arrays = profit_array - date_array + 1
#custom assess items list
custom_assess_begin = num_ledger_sub_arrays
Code:
("game_log_window", 0, "game_log_window", 0, 0, 0, 0, 0, 0, 1, 1, 1),
#if you don't have this defined as a mesh already; it's native, just needs a module_system declaration
Code:
["book_trade_ledger","Merchant's Ledger", [("book_open",0)], itp_type_book, 0, 3500,weight(2)|abundance(100),imodbits_none],
#make sure that the book is within the range of other reference (non-readable) books
##Also, add to the inventory list of the "book_merchant" troops.
Code:
  ("trade_ledger_create",    
   [
    (store_script_param_1, ":troop"),
    (call_script, "script_array_create"),
    (assign, ":ledger", reg0),
    (party_set_slot, ":ledger", slot_party_type, spt_array),
    (str_store_troop_name_plural, s0, ":troop"),
    (party_set_name, ":ledger", "@{s0} Trade Ledger Array"), #For DEBUG
    (troop_set_slot, ":troop", slot_troop_trade_ledger, ":ledger"),
    (try_begin), #Not really needed yet...but maybe eventually
        (neq, ":troop", "trp_player"),
        (troop_get_slot, ":owner", ":troop", slot_troop_leaded_party),
        (gt, ":owner", 0),
        (party_is_active, ":owner"),
        (call_script, "script_array_set_owner", ":ledger", ":owner"),
    (try_end),
    (str_clear, s0),
    (try_for_range, ":unused", 0, num_ledger_sub_arrays),
        (call_script, "script_array_create"),
        (call_script, "script_array_pushback", ":ledger", reg0), #Add value at end
        (call_script, "script_array_set_owner", reg0, ":ledger"),
        (party_set_name, reg0, s0),
    (try_end), 
    
    (assign, reg0, ":ledger"),
   ]),    

 ("trade_ledger_write",
   [
    (store_script_param_1, ":num_entries"),
    (store_script_param_2, ":troop"),
    (try_begin),
        (troop_slot_ge, ":troop", slot_troop_trade_ledger, 1),
        (troop_get_slot, ":ledger", ":troop", slot_troop_trade_ledger),
        (call_script, "script_cf_array_is_array", ":ledger"),
    (else_try),
        (call_script, "script_trade_ledger_create", ":troop"),
        (assign, ":ledger", reg0),
    (try_end),
    
    (call_script, "script_array_get_element", ":ledger", date_array),
    (assign, ":date_array", reg0),
    (call_script, "script_array_get_element", ":ledger", town_array),
    (assign, ":town_array", reg0),
    (call_script, "script_array_get_element", ":ledger", item_array),
    (assign, ":item_array", reg0),
    (call_script, "script_array_get_element", ":ledger", destination_array),
    (assign, ":destination_array", reg0),
    (call_script, "script_array_get_element", ":ledger", profit_array),
    (assign, ":profit_array", reg0),
    
    (store_current_hours, ":cur_hours"),    
    (assign, ":params_begin", 3), #1 is number of entries, 2 is troop, 3 is first item
    (try_for_range, ":unused", 0, ":num_entries"),
        (call_script, "script_array_insert", ":date_array", 0, ":cur_hours"),
        (call_script, "script_array_insert", ":town_array", 0, "$current_town"),
        (store_add, ":params_end", ":params_begin", 3),
        (try_for_range, ":param", ":params_begin", ":params_end"),
            (store_script_param, ":value", ":param"),
            (store_sub, reg1, ":param", ":params_begin"),
            (eq, reg1, 0), #Item ID
            (call_script, "script_array_insert", ":item_array", 0, ":value"),
        (else_try),
            (eq, reg1, 1), #Dest Town
            (call_script, "script_array_insert", ":destination_array", 0, ":value"),
        (else_try),
            (eq, reg1, 2), #Profit
            (call_script, "script_array_insert", ":profit_array", 0, ":value"),            
        (try_end), #Item Details Loop
        (assign, ":params_begin", ":params_end"),
    (try_end), #Entries Loop
   ]),

  ("cf_trade_ledger_trim_entries",
   [
    (store_script_param_1, ":troop"),
    (store_script_param_2, ":condition"), #Num of Days, Item, or Town, or Profit Level
    (store_script_param, ":trim_type", 3),

    (troop_get_slot, ":ledger", ":troop", slot_troop_trade_ledger),
    (ge, ":ledger", 1),
    (call_script, "script_cf_array_is_array", ":ledger"),
    
    (call_script, "script_array_get_element", ":ledger", date_array),
    (assign, ":date_array", reg0),
    (call_script, "script_array_get_element", ":ledger", town_array),
    (assign, ":town_array", reg0),
    (call_script, "script_array_get_element", ":ledger", item_array),
    (assign, ":item_array", reg0),
    (call_script, "script_array_get_element", ":ledger", destination_array),
    (assign, ":destination_array", reg0),
    (call_script, "script_array_get_element", ":ledger", profit_array),
    (assign, ":profit_array", reg0),    
    
    (call_script, "script_array_get_size", ":date_array"),
    (assign, ":ledger_length", reg0),
    
    (call_script, "script_array_get_element", ":ledger", ":trim_type"),
    (assign, ":target_array", reg0),    
    
    (try_begin),
        (this_or_next|eq, ":trim_type", date_array),
        (eq, ":trim_type", profit_array),
        (try_begin),
            (eq, ":trim_type", date_array),
            (store_current_hours, ":cur_hours"),
            (val_mul, ":condition", 24),
            (store_sub, ":condition", ":cur_hours", ":condition"),
            (val_add, ":condition", 12), #Just to be a bit on the liberal side of keeping entries    
        (try_end),    
        (try_for_range_backwards, ":i", 0, ":ledger_length"),
            (call_script, "script_cf_array_get_element", ":target_array", ":i"),
            (lt, reg0, ":condition"), #older than the cutoff point / less than profit
            (call_script, "script_cf_array_remove", ":date_array", ":i"),
            (call_script, "script_cf_array_remove", ":town_array", ":i"),
            (call_script, "script_cf_array_remove", ":item_array", ":i"),
            (call_script, "script_cf_array_remove", ":destination_array", ":i"),
            (call_script, "script_cf_array_remove", ":profit_array", ":i"),    
        (try_end),
    (else_try),
        (is_between, ":trim_type", town_array, profit_array), #item or prod/demand towns
        (try_for_range_backwards, ":i", 0, ":ledger_length"),
            (call_script, "script_cf_array_get_element", ":target_array", ":i"),
            (eq, reg0, ":condition"), #matches item or town
            (call_script, "script_cf_array_remove", ":date_array", ":i"),
            (call_script, "script_cf_array_remove", ":town_array", ":i"),
            (call_script, "script_cf_array_remove", ":item_array", ":i"),
            (call_script, "script_cf_array_remove", ":destination_array", ":i"),
            (call_script, "script_cf_array_remove", ":profit_array", ":i"),    
        (try_end),    
    (try_end),
    
    (call_script, "script_array_get_size", ":date_array"),
    (store_sub, reg0, ":ledger_length", reg0), #Number of Entries Removed
    (gt, reg0, 0),
   ]),

  ("cf_trade_ledger_custom_assess_item",
   [
    (store_script_param_1, ":item"),
    (store_script_param_2, ":index"),
    (try_begin),
        (troop_slot_ge, "trp_player", slot_troop_trade_ledger, 1),
        (troop_get_slot, ":ledger", "trp_player", slot_troop_trade_ledger),
        (call_script, "script_cf_array_is_array", ":ledger"),
    (else_try),
        (call_script, "script_trade_ledger_create", "trp_player"),
        (assign, ":ledger", reg0),
    (try_end),
    
    (ge, ":index", custom_assess_begin),
    (assign, ":item_added", 0),    
    (try_begin),
        (call_script, "script_cf_array_get_element", ":ledger", ":index"),
        (is_between, reg0, trade_goods_begin, trade_goods_end),
        (call_script, "script_cf_array_set_element", ":ledger", ":index", ":item"),
        (assign, ":item_added", 1),    
    (else_try),
        (call_script, "script_cf_array_insert", ":ledger", ":index", ":item"),
        (assign, ":item_added", 1),    
    (try_end),
    (eq, ":item_added", 1),
   ]),    
  
 ("cf_trade_ledger_custom_assess_duplicates",
   [    
    #Test for duplication among custom assesment items
    (troop_get_slot, ":ledger", "trp_player", slot_troop_trade_ledger),
    (ge, ":ledger", 1),
    (call_script, "script_cf_array_is_array", ":ledger"),
    (assign, ":dupe_removed", 0),
    (call_script, "script_get_max_skill_of_player_party", "skl_trade"),
    (assign, ":max_skill", reg0),
    (val_max, ":max_skill", 1), #at least 1 
    (val_add, ":max_skill", custom_assess_begin), ##do i need to add another +1?
    (try_for_range, ":index", custom_assess_begin, ":max_skill"),
        (call_script, "script_cf_array_get_element", ":ledger", ":index"),
        (assign, ":item", reg0),
        (try_for_range_backwards, ":i", custom_assess_begin, ":max_skill"),
            (neq, ":i", ":index"),
            (call_script, "script_cf_array_get_element", ":ledger", ":i"),
            (eq, reg0, ":item"),
            (call_script, "script_cf_array_remove", ":ledger", ":i"),
            (assign, ":dupe_removed", 1),
        (try_end),
    (try_end),
    (eq, ":dupe_removed", 1),
   ]),
Code:
         (str_store_party_name, s5, ":best_result_1_town"),
         (str_store_string, s3, "@^Buying {s4} here and selling it at {s5} would bring a profit of {reg6} denars per item.{s3}"),
       (try_end),
#Trade Ledger Begin
    (try_begin),
            (gt, ":num_best_results", 0),
            (store_item_kind_count, reg0, "itm_book_trade_ledger"),
            (ge, reg0, 1),
            (assign, ":num_to_write", ":num_best_results"), ##To deal with maximum of 15 script arguments had to break into 2 "write" operations
            (val_min, ":num_to_write", 3),
            (call_script, "script_trade_ledger_write", ":num_to_write", "trp_player", ":best_result_1_item", ":best_result_1_town", ":best_result_1_profit", ":best_result_2_item", ":best_result_2_town", ":best_result_2_profit", ":best_result_3_item", ":best_result_3_town", ":best_result_3_profit"),
            (gt, ":num_best_results", ":num_to_write"),
            (store_sub, ":num_to_write", ":num_best_results", ":num_to_write"),
            (call_script, "script_trade_ledger_write", ":num_to_write", "trp_player", ":best_result_4_item", ":best_result_4_town", ":best_result_4_profit", ":best_result_5_item", ":best_result_5_town", ":best_result_5_profit"),
        (try_end),
        (try_begin),
            (troop_slot_ge, "trp_player", slot_troop_trade_ledger, 1),
            (troop_get_slot, ":ledger", "trp_player", slot_troop_trade_ledger),
            (call_script, "script_cf_array_is_array", ":ledger"),
            (call_script, "script_array_get_size", ":ledger"), 
            (gt, reg0, custom_assess_begin), #There are items slotted to assess
            (assign, ":ledger_length", reg0),
            (try_for_range, ":i", custom_assess_begin, ":ledger_length"),
                (call_script, "script_cf_array_get_element", ":ledger", ":i"),
                (is_between, reg0, trade_goods_begin, trade_goods_end),
                (neq, ":best_result_1_item", reg0),
                (neq, ":best_result_2_item", reg0),
                (neq, ":best_result_3_item", reg0),
                (neq, ":best_result_4_item", reg0), 
                (neq, ":best_result_5_item", reg0), #Not already included in the standard run of "assess prices"
                (assign, ":trade_good", reg0),
                #Check if it can be bought
                (party_get_slot, ":merchant", "$current_town", slot_town_merchant),
                (store_item_kind_count, reg0, ":trade_good", ":merchant"),
                (ge, reg0, 1), #The merchant carries it
                (store_mul, ":max_iteration", ":num_towns", ":max_skill"),
                (val_div, ":max_iteration", 10),
                (assign, ":profit", 0),
                (assign, ":dest_town", -1),
                (try_for_range, ":unused", 0, ":max_iteration"),
                    (store_random_in_range, ":random_town", towns_begin, towns_end),
                    (neq, ":random_town", ":dest_town"),
                    (store_item_value, ":trade_good_price", ":trade_good"),
                    (assign, "$g_encountered_party", ":org_encountered_party"),
                    (call_script, "script_game_get_item_buy_price_factor", ":trade_good"),
                    (store_mul, ":trade_good_buy_price", ":trade_good_price", reg0),
                    (val_div, ":trade_good_buy_price", 100),
                    (val_max, ":trade_good_buy_price", 1),
                    (assign, "$g_encountered_party", ":random_town"),
                    (call_script, "script_game_get_item_sell_price_factor", ":trade_good"),
                    (store_mul, ":trade_good_sell_price", ":trade_good_price", reg0),
                    (val_div, ":trade_good_sell_price", 100),
                    (val_max, ":trade_good_sell_price", 1),
                    (store_sub, ":difference", ":trade_good_sell_price", ":trade_good_buy_price"),
                    (gt, ":difference", ":profit"),
                    (assign, ":dest_town", ":random_town"),
                    (assign, ":profit", ":difference"),
                (try_end), #Best price loop
                (neq, ":dest_town", -1),
                (str_store_item_name, s4, ":trade_good"),
                (str_store_party_name, s5, ":dest_town"),
                (str_store_string, s3, "@^Buying {s4} here and selling it at {s5} would bring a profit of {reg6} denars per item.{s3}"),
                (call_script, "script_trade_ledger_write", 1, "trp_player", ":trade_good", ":dest_town", ":profit"),
            (try_end), #Custom Item loop
            (assign, "$g_encountered_party", ":org_encountered_party"),
        (try_end),
#Trade Ledger End
       (str_store_string, s2, "@{reg3?You find:{s1} finds} out the following:^{s3}"),
     (try_end),
     ],
Code:
        ("action_view_trade_ledger", 
            [
                (store_item_kind_count, reg0, "itm_book_trade_ledger"),
                (ge, reg0, 1),
                #Ensure it has been written to:
                (assign, reg60, 0),
                (troop_slot_ge, "trp_player", slot_troop_trade_ledger, 1),
                (troop_get_slot, ":ledger", "trp_player", slot_troop_trade_ledger),
                (call_script, "script_cf_array_is_array", ":ledger"),
                (call_script, "script_array_get_element", ":ledger", date_array),
                (call_script, "script_array_get_size", reg0),
                (ge, reg0, 1),
                (assign, reg60, 1),
            ],"View Your Trade Ledger.",
            [
                (assign, reg60, 0), #begin in Default view
                (start_presentation, "prsnt_trade_ledger_basic"),
            ]),
        ("action_view_trade_ledger_denied",
            [    
            #Only show this when the player owns a ledger, but has not written to it yet
                (store_item_kind_count, reg0, "itm_book_trade_ledger"),
                (ge, reg0, 1),
                (eq, reg60, 0), #from above; hasn't been written to            
                (disable_menu_option),
            ], "Assess Items to start your Trade Ledger.", []),


module_presentations in next post

 

Caba`drin

Count
M&BWBWF&SNWVC
Best answers
0
Code:
  ("trade_ledger_basic", 0, mesh_game_log_window, [ 
    (ti_on_presentation_load,
     [(set_fixed_point_multiplier, 1000),      

      (create_text_overlay, reg0, "@Merchant Ledger", tf_center_justify|tf_single_line|tf_with_outline),
      (overlay_set_color, reg0, 0xFFFFFFFF),
      (position_set_x, pos1, 1500),
      (position_set_y, pos1, 1500),
      (overlay_set_size, reg0, pos1),
      (position_set_x, pos1, 500),
      (position_set_y, pos1, 680),
      (overlay_set_position, reg0, pos1),

      (create_text_overlay, reg0, "@____Assessed Profit by Subtitle Here", tf_center_justify|tf_single_line), #Subtitle
      (position_set_x, pos1, 500),
      (position_set_y, pos1, 650),
      (overlay_set_position, reg0, pos1),
      
      ##Ledger Pane
      (str_clear, s0),
      (create_text_overlay, "$g_presentation_obj_bugdet_report_container", s0, tf_scrollable_style_2),
      (position_set_x, pos1, 50),
      (position_set_y, pos1, 100),
      (overlay_set_position, "$g_presentation_obj_bugdet_report_container", pos1),
      (position_set_x, pos1, 600),
      (position_set_y, pos1, 500), 
      (overlay_set_area_size, "$g_presentation_obj_bugdet_report_container", pos1),
      (set_container_overlay, "$g_presentation_obj_bugdet_report_container"),
      
      (troop_get_slot, ":ledger", "trp_player", slot_troop_trade_ledger),
      (ge, ":ledger", 1),
      (call_script, "script_cf_array_is_array", ":ledger"),
      (call_script, "script_array_get_element", ":ledger", date_array),
      (assign, ":date_array", reg0),
      (call_script, "script_array_get_element", ":ledger", town_array),
      (assign, ":town_array", reg0),
      (call_script, "script_array_get_element", ":ledger", item_array),
      (assign, ":item_array", reg0),
      (call_script, "script_array_get_element", ":ledger", destination_array),
      (assign, ":destination_array", reg0),
      (call_script, "script_array_get_element", ":ledger", profit_array),
      (assign, ":profit_array", reg0),
        
      (call_script, "script_array_get_size", ":date_array"),
      (assign, ":ledger_length", reg0),
      (store_mul, ":cur_y", ":ledger_length", 30),

      (try_begin),
          (eq, reg60, 0), #Default (Chronological) View
          (assign, ":next_entry", 0),
          (try_for_range, ":i", 0, ":ledger_length"),
            (eq, ":i", ":next_entry"),
            
            (call_script, "script_cf_array_get_element", ":date_array", ":i"),
            (assign, ":date", reg0),
            (str_store_date, s0, ":date"),
            (call_script, "script_cf_array_get_element", ":town_array", ":i"),
            (assign, ":town", reg0),
            (str_store_party_name, s1, ":town"),
            #DISPLAY DAY, TOWN in one overlay
            (create_text_overlay, reg0, "@{s0}, products from {s1}:"),
            (position_set_x, pos1, 1000),
            (position_set_y, pos1, 1000),
            (overlay_set_size, reg0, pos1),
            (position_set_x, pos1, 25),
            (position_set_y, pos1, ":cur_y"),
            (overlay_set_position, reg0, pos1),
            
            (assign, ":end", ":ledger_length"),
            (assign, ":end_index", ":end"), #Should get overwritten in below loop
            #(store_add, ":next_entry", ":i", 1), #Should get overwritten in below loop #necessary fail-safe?
            (try_for_range, ":n", ":i", ":end"), #This loop finds the end of the current set of entries
                (call_script, "script_cf_array_get_element", ":date_array", ":n"),
                (assign, ":test_date", reg0),
                (call_script, "script_cf_array_get_element", ":town_array", ":n"),
                (this_or_next|neq, ":town", reg0), #Once the date OR the town change, it is a new entry
                (neq, ":date", ":test_date"),
                (assign, ":end_index", ":n"),
                (assign, ":next_entry", ":n"),
                (assign, ":end", 0), #Break
            (try_end),

            (assign, ":line_count", 0),
            (str_clear, s3),
            (try_for_range, ":n", ":i", ":end_index"),
                (val_add, ":line_count", 1),
                (call_script, "script_cf_array_get_element", ":item_array", ":n"),
                (str_store_item_name, s1, reg0),
                (call_script, "script_cf_array_get_element", ":destination_array", ":n"),
                (str_store_party_name, s2, reg0),
                (call_script, "script_cf_array_get_element", ":profit_array", ":n"),
                (str_store_string, s3, "@^{s1} sold in {s2} would earn {reg0} denars.{s3}"),    
            (try_end), #Item Loop    
            
            (val_mul, ":line_count", 14),
            (val_sub, ":cur_y", ":line_count"),
            #CREATE ITEM, DEST, PROFIT for all items in one overlay
            (create_text_overlay, reg0, s3),
            (position_set_x, pos1, 800),
            (position_set_y, pos1, 800),
            (overlay_set_size, reg0, pos1),
            (position_set_x, pos1, 50),
            (position_set_y, pos1, ":cur_y"),
            (overlay_set_position, reg0, pos1),
            (val_sub, ":cur_y", 30),            
          (try_end), #Town Entry Loop
          (store_sub, reg0, "$g_presentation_obj_bugdet_report_container", 1),
          (overlay_set_text, reg0, "@__Assessed Profit by Log Entry Date"),
        (else_try),
          (eq, reg60, 1), #Origin View
          (try_for_range, ":cur_town", towns_begin, towns_end),
            (assign, ":line_count", 0),
            (assign, ":profit", 0),
            (try_for_range, ":i", 0, ":ledger_length"),
                (call_script, "script_cf_array_get_element", ":town_array", ":i"),
                (eq, ":cur_town", reg0),
                (call_script, "script_cf_array_get_element", ":profit_array", ":i"),
                (val_add, ":profit", reg0),    
                (val_add, ":line_count", 1),
            (try_end),
            (val_max, ":line_count", 1), #Ensure no Div-by-0
            (val_div, ":profit", ":line_count"),
            (troop_set_slot, "trp_temp_array_b", ":cur_town", ":profit"),
          (try_end),
          (assign, ":max_profit", 0),
          (try_for_range, ":i", towns_begin, towns_end),
            (troop_get_slot, reg0, "trp_temp_array_b", ":i"),
            (lt, ":max_profit", reg0),
            (assign, ":max_profit", reg0),
          (try_end),
          (val_add, ":max_profit", 1),
          (try_for_range_backwards, ":profit", 0, ":max_profit"),
            (try_for_range, ":cur_town", towns_begin, towns_end),
                (troop_slot_eq, "trp_temp_array_b", ":cur_town", ":profit"),

                (assign, ":line_count", 0),
                (str_clear, s3),
                (try_for_range, ":i", 0, ":ledger_length"),
                    (call_script, "script_cf_array_get_element", ":town_array", ":i"),
                    (eq, ":cur_town", reg0),
                    (val_add, ":line_count", 1),

                    (call_script, "script_cf_array_get_element", ":date_array", ":i"),
                    (str_store_date, s0, reg0),
                    (call_script, "script_cf_array_get_element", ":item_array", ":i"),
                    (str_store_item_name, s1, reg0),
                    (call_script, "script_cf_array_get_element", ":destination_array", ":i"),
                    (str_store_party_name, s2, reg0),
                    (call_script, "script_cf_array_get_element", ":profit_array", ":i"),
                    (str_store_string, s3, "@^{s1} sold in {s2} would earn {reg0} denars (as of {s0}).{s3}"),            
                (try_end), #Entry Loop
                (ge, ":line_count", 1),
                
                #DISPLAY TOWN header in one overlay
                (str_store_party_name, s1, ":cur_town"),
                (str_store_string, s1, "@Production in {s1}"),
                (create_text_overlay, reg0, s1),
                (position_set_x, pos1, 1000),
                (position_set_y, pos1, 1000),
                (overlay_set_size, reg0, pos1),
                (position_set_x, pos1, 25),
                (position_set_y, pos1, ":cur_y"),
                (overlay_set_position, reg0, pos1),

                
                (val_mul, ":line_count", 14),
                (val_sub, ":cur_y", ":line_count"),
                
                #ITEM, DEST, PROFIT, and DATE for all items in one overlay
                (create_text_overlay, reg0, s3),
                (position_set_x, pos1, 800),
                (position_set_y, pos1, 800),
                (overlay_set_size, reg0, pos1),
                (position_set_x, pos1, 50),
                (position_set_y, pos1, ":cur_y"),
                (overlay_set_position, reg0, pos1),
                (val_sub, ":cur_y", 30),    
              (try_end), #Town-Profit Loop
          (try_end), #Profit Values Loop
          
          (store_sub, reg0, "$g_presentation_obj_bugdet_report_container", 1),
          (overlay_set_text, reg0, "@Assessed Profit by Town of Production"),
        (else_try),
          (eq, reg60, 2), #Destination View
          (try_for_range, ":cur_town", towns_begin, towns_end),
            (assign, ":line_count", 0),
            (assign, ":profit", 0),
            (try_for_range, ":i", 0, ":ledger_length"),
                (call_script, "script_cf_array_get_element", ":destination_array", ":i"),
                (eq, ":cur_town", reg0),
                (call_script, "script_cf_array_get_element", ":profit_array", ":i"),
                (val_add, ":profit", reg0),    
                (val_add, ":line_count", 1),
            (try_end),
            (val_max, ":line_count", 1), #Ensure no Div-by-0
            (val_div, ":profit", ":line_count"),
            (troop_set_slot, "trp_temp_array_b", ":cur_town", ":profit"),
          (try_end),
          (assign, ":max_profit", 0),
          (try_for_range, ":i", towns_begin, towns_end),
            (troop_get_slot, reg0, "trp_temp_array_b", ":i"),
            (lt, ":max_profit", reg0),
            (assign, ":max_profit", reg0),
          (try_end),
          (val_add, ":max_profit", 1),
          (try_for_range_backwards, ":profit", 0, ":max_profit"),
            (try_for_range, ":cur_town", towns_begin, towns_end),
                (troop_slot_eq, "trp_temp_array_b", ":cur_town", ":profit"),

                (assign, ":line_count", 0),
                (str_clear, s3),
                (try_for_range, ":i", 0, ":ledger_length"),
                    (call_script, "script_cf_array_get_element", ":destination_array", ":i"),
                    (eq, ":cur_town", reg0),
                    (val_add, ":line_count", 1),

                    (call_script, "script_cf_array_get_element", ":date_array", ":i"),
                    (str_store_date, s0, reg0),
                    (call_script, "script_cf_array_get_element", ":item_array", ":i"),
                    (str_store_item_name, s1, reg0),
                    (call_script, "script_cf_array_get_element", ":town_array", ":i"),
                    (str_store_party_name, s2, reg0),
                    (call_script, "script_cf_array_get_element", ":profit_array", ":i"),
                    (str_store_string, s3, "@^{s1} purchased in {s2} would earn {reg0} denars (as of {s0}).{s3}"),            
                (try_end), #Entry Loop
                (ge, ":line_count", 1),
                
                #DISPLAY TOWN header in one overlay
                (str_store_party_name, s1, ":cur_town"),
                (str_store_string, s1, "@Demand in {s1}"),
                (create_text_overlay, reg0, s1),
                (position_set_x, pos1, 1000),
                (position_set_y, pos1, 1000),
                (overlay_set_size, reg0, pos1),
                (position_set_x, pos1, 25),
                (position_set_y, pos1, ":cur_y"),
                (overlay_set_position, reg0, pos1),

                (val_mul, ":line_count", 14),
                (val_sub, ":cur_y", ":line_count"),
                
                #ITEM, DEST, PROFIT, and DATE for all items in one overlay
                (create_text_overlay, reg0, s3),
                (position_set_x, pos1, 800),
                (position_set_y, pos1, 800),
                (overlay_set_size, reg0, pos1),
                (position_set_x, pos1, 50),
                (position_set_y, pos1, ":cur_y"),
                (overlay_set_position, reg0, pos1),
                (val_sub, ":cur_y", 30),    
              (try_end), #Town-Profit Loop
          (try_end), #Profit Values Loop
          (store_sub, reg0, "$g_presentation_obj_bugdet_report_container", 1),
          (overlay_set_text, reg0, "@Assessed Profit by Town of Demand"),
        (else_try),
          (eq, reg60, 3), #Item View
          (try_for_range, ":cur_item", trade_goods_begin, trade_goods_end),
            (assign, ":line_count", 0),
            (assign, ":profit", 0),
            (try_for_range, ":i", 0, ":ledger_length"),
                (call_script, "script_cf_array_get_element", ":item_array", ":i"), 
                (eq, ":cur_item", reg0),
                (call_script, "script_cf_array_get_element", ":profit_array", ":i"),
                (val_add, ":profit", reg0),    
                (val_add, ":line_count", 1),
            (try_end),
            (val_max, ":line_count", 1), #Ensure no Div-by-0
            (val_div, ":profit", ":line_count"),
            (troop_set_slot, "trp_temp_array_b", ":cur_item", ":profit"),
          (try_end),
          (assign, ":max_profit", 0),
          (try_for_range, ":i", trade_goods_begin, trade_goods_end),
            (troop_get_slot, reg0, "trp_temp_array_b", ":i"),
            (lt, ":max_profit", reg0),
            (assign, ":max_profit", reg0),
          (try_end),
          (val_add, ":max_profit", 1),
          (try_for_range_backwards, ":profit", 0, ":max_profit"),
            (try_for_range, ":cur_item", trade_goods_begin, trade_goods_end),
                (troop_slot_eq, "trp_temp_array_b", ":cur_item", ":profit"),

                (assign, ":line_count", 0),
                (str_clear, s3),
                (try_for_range, ":i", 0, ":ledger_length"),
                    (call_script, "script_cf_array_get_element", ":item_array", ":i"),
                    (eq, ":cur_item", reg0),
                    (val_add, ":line_count", 1),

                    (call_script, "script_cf_array_get_element", ":date_array", ":i"),
                    (str_store_date, s0, reg0),
                    (call_script, "script_cf_array_get_element", ":town_array", ":i"),
                    (str_store_party_name, s1, reg0),
                    (call_script, "script_cf_array_get_element", ":destination_array", ":i"),
                    (str_store_party_name, s2, reg0),
                    (call_script, "script_cf_array_get_element", ":profit_array", ":i"),
                    (str_store_string, s3, "@^Buy in: {s1} - sell in: {s2} for {reg0} denars profit (as of {s0}).{s3}"),            
                (try_end), #Entry Loop
                (ge, ":line_count", 1),
                
                #DISPLAY ITEM header in one overlay
                (str_store_item_name, s1, ":cur_item"),
                (str_store_string, s1, "@Supply and Demand of {s1}"),
                (create_text_overlay, reg0, s1),
                (position_set_x, pos1, 1000),
                (position_set_y, pos1, 1000),
                (overlay_set_size, reg0, pos1),
                (position_set_x, pos1, 25),
                (position_set_y, pos1, ":cur_y"),
                (overlay_set_position, reg0, pos1),

                (val_mul, ":line_count", 14),
                (val_sub, ":cur_y", ":line_count"),
                
                #Origin, DEST, PROFIT, and DATE for all towns in one overlay
                (create_text_overlay, reg0, s3),
                (position_set_x, pos1, 800),
                (position_set_y, pos1, 800),
                (overlay_set_size, reg0, pos1),
                (position_set_x, pos1, 50),
                (position_set_y, pos1, ":cur_y"),
                (overlay_set_position, reg0, pos1),
                (val_sub, ":cur_y", 30),    
              (try_end), #Item-Profit Loop
          (try_end), #Profit Values Loop
          (store_sub, reg0, "$g_presentation_obj_bugdet_report_container", 1),
          (overlay_set_text, reg0, "@____Assessed Profit by Trade Good"),
        (else_try),
          (eq, reg60, 4),
          (assign, ":cur_y", 750),
          
          (create_text_overlay, reg0, "@Trim ledger entries older than:______________days:"),
          (position_set_x, pos1, 900),
          (position_set_y, pos1, 900),
          (overlay_set_size, reg0, pos1),
          (position_set_x, pos1, 50),
          (position_set_y, pos1, ":cur_y"),
          (overlay_set_position, reg0, pos1),
          
          (create_number_box_overlay, "$g_presentation_obj_custom_battle_designer_17", 3, 1001),
          (position_set_x, pos1, 285),
          (position_set_y, pos1, ":cur_y"),
          (overlay_set_position, "$g_presentation_obj_custom_battle_designer_17", pos1),
          (overlay_set_val, "$g_presentation_obj_custom_battle_designer_17", 3),
          (val_sub, ":cur_y", 30),
          
          (create_button_overlay, reg0, "@Remove entries."),
          (position_set_x, pos1, 900),
          (position_set_y, pos1, 900),
          (overlay_set_size, reg0, pos1),
          (position_set_x, pos1, 290),
          (position_set_y, pos1, ":cur_y"),
          (overlay_set_position, reg0, pos1),
          (val_sub, ":cur_y", 40),
          
          (create_text_overlay, reg0, "@Trim ledger entries covering the following trade good:"),
          (position_set_x, pos1, 900),
          (position_set_y, pos1, 900),
          (overlay_set_size, reg0, pos1),
          (position_set_x, pos1, 50),
          (position_set_y, pos1, ":cur_y"),
          (overlay_set_position, reg0, pos1),
          (val_sub, ":cur_y", 40),
          
          (create_slider_overlay, "$g_presentation_obj_custom_battle_designer_16", trade_goods_begin, trade_goods_end),
          (position_set_x, pos1, 200),
          (position_set_y, pos1, ":cur_y"),
          (overlay_set_position, "$g_presentation_obj_custom_battle_designer_16", pos1),
                
          (create_text_overlay, reg0, "@Use slider to choose item"),
          (position_set_x, pos1, 900),
          (position_set_y, pos1, 900),
          (overlay_set_size, reg0, pos1),
          (position_set_x, pos1, 350),
          (position_set_y, pos1, ":cur_y"),
          (overlay_set_position, reg0, pos1),
          (val_sub, ":cur_y", 30),
          
          (create_button_overlay, reg0, "@Remove entries."),
          (position_set_x, pos1, 900),
          (position_set_y, pos1, 900),
          (overlay_set_size, reg0, pos1),
          (position_set_x, pos1, 290),
          (position_set_y, pos1, ":cur_y"),
          (overlay_set_position, reg0, pos1),
          (val_sub, ":cur_y", 40),
          
          (create_text_overlay, reg0, "@Trim ledger entries for goods tied to this town:"),
          (position_set_x, pos1, 900),
          (position_set_y, pos1, 900),
          (overlay_set_size, reg0, pos1),
          (position_set_x, pos1, 50),
          (position_set_y, pos1, ":cur_y"),
          (overlay_set_position, reg0, pos1),
          (val_sub, ":cur_y", 40),
          
          (create_slider_overlay, "$g_presentation_obj_custom_battle_designer_15", towns_begin, towns_end),
          (position_set_x, pos1, 200),
          (position_set_y, pos1, ":cur_y"),
          (overlay_set_position, "$g_presentation_obj_custom_battle_designer_15", pos1),
                
          (create_text_overlay, reg0, "@Use slider to choose town"),
          (position_set_x, pos1, 900),
          (position_set_y, pos1, 900),
          (overlay_set_size, reg0, pos1),
          (position_set_x, pos1, 350),
          (position_set_y, pos1, ":cur_y"),
          (overlay_set_position, reg0, pos1),
          (val_sub, ":cur_y", 30),
                    
          (create_button_overlay, reg0, "@Remove entries (Production)."),
          (position_set_x, pos1, 900),
          (position_set_y, pos1, 900),
          (overlay_set_size, reg0, pos1),
          (position_set_x, pos1, 290),
          (position_set_y, pos1, ":cur_y"),
          (overlay_set_position, reg0, pos1),
          (val_sub, ":cur_y", 20),
          
          (create_button_overlay, reg0, "@Remove entries (Demand)."),
          (position_set_x, pos1, 900),
          (position_set_y, pos1, 900),
          (overlay_set_size, reg0, pos1),
          (position_set_x, pos1, 290),
          (position_set_y, pos1, ":cur_y"),
          (overlay_set_position, reg0, pos1),
          (val_sub, ":cur_y", 40),
          
          (create_text_overlay, reg0, "@Trim ledger entries with less than:______________denar profit:"),
          (position_set_x, pos1, 900),
          (position_set_y, pos1, 900),
          (overlay_set_size, reg0, pos1),
          (position_set_x, pos1, 50),
          (position_set_y, pos1, ":cur_y"),
          (overlay_set_position, reg0, pos1),
          
          (create_number_box_overlay, "$g_presentation_obj_custom_battle_designer_14", 10, 1001),
          (position_set_x, pos1, 305),
          (position_set_y, pos1, ":cur_y"),
          (overlay_set_position, "$g_presentation_obj_custom_battle_designer_14", pos1),
          (overlay_set_val, "$g_presentation_obj_custom_battle_designer_14", 10),
          (val_sub, ":cur_y", 30),
          
          (create_button_overlay, reg0, "@Remove entries."),
          (position_set_x, pos1, 900),
          (position_set_y, pos1, 900),
          (overlay_set_size, reg0, pos1),
          (position_set_x, pos1, 290),
          (position_set_y, pos1, ":cur_y"),
          (overlay_set_position, reg0, pos1),
          (val_sub, ":cur_y", 60),
                    
          (create_text_overlay, reg0, "@Ask about the potential profit of the following items^____every time you assess prices in a marketplace:"),
          (position_set_x, pos1, 900),
          (position_set_y, pos1, 900),
          (overlay_set_size, reg0, pos1),
          (position_set_x, pos1, 50),
          (position_set_y, pos1, ":cur_y"),
          (overlay_set_position, reg0, pos1),
          (val_sub, ":cur_y", 40),
          
          (call_script, "script_get_max_skill_of_player_party", "skl_trade"),
          (assign, ":max_skill", reg0),
          (val_max, ":max_skill", 1), #at least 1
          (store_add, ":array_size", ":max_skill", custom_assess_begin),
          (assign, ":ledger_length", ":array_size"),
          (try_begin),
            (call_script, "script_array_get_size", ":ledger"),
            (lt, reg0, ":array_size"), #array not big enough
            (val_sub, ":array_size", reg0),
            (try_for_range, ":unused", 0, ":array_size"),
                (call_script, "script_array_pushback", ":ledger", -1), #Increase array's size
            (try_end),          
          (try_end),
          
          (try_for_range, ":i", custom_assess_begin, ":ledger_length"),
                (create_slider_overlay, ":overlay", trade_goods_begin, trade_goods_end),
                (position_set_x, pos1, 200),
                (position_set_y, pos1, ":cur_y"),
                (overlay_set_position, ":overlay", pos1),
                
                (create_text_overlay, reg0, s0),
                (position_set_x, pos1, 900),
                (position_set_y, pos1, 900),
                (overlay_set_size, reg0, pos1),
                (position_set_x, pos1, 350),
                (position_set_y, pos1, ":cur_y"),
                (overlay_set_position, reg0, pos1),
                (val_sub, ":cur_y", 40),
                
                (troop_set_slot, "trp_temp_array_c", ":i", ":overlay"),
                (try_begin),
                    (call_script, "script_cf_array_get_element", ":ledger", ":i"),
                    (is_between, reg0, trade_goods_begin, trade_goods_end),
                    (str_store_item_name, s0, reg0),
                    (overlay_set_val, ":overlay", reg0),
                (else_try),
                    (str_store_string, s0, "@Use slider to choose item"),
                (try_end),
                (val_add, ":overlay", 1),
                (overlay_set_text, ":overlay", s0),
          (try_end),
           
          (store_sub, reg0, "$g_presentation_obj_bugdet_report_container", 1),
          (overlay_set_text, reg0, "@___________Log Entry Options"),
      (try_end),      
      (set_container_overlay, -1),
      
      ##Note Pad Pane
      (create_mesh_overlay, reg0, "mesh_white_plane"),
      (overlay_set_alpha, reg0, 0x30),
      (position_set_x, pos1, 11550),
      (position_set_y, pos1, 19500),
      (overlay_set_size, reg0, pos1),
      (position_set_x, pos1, 700),
      (position_set_y, pos1, 210),
      (overlay_set_position, reg0, pos1),      
      
      (str_store_party_name, s0, ":date_array"),
      (create_text_overlay, "$g_presentation_obj_custom_battle_designer_18", s0, tf_scrollable_style_2),
      (position_set_x, pos1, 800),
      (position_set_y, pos1, 800),
      (overlay_set_size, "$g_presentation_obj_custom_battle_designer_18", pos1),
      (position_set_x, pos1, 700),
      (position_set_y, pos1, 210),
      (overlay_set_position, "$g_presentation_obj_custom_battle_designer_18", pos1),
      (position_set_x, pos1, 230),
      (position_set_y, pos1, 390),
      (overlay_set_area_size, "$g_presentation_obj_custom_battle_designer_18", pos1),
      
      (create_button_overlay, reg0, "@Add Note"),
      (position_set_x, pos1, 900),
      (position_set_y, pos1, 900),
      (overlay_set_size, reg0, pos1),
      (position_set_x, pos1, 700),
      (position_set_y, pos1, 150),
      (overlay_set_position, reg0, pos1),    
      
      (create_button_overlay, reg0, "@Clear Notes"),
      (position_set_x, pos1, 900),
      (position_set_y, pos1, 900),
      (overlay_set_size, reg0, pos1),
      (position_set_x, pos1, 830),
      (position_set_y, pos1, 150),
      (overlay_set_position, reg0, pos1),
    
      (create_simple_text_box_overlay, reg0),
      (position_set_x, pos1, 228),
      (position_set_y, pos1, 800),
      (overlay_set_size, reg0, pos1),
      (position_set_x, pos1, 700),
      (position_set_y, pos1, 180),
      (overlay_set_position, reg0, pos1),

      (create_text_overlay, reg0, "@Use a /\ (caret) for a line break."), # \%^
      (position_set_x, pos1, 700),
      (position_set_y, pos1, 700),
      (overlay_set_size, reg0, pos1),
      (position_set_x, pos1, 730),
      (position_set_y, pos1, 120),
      (overlay_set_position, reg0, pos1),      
      
      ##Bottom Row Buttons      
      (create_game_button_overlay, "$g_presentation_obj_custom_battle_designer_19", "@Chronological Log", 0),
      (position_set_x, pos1, 260),
      (position_set_y, pos1, 10),
      (overlay_set_position, "$g_presentation_obj_custom_battle_designer_19", pos1),
      
      (create_game_button_overlay, reg0, "@Production Towns", 0),
      (position_set_x, pos1, 420),
      (position_set_y, pos1, 10),
      (overlay_set_position, reg0, pos1),      
            
      (create_game_button_overlay, reg0, "@Purchasing Towns", 0),
      (position_set_x, pos1, 580),
      (position_set_y, pos1, 10),
      (overlay_set_position, reg0, pos1),          
            
      (create_game_button_overlay, reg0, "@Trade Goods", 0),
      (position_set_x, pos1, 740),
      (position_set_y, pos1, 10),
      (overlay_set_position, reg0, pos1),    
      
      (create_game_button_overlay, reg0, "@Manage Ledger", 0), #On Far Left
      (position_set_x, pos1, 100),
      (position_set_y, pos1, 10),
      (overlay_set_position, reg0, pos1),

      (create_game_button_overlay, "$g_presentation_obj_custom_battle_designer_20", "@Done", 0),
      (position_set_x, pos1, 900),
      (position_set_y, pos1, 10),
      (overlay_set_position, "$g_presentation_obj_custom_battle_designer_20", pos1),
      
      (str_clear, s0),
      (assign, reg56, 10),
      (assign, reg57, -1),
      (assign, reg58, -1),
      (assign, reg59, 3),
      
      (presentation_set_duration, 999999),
      ]),
    (ti_on_presentation_run,
      [    
        (key_clicked, key_escape),
        (try_begin),
            (eq, reg60, 4),#Leaving Config/Options Page
            (call_script, "script_cf_trade_ledger_custom_assess_duplicates"),
        (try_end),
        (presentation_set_duration, 0),
      ]),
    (ti_on_presentation_event_state_change,
     [
        (store_trigger_param_1, ":object"),
        (store_trigger_param_2, ":value"),
        (try_begin),
           (eq, ":object", "$g_presentation_obj_custom_battle_designer_20"),
           (try_begin),
                (eq, reg60, 4),#Leaving Config/Options Page
                (call_script, "script_cf_trade_ledger_custom_assess_duplicates"),
           (try_end),
           (presentation_set_duration, 0),
        (else_try),  #Add Note
            (store_add, ":overlay", "$g_presentation_obj_custom_battle_designer_18", 1),
            (eq, ":object", ":overlay"),
            (neg|str_is_empty, s0),
            (troop_get_slot, ":ledger", "trp_player", slot_troop_trade_ledger),
            (ge, ":ledger", 1),
            (call_script, "script_array_get_element", ":ledger", 0),
            (str_store_party_name, s1, reg0),
            (str_store_string, s1, "@{s1}^+{s0}"),
            (party_set_name, reg0, s1),
            (overlay_set_text, "$g_presentation_obj_custom_battle_designer_18", s1),
            (str_clear, s0),
            (val_add, ":overlay", 2),
            (overlay_set_text, ":overlay", s0),
        (else_try), #Clear Notes
            (store_add, ":overlay", "$g_presentation_obj_custom_battle_designer_18", 2),
            (eq, ":object", ":overlay"),
            (troop_get_slot, ":ledger", "trp_player", slot_troop_trade_ledger),
            (ge, ":ledger", 1),
            (call_script, "script_array_get_element", ":ledger", 0),
            (str_clear, s0),
            (party_set_name, reg0, s0),
            (overlay_set_text, "$g_presentation_obj_custom_battle_designer_18", s0),
        (else_try), #Log View Changes
            (is_between, ":object", "$g_presentation_obj_custom_battle_designer_19", "$g_presentation_obj_custom_battle_designer_20"),
            (store_sub, ":view", ":object", "$g_presentation_obj_custom_battle_designer_19"), #Results in a value 0-4
            (try_begin),
                (eq, reg60, 4), #Leaving Config/Options Page
                (call_script, "script_cf_trade_ledger_custom_assess_duplicates"),
            (try_end),
            (assign, reg60, ":view"),
            (start_presentation, "prsnt_trade_ledger_basic"),
        (else_try), #Set Date Threshold for Removal
            (eq, ":object", "$g_presentation_obj_custom_battle_designer_17"),
            (assign, reg59, ":value"),
        (else_try), #Remove Entries - Date
            (store_add, ":overlay", "$g_presentation_obj_custom_battle_designer_17", 1),
            (eq, ":object", ":overlay"),
            (gt, reg59, 0),
            (call_script, "script_cf_trade_ledger_trim_entries", "trp_player", reg59, date_array),
            (display_message, "@{reg0} entries removed from ledger."),
        (else_try), #Set Item for Removal
            (eq, ":object", "$g_presentation_obj_custom_battle_designer_16"),
            (is_between, ":value", trade_goods_begin, trade_goods_end),
            (assign, reg58, ":value"),
            (str_store_item_name, s0, ":value"),
            (overlay_set_val, ":object", ":value"), #looks cleaner
            (val_add, ":object", 1),
            (overlay_set_text, ":object", s0),
        (else_try), #Remove Entries - Item
            (store_add, ":overlay", "$g_presentation_obj_custom_battle_designer_16", 2),
            (eq, ":object", ":overlay"),
            (is_between, reg58, trade_goods_begin, trade_goods_end),
            (call_script, "script_cf_trade_ledger_trim_entries", "trp_player", reg58, item_array),
            (display_message, "@{reg0} entries removed from ledger."),
        (else_try), #Set Town for Removal
            (eq, ":object", "$g_presentation_obj_custom_battle_designer_15"),
            (is_between, ":value", towns_begin, towns_end),
            (assign, reg57, ":value"),
            (str_store_party_name, s0, ":value"),
            (overlay_set_val, ":object", ":value"), #looks cleaner
            (val_add, ":object", 1),
            (overlay_set_text, ":object", s0),
        (else_try), #Remove Entries - Production Town
            (store_add, ":overlay", "$g_presentation_obj_custom_battle_designer_15", 2),
            (eq, ":object", ":overlay"), 
            (is_between, reg57, towns_begin, towns_end),
            (store_sub, ":overlay", ":object", "$g_presentation_obj_custom_battle_designer_15"),
            (call_script, "script_cf_trade_ledger_trim_entries", "trp_player", reg57, town_array),
            (display_message, "@{reg0} entries removed from ledger."),    
        (else_try), #Remove Entries - Demand Town
            (val_add, ":overlay", 1),
            (eq, ":object", ":overlay"), 
            (is_between, reg57, towns_begin, towns_end),
            (store_sub, ":overlay", ":object", "$g_presentation_obj_custom_battle_designer_15"),
            (call_script, "script_cf_trade_ledger_trim_entries", "trp_player", reg57, destination_array),
            (display_message, "@{reg0} entries removed from ledger."),    
        (else_try), #Set Profit Level for Removal
            (eq, ":object", "$g_presentation_obj_custom_battle_designer_14"),
            (assign, reg56, ":value"),
        (else_try), #Remove Entries - Proft Level
            (store_add, ":overlay", "$g_presentation_obj_custom_battle_designer_14", 1),
            (eq, ":object", ":overlay"),
            (gt, reg56, 0),
            (call_script, "script_cf_trade_ledger_trim_entries", "trp_player", reg56, profit_array),
            (display_message, "@{reg0} entries removed from ledger."),            
        (else_try), #Assess Custom Item        
            (troop_get_slot, ":slider_1", "trp_temp_array_c", 5),
            (is_between, ":object", ":slider_1", "$g_presentation_obj_custom_battle_designer_18"),
            (is_between, ":value", trade_goods_begin, trade_goods_end),
            (troop_get_slot, ":ledger", "trp_player", slot_troop_trade_ledger),
            (call_script, "script_array_get_size", ":ledger"),
            (val_add, reg0, 1),
            (try_for_range, ":i", custom_assess_begin, reg0),
                (troop_slot_eq, "trp_temp_array_c", ":i", ":object"),
                (assign, ":index", ":i"),
                (assign, reg0, 0), #break
            (try_end),
            (call_script, "script_cf_trade_ledger_custom_assess_item", ":value", ":index"),
            (str_store_item_name, s0, ":value"),
            (overlay_set_val, ":object", ":value"), #looks cleaner
            (val_add, ":object", 1),
            (overlay_set_text, ":object", s0),
        (try_end),
     ]),
    ]),
 

Hatonastick

I'm going to use this, thanks!

BTW, you might want to fix this little typo though: "Asses Prices".  There should be an extra 'S' on the end of "Asses". :wink:
 

akmatov

Recruit
M&BWBWF&S
Best answers
0
This seems very interesting.  But I have NO idea how to install it. :sad:(

Please advise.
 

Bismarck

Knight
Best answers
0
Thank you for this useful and interesting script. It will be included in the new NMC version.
 

SpizNastee

Recruit
Best answers
0
How would I go about incorporating this into Pendor? I'm playing right now but, after having used the ledger in Silverstag, don't think I can play without it!

I looked at the Modmerger readme but I'm not sure I understand exactly how I'd insert this code, or if that's even what I should be using to do so...