Skip to content

Shopkeeper dialog fails to transition to shop #4

@DmitriyusGit

Description

@DmitriyusGit

Version: Current

How to reproduce:
Pull main branch and interact with shopkeeper, select "yes" dialog, transition fails to change shop menu, game crashes with error:

E 0:00:12:384   DialogSystemNode.show_dialog: Out of bounds get index '0' (on base: 'Array[DialogItem]')
  <GDScript Source> dialog_system.gd:81 @ DialogSystemNode.show_dialog()
  <Stack Trace> dialog_system.gd:81 @ show_dialog()
                dialog_system.gd:182 @ _dialog_choice_selected()

Handle with solution below:

res://GUI/dialog_system/scripts/dialog_system.gd

Original:

## Show the dialog UI
func show_dialog( _items : Array[ DialogItem ] ) -> void:
	is_active = true
	if _items[0] is DialogCutscene:
		dialog_ui.visible = false
	else:
		dialog_ui.visible = true
	dialog_ui.process_mode = Node.PROCESS_MODE_ALWAYS
	dialog_items = _items
	dialog_item_index = 0
	get_tree().paused = true
	await get_tree().process_frame
	if dialog_items.size() == 0:
		hide_dialog()
	else:
		start_dialog()
	pass

Fix:

## Show the dialog UI
func show_dialog( _items : Array[ DialogItem ] ) -> void:
	is_active = true
	if _items.is_empty():
		hide_dialog()
		return
	if _items[0] is DialogCutscene:
		dialog_ui.visible = false
	else:
		dialog_ui.visible = true
	dialog_ui.process_mode = Node.PROCESS_MODE_ALWAYS
	dialog_items = _items
	dialog_item_index = 0
	get_tree().paused = true
	await get_tree().process_frame
	if dialog_items.size() == 0:
		hide_dialog()
	else:
		start_dialog()
	pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions