Dynamically generated choices
So uhh, I'm trying to generate a dynamic choice menu. Surprisingly, the script below somewhat works
The only problem is that choice menu is never shown, and last choice is always picked up somehow (number 2 in this case). I've attached this to talk script. At first I've attached it to hit(), and thought pressing CTRL is what messes things up. Apparently not.
Has anyone tried to do this, and can it be done?
int &crap = 0;
choice_start();
set_y 200
set_title_color 15
title_start();
Dynamic choice
title_end();
loop:
if(&crap < 3)
{
"Option &crap"
&crap += 1;
goto loop;
}
choice_end();
say("I've picked &result", 1);
The only problem is that choice menu is never shown, and last choice is always picked up somehow (number 2 in this case). I've attached this to talk script. At first I've attached it to hit(), and thought pressing CTRL is what messes things up. Apparently not.
Has anyone tried to do this, and can it be done?
What exactly you mean by dynamic?
If you just want that some choices are not shown you can just add conditionals to the choices, but you presumably knew that.
If you want to make a large number of "option N" choices then you do have to manually unroll your choice list AFAIK
If you want to let player pick an arbitrary number either do a looping choice menu with "current value: &crap" title, with options "[increase/decrease] by [1/10/...]"; or do whatever Ultimate Cheat does with its variable editor.
If you just want that some choices are not shown you can just add conditionals to the choices, but you presumably knew that.
If you want to make a large number of "option N" choices then you do have to manually unroll your choice list AFAIK
If you want to let player pick an arbitrary number either do a looping choice menu with "current value: &crap" title, with options "[increase/decrease] by [1/10/...]"; or do whatever Ultimate Cheat does with its variable editor.
Dynamic as it can generate a number of choices, based on a current value of a variable, as demonstrated in the snippet above. I will check the file to see what was done there, cause I am facing issues.
You should be able to do something like this
int &crap = 3
choice_start()
set_y 200
set_title_color 15
title_start()
Dynamic choice
title_end()
(&crap >= 1) "Choice 1"
(&crap >= 2) "Choice 2"
(&crap >= 3) "Choice 3"
(&crap >= 4) "Choice 4"
(&crap >= 5) "Choice 5"
choice_end()
say("I've picked &result", 1)
That's not (fully) dynamic. Choices are hardcoded, and I don't know what values &crap might have. It might be 20 or more, at which point such approach becomes unmanagable.
So, generate choices in a "while/for" loop from 0 to N
So, generate choices in a "while/for" loop from 0 to N
I wonder if there's a low-ish limit for how many choices you can have, in which case having spaceholders for each wouldn't really decrease the dynamism.
The choice menu gets separated into pages after about 13 lines IIRC, which while not a hard limit is kind of awkward.
The choice menu gets separated into pages after about 13 lines IIRC, which while not a hard limit is kind of awkward.
With all due respect scratcher, I was looking for a specific solution, not a shift to a problem I totally forgot about
Dang... I'll might have to limit the number of choices and do stuff manually up to 10, while "sacrificing" what I originally had in mind. Luckily, that's something I can live with and may even be beneficial overall.
I'll keep the topic open for suggestions to the original problem, just in case someone knows if this is doable, or where the problem of "autoselect" is.
Dang... I'll might have to limit the number of choices and do stuff manually up to 10, while "sacrificing" what I originally had in mind. Luckily, that's something I can live with and may even be beneficial overall.
I'll keep the topic open for suggestions to the original problem, just in case someone knows if this is doable, or where the problem of "autoselect" is.
You're only providing choices to the player when &crap is < 3 but &crap becomes 3 very fast.
What happens if you move 'option &crap' up so it's not within the if check?
What happens if you move 'option &crap' up so it's not within the if check?
It's an attempt to programmatically add options to a choice menu which isn't possible in DinkC due to the line parser changing completely once it hits menu options (edit: my reply looks nonsensical since lep changed his post). It's fairly straightforward in DinkLua however:
function talk()
-- Store references
local refs = {"beans", "pasta", "salad", "rice"}
local mymenu = dink.create_choice_menu()
-- Add random foods to it
for i = 1, 20 do
local randint = math.random(1, #refs)
mymenu:add_choice(refs[randint])
end
local mychoice = mymenu
how()
player
ay("I chose option " .. global.result)
end
Yeah I edited my post because as I was looking back through my response I realized I had understood it incorrectly.
@LeprochaUn - moving "option &crap" out of the if() behaves the same way. Menu is never rendered and last choice is selected somehow.
@yeolde - thanks. I'll have to check how to proceed from here.
@yeolde - thanks. I'll have to check how to proceed from here.
Depending on how badly you want it, it would be possible to implement Seseler's approach above combined with my approach to writing DinkC, i.e. autogenerating it with a more capable programming language, in this case to account for all possible permutations. It's also possible to chain (AND) conditionals, seemingly as many times as you like to determine their addition to the option list.
@yeoldetoast I badly want a better language than DinkC in certain scenarios, but I could use others to generate this particular script... It's just... crazy... Nevermind. I'm continuing to develop with what I have. Combined with what scratcher said, it makes sense to include some limitations.














