how to count the options in a dialog

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
Rickster
Posts: 291
Joined: Sun Oct 24, 2010 4:23 pm

how to count the options in a dialog

#1 Post by Rickster »

Hi,

is there a possibility to count the given options in a npc dialog?

there is a npc which, depending on some conditions, gives me other options to chose from and i want to react, based on the given options i can choose from.

e.g. what i want to know from a npc dialog is:

Code: Select all

What do you want to do?
I want this.
I want that.
I do not want anything.
how many options are there to chose from.

Thanx
Ric
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: how to count the options in a dialog

#2 Post by lisa »

Judging by Rock's ChoiceOptionByName() I doubt there is a count for options.

Can you just use the option by name??

ChoiceOptionByName("first text you want")
ChoiceOptionByName("second text you want")
ChoiceOptionByName("third text you want")


That will try first, second and third regardless of if any actually work.

In order to actually respond with inteligence then you will probably have to do something like this.

Wrote this in a bit of a hurry but hopefully you get the idea

Code: Select all

	optionnames = {}
    local counter = 1
	local option
    repeat
		option = RoMScript("GetSpeakOption("..counter..")")
		if option then
			table.insert(optionnames, option)
        end
        counter = counter + 1
    until not option
	
	for k,v in ipairs(optionnames) do
		if FindNormalisedString(v,"first choice") then
			RoMScript("ChoiceOption("..k..");"); yrest(1000);
			return
		end
		if FindNormalisedString(v,"second choice") then
			RoMScript("ChoiceOption("..k..");"); yrest(1000);
			return
		end	
		if FindNormalisedString(v,"third choice") then
			RoMScript("ChoiceOption("..k..");"); yrest(1000);
		end		
	end
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
BillDoorNZ
Posts: 446
Joined: Wed Aug 03, 2011 7:37 pm

Re: how to count the options in a dialog

#3 Post by BillDoorNZ »

you could try:

Code: Select all

GetNumSpeakOption();
havent' tried it myself, but thats what speakframe.lua uses
Rickster
Posts: 291
Joined: Sun Oct 24, 2010 4:23 pm

Re: how to count the options in a dialog

#4 Post by Rickster »

Code: Select all

GetNumSpeakOption();

this does not work. mm shows this error:

Code: Select all

7:45am - [string "..."]:38: attempt to call global 'GetNumSpeakOption' (a nil value)
and i can not find something like this function in the wiki or in the forum

----------------------
[added] I used it the wrong way:

Code: Select all

counter = GetNumSpeakOption();
Look at lisas next post how to use it!
----------------------

i used part of lisas suggestion which i can use in a more simple way, as i only need to know if there are only two ore more options available

Code: Select all

local counter = 0;
local option;
repeat
	option = RoMScript("GetSpeakOption("..counter..")"); yrest(slow_time);
	counter = counter + 1;
until (not option or counter-1 > 2); -- stop if more then two options

if counter-1 > 2 then
	-- more than 2 options available
else
	-- 2 or less options available
end;
Thanx
Ric
Last edited by Rickster on Tue Jul 17, 2012 1:52 am, edited 1 time in total.
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: how to count the options in a dialog

#5 Post by lisa »

Code: Select all

local counter = RoMScript("GetNumSpeakOption()")
if counter > 2 then
   -- more than 2 options available
else
   -- 2 or less options available
end
It doesn't count leave conversation as an option.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Rickster
Posts: 291
Joined: Sun Oct 24, 2010 4:23 pm

Re: how to count the options in a dialog

#6 Post by Rickster »

that works great for me now :)

thank you all!

my mistake was to use GetNumSpeakOption() as a regular function not as a RoMScript.

btw ... where can I look for these RoM Functions?
Is there a wiki, like the wiki for this bot?

Ric
Post Reply