@@ -4,6 +4,7 @@ signal bb_data(text: String)
44signal location_name (text : String )
55signal status_text (text : String )
66signal mobs_text (text : String )
7+ signal items_text (text : String )
78signal exits_text (text : String )
89signal container_request (data : Array )
910signal auto_commands_submitted (cmd : String )
@@ -14,8 +15,8 @@ const _RIGHT_CHARS := {"╗": true, "║": true, "╝": true}
1415var _in_map := false
1516var _cur_map : Array = []
1617var _backpack_prohibit = false
17- var _prevent_location_name = false
18- var _prevent_location_desc = false
18+ var _prevent_location_name : int = 0
19+ var _prevent_location_desc : int = 0
1920
2021# remember first line + left index to compute prefix
2122var _first_line_raw := ""
@@ -241,7 +242,10 @@ func _visible_prefix(bb_chunk: String, n: int = 30) -> String:
241242
242243func _process_one_bb_line (bb_chunk : String ) -> void :
243244 var descs : Array = []
244-
245+ var sys_msg : bool = false
246+ if contains_term (bb_chunk , ".:" ) or contains_term (bb_chunk , "───────────" ):
247+ sys_msg = true
248+
245249 for raw_line in bb_chunk .split ("\n " , false ):
246250 var line := raw_line .rstrip ("\r " )
247251 var pair := _line_map_slice_indices (line )
@@ -302,31 +306,36 @@ func _process_one_bb_line(bb_chunk: String) -> void:
302306
303307 # two line message
304308 if descs_size == 2 :
305- if _visible_prefix (descs [0 ], 5 ) == "Exits" :
309+ if contains_term (descs [0 ], "Exits" ) :
306310 # exits
307311 emit_signal ("exits_text" , bb_chunk )
308312 return
309- elif _visible_prefix (descs [0 ], 9 ) == "Also here" :
313+ elif contains_term (descs [0 ], "Also here" ):
314+ # mobs
310315 emit_signal ("mobs_text" , descs [0 ])
316+ elif contains_term (descs [0 ], "On the Ground" ):
317+ # items
318+ print (descs [0 ])
319+ emit_signal ("items_text" , descs [0 ])
311320 else :
312321 $ TextDisplay .append_text (bb_chunk )
313322 # auto refresh the mobs
314323 var l0_prefix_100 = _visible_prefix (descs [0 ], 100 )
315324 if contains_term (l0_prefix_100 , "enters" ):
316- _prevent_location_name = true
317- _prevent_location_desc = true
325+ _prevent_location_name += 1
326+ _prevent_location_desc += 1
318327 emit_signal ("auto_commands_submitted" , "look" )
319328 if contains_term (l0_prefix_100 , "leaves" ):
320- _prevent_location_name = true
321- _prevent_location_desc = true
329+ _prevent_location_name += 1
330+ _prevent_location_desc += 1
322331 emit_signal ("auto_commands_submitted" , "look" )
323332 if contains_term (l0_prefix_100 , "died" ):
324- _prevent_location_name = true
325- _prevent_location_desc = true
333+ _prevent_location_name += 1
334+ _prevent_location_desc += 1
326335 emit_signal ("auto_commands_submitted" , "look" )
327336 if contains_term (l0_prefix_100 , "prepares" ):
328- _prevent_location_name = true
329- _prevent_location_desc = true
337+ _prevent_location_name += 1
338+ _prevent_location_desc += 1
330339 emit_signal ("auto_commands_submitted" , "look" )
331340 return
332341
@@ -341,7 +350,6 @@ func _process_one_bb_line(bb_chunk: String) -> void:
341350 # --- Step 1: Trim each line and remove empties ---
342351 for i in range (descs_size ):
343352 descs [i ] = descs [i ].strip_edges ()
344- # print("Desc appended ", i, " : ", descs[i])
345353
346354 # --- Step 2: Join with newlines instead of spaces ---
347355 text = " " .join (descs )
@@ -355,58 +363,46 @@ func _process_one_bb_line(bb_chunk: String) -> void:
355363 var l0_prefix_100 = _visible_prefix (descs [0 ], 100 )
356364 var l1_prefix_100 = _visible_prefix (descs [1 ], 100 )
357365 var l2_prefix_100 = _visible_prefix (descs [2 ], 100 )
358- # print("------------------------------")
359- # print("L0 Prefix: ", l0_prefix_100)
360- # print("L1 Prefix: ", l1_prefix_100)
361- # print("L2 Prefix: ", l2_prefix_100)
362- # print("------------------------------")
363-
364- if _visible_prefix (l1_prefix_100 , 4 ) == ".: (" :
366+
367+ if contains_term (l1_prefix_100 , ".: (" ):
365368 # location name
366369 emit_signal ("location_name" , bb_chunk )
367370 emit_signal ("mobs_text" , "" )
368- if not _prevent_location_name :
371+ emit_signal ("items_text" , "" )
372+ if _prevent_location_name < 1 :
369373 $ TextDisplay .append_text (bb_chunk )
370374 else :
371- _prevent_location_name = false
375+ _prevent_location_name -= 1
372376 return
373377
374- elif l2_prefix_100 == "┌─ .:Info ──────────────────────┐ ┌─ .: Attributes ───────────────────────────┐" :
378+ elif contains_term ( l2_prefix_100 , ".: Attributes" ) :
375379 # status table
376380 emit_signal ("container_request" , bb_chunk , "status" )
377381 _backpack_prohibit = true
378382
379- elif l0_prefix_100 == "┌─ .:Equipment ──────────────────────────────────────────────────────────────┐" :
383+ elif contains_term ( l0_prefix_100 , " .:Equipment" ) :
380384 # backpack
381385 if not _backpack_prohibit :
382386 emit_signal ("container_request" , bb_chunk , "equipment" )
383387 else :
384388 _backpack_prohibit = false
385389
386- elif l1_prefix_100 == "┌─ .:Skills ─────────────────────────────────────────────────────────────────┐" :
390+ elif contains_term ( l1_prefix_100 , " .:Skills" ) :
387391 # skills table
388392 emit_signal ("container_request" , bb_chunk , "skills" )
389393
390- elif l0_prefix_100 == ".: Spells" :
394+ elif contains_term ( l0_prefix_100 , ".: Spells" ) :
391395 # skills table
392396 emit_signal ("container_request" , bb_chunk , "spells" )
393-
394- elif l0_prefix_100 == "┌─────────────────────────────────────────────────────────────────────────┐" :
395- # sunrise and sunset
396- $ TextDisplay .append_text (bb_chunk )
397397
398- elif l2_prefix_100 == "│ Name │ Level │ Alignment │ Profession │ Online │ Role │" :
399- # player table
400- $ TextDisplay .append_text (bb_chunk )
401-
402- elif l1_prefix_100 == ".: Pets by Rodric" :
403- $ TextDisplay .append_text (bb_chunk )
404-
405398 else :
406- if not _prevent_location_desc :
399+ if sys_msg :
400+ $ TextDisplay .append_text (bb_chunk )
401+ return
402+ if _prevent_location_desc < 1 :
407403 $ TextDisplay .append_text (text + "\n " )
408404 else :
409- _prevent_location_desc = false
405+ _prevent_location_desc -= 1
410406 return
411407
412408# ---------------- helpers ----------------
0 commit comments