BUG: Lua FUnction AddConversationOption

Old bugs stored here for reference.
Locked
User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

BUG: Lua FUnction AddConversationOption

Post by Ememjr » Tue Mar 26, 2019 1:23 pm

LUA Functions: AddConversationOption()
the following function according to the wiki, if param3 (optional) is left out , and then that option is seletion on the dialog screen, that the dialog box will close
that in fact is not happening, if you select the "close" option then the dialog box hangs and you have to close with x

LUA Functions: AddConversationOption()
Adds an option for a player to select in a dialog with an NPC.
Syntax
AddConversationOption(param1, param2, [param3])


Parameters
Required - param1 (conversation), param2 (string)
param1 must be a conversation
param2 is the option to add to the given conversation
Optional - param3 (string)
param3 is the custom function to call if this option is selected

Usage

Code: Select all

 function hailed(NPC, Spawn)
	-- have the NPC face the player
        FaceTarget(NPC, Spawn)
	-- create the conversation
	conversation = CreateConversation()
	-- set the 3 player options
	AddConversationOption(conversation, "Good", "Choice1")
	AddConversationOption(conversation, "Not so good.", "Choice2")
	AddConversationOption(conversation, "I don't have time for this.")
	-- set the npc dialog and start the conversation
	StartConversation(conversation, NPC, Spawn, "Good to see you " .. GetName(Spawn) .. ", how are you today?")
 end
This script makes a conversation with 3 choices for the player.


Notes
If param3 is left out then when the player selects that option the dialog will close.

User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

Re: BUG: Lua FUnction AddConversationOption

Post by Ememjr » Tue Mar 26, 2019 1:25 pm

I have identified the issue

in the following code

Code: Select all

case OP_DialogSelectMsg:{
			LogWrite(OPCODE__DEBUG, 1, "Opcode", "Opcode 0x%X (%i): OP_DialogSelectMsg", opcode, opcode);
			PacketStruct* packet = configReader.getStruct("WS_DialogSelect", GetVersion());
			if(packet){
				packet->LoadPacketData(app->pBuffer, app->size);
				int32 conversation_id = packet->getType_int32_ByName("conversation_id");
				int32 response_index = packet->getType_int32_ByName("response");
				if(GetCurrentZone()){
					Spawn* spawn = conversation_spawns[conversation_id];
					Item* item = conversation_items[conversation_id];
					int8 test1 = conversation_map.count(conversation_id);
					int8 test2 = conversation_map[conversation_id].count(response_index);
					if (conversation_map.count(conversation_id) > 0 && conversation_map[conversation_id].count(response_index) > 0) {
						if (spawn)
							GetCurrentZone()->CallSpawnScript(spawn, SPAWN_SCRIPT_CONVERSATION, player, conversation_map[conversation_id][response_index].c_str());
						else if (item && lua_interface && item->GetItemScript())
							lua_interface->RunItemScript(item->GetItemScript(), conversation_map[conversation_id][response_index].c_str(), item, player);
					}
					else
						CloseDialog(conversation_id);
				}
				safe_delete(packet);
			}
			break;
i added

Code: Select all

else
						CloseDialog(conversation_id);
i will be tsting this change and commmit later today

User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

Re: BUG: Lua FUnction AddConversationOption

Post by Ememjr » Wed Apr 24, 2019 6:04 am

this bug fix was commited in SVN in Revision 2817

Locked

Who is online

Users browsing this forum: No registered users and 0 guests