@@ -6,13 +6,16 @@ signal status_text(text: String)
66signal mobs_text (text : String )
77signal exits_text (text : String )
88signal container_request (data : Array )
9+ signal auto_commands_submitted (cmd : String )
910
1011const _LEFT_CHARS := {"╔" : true , "║" : true , "╚" : true }
1112const _RIGHT_CHARS := {"╗" : true , "║" : true , "╝" : true }
1213
1314var _in_map := false
1415var _cur_map : Array = []
1516var _backpack_prohibit = false
17+ var _prevent_location_name = false
18+ var _prevent_location_desc = false
1619
1720# remember first line + left index to compute prefix
1821var _first_line_raw := ""
@@ -279,30 +282,26 @@ func _process_one_bb_line(bb_chunk: String) -> void:
279282
280283 # After processing all lines in the chunk, append descriptions once
281284 var descs_size = descs .size ()
282- # print("Desc size = ", descs_size)
283- # print("Start to process desc.....")
284-
285285 var text = ""
286286
287287 # one line message
288288 if descs_size == 1 :
289- # print("------------------------------")
290- # print("One line desc: ", descs)
291- # print("------------------------------")
292289 if _visible_prefix (descs [0 ], 1 ) == "(" :
293290 # status text
294291 emit_signal ("status_text" , str (descs [0 ]))
295292 return
296293 elif _visible_prefix (descs [0 ], 100 ) in ["TEXTMASK:false" , "TEXTMASK:true" ]:
297294 return
298295 else :
299- $ TextDisplay .append_text (bb_chunk )
296+ # classified as short msg
297+ var short_msg = _visible_prefix (descs [0 ], 30 )
298+ if len (short_msg ) > 3 :
299+ if short_msg not in ["look" , "status" , "equipment" , "skills" , "spells" ]:
300+ $ TextDisplay .append_text (bb_chunk )
301+ return
300302
301303 # two line message
302304 if descs_size == 2 :
303- # print("------------------------------")
304- # print("Two line desc: ", descs)
305- # print("------------------------------")
306305 if _visible_prefix (descs [0 ], 5 ) == "Exits" :
307306 # exits
308307 emit_signal ("exits_text" , bb_chunk )
@@ -311,6 +310,24 @@ func _process_one_bb_line(bb_chunk: String) -> void:
311310 emit_signal ("mobs_text" , descs [0 ])
312311 else :
313312 $ TextDisplay .append_text (bb_chunk )
313+ # auto refresh the mobs
314+ var l0_prefix_100 = _visible_prefix (descs [0 ], 100 )
315+ if contains_term (l0_prefix_100 , "enters" ):
316+ _prevent_location_name = true
317+ _prevent_location_desc = true
318+ emit_signal ("auto_commands_submitted" , "look" )
319+ if contains_term (l0_prefix_100 , "leaves" ):
320+ _prevent_location_name = true
321+ _prevent_location_desc = true
322+ emit_signal ("auto_commands_submitted" , "look" )
323+ if contains_term (l0_prefix_100 , "died" ):
324+ _prevent_location_name = true
325+ _prevent_location_desc = true
326+ emit_signal ("auto_commands_submitted" , "look" )
327+ if contains_term (l0_prefix_100 , "prepares" ):
328+ _prevent_location_name = true
329+ _prevent_location_desc = true
330+ emit_signal ("auto_commands_submitted" , "look" )
314331 return
315332
316333 # big message
@@ -348,7 +365,11 @@ func _process_one_bb_line(bb_chunk: String) -> void:
348365 # location name
349366 emit_signal ("location_name" , bb_chunk )
350367 emit_signal ("mobs_text" , "" )
351- $ TextDisplay .append_text (bb_chunk )
368+ if not _prevent_location_name :
369+ $ TextDisplay .append_text (bb_chunk )
370+ else :
371+ _prevent_location_name = false
372+ return
352373
353374 elif l2_prefix_100 == "┌─ .:Info ──────────────────────┐ ┌─ .:Attributes ───────────────────────────┐" :
354375 # status table
@@ -382,8 +403,12 @@ func _process_one_bb_line(bb_chunk: String) -> void:
382403 $ TextDisplay .append_text (bb_chunk )
383404
384405 else :
385- $ TextDisplay .append_text (text + "\n " )
386-
406+ if not _prevent_location_desc :
407+ $ TextDisplay .append_text (text + "\n " )
408+ else :
409+ _prevent_location_desc = false
410+ return
411+
387412# ---------------- helpers ----------------
388413func _line_map_slice_indices (bb_line : String ) -> Array :
389414 var left := - 1
@@ -474,3 +499,6 @@ func _closing_for_stack(stack: Array) -> String:
474499 if String (stack [i ]).begins_with ("[color" ):
475500 s += "[/color]"
476501 return s
502+
503+ func contains_term (message : String , term : String ) -> bool :
504+ return message .find (term ) != - 1
0 commit comments