Scrolling dialog selections?

Started by Starlock, February 09, 2016, 06:18:52 PM

Previous topic - Next topic
Hey, I'm planning to implement a crafting system that involves talking to NPCs and they will show a selection of craftables and the regents required to make them. I figured it would be easier to make this as a dialog that displays craftables and checks if you have the regents when you select it. Is it possible to have more than 4 selection in a dialog that you can scroll through or would I have to create a menu for a crafting system to be possible

Dialogs are already menus in most games.

So would a crafting system be something viable just using the dialog box?

Would a new dialog box have to be coded or are zsdx or roth usable. Right now using a dialog box similar to the zsdx one I am only able to make 2 choice questions rather than a bunch of choices that you can scroll through.

Well it has to be a modified version of the one of another game since you want to add new things.

Forgot about this for a while, coming back to it now. I'm using Diarandor's current dialog box as a point of reference, but I kinda need a push in the right direction, I'm not too sure where to begin with this atm  ???

March 17, 2016, 09:01:56 AM #7 Last Edit: March 17, 2016, 09:24:30 AM by Diarandor
My dialog box is a modified version of Christopho's one, so all credit goes for him. It allows to use certain syntax to write color words, and the last version also adds commands to draw animated sprites.

Edit: @Starlock, you should start by studying the code, as I did, until you fully understand it. I remember it was not easy since the script is long, so be patient.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

March 20, 2016, 08:09:28 PM #8 Last Edit: March 20, 2016, 08:18:07 PM by Starlock
I've started to work on it by making a hybrid between the zelda roth and zsdx dialog boxes. I can get the box to appear, but it's giving me an error about the text_surface on this chunk of code...
Code ( lua) Select
    if not special then
    text_surface:set_text(text_surface:get_text() .. current_char)

    -- If this is a multibyte character, also add the next byte.
    local byte = current_char:byte()
    if byte >= 192 and byte < 224 then
      -- The first byte is 110xxxxx: the character is stored with
      -- two bytes (utf-8).
      current_char = line:sub(self.char_index, self.char_index)
      self.char_index = self.char_index + 1
      text_surface:set_text(text_surface:get_text() .. current_char)

I'm a bit confused as to why it doesn't work when text_surface is used earlier in the code with no problem

EDIT: I would've posted the full code, but it was over the limit  :-\

What is the exact error ? Attempt to call a nil value ?

March 20, 2016, 10:18:11 PM #10 Last Edit: March 21, 2016, 04:13:34 AM by Starlock

Error: In timer callback: [string "scripts/dialog_box.lua"]:492: attempt to index local 'text_surface' (a nil value)

Sorry I forgot to write that in originally

EDIT: github link to full code

I was able to get the dialog box to function properly. It has Diarandor's animations and colors as well as the ability the make more than 2 answers to questions from the Return of the Hylian

I'm continuing to make a few changes to the dialog box code to make a crafting system smoother. I tried to make it so you can close the dialog box at any time when it is being used for crafting.

Code ( lua) Select
function game:on_key_pressed(key)
  if key == "escape" and == "_crafting" then
game.dialog_box = nil

I'm getting the error Error: In on_key_pressed: [string "scripts/dialog_box.lua"]:149: attempt to inde
x field 'dialog' (a nil value)

I was trying to test the code using a dialog called "give_crafting" so I'm unsure why dialog would be a nil value

You have to learn how to debug by yourself.

The error speaks by itself: your variable "self.dialog" is nil, so you cannot index it with something like "" (which makes no sense). You can only index lists, and a nil variable is not a list, obviously.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."