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?
Sure, I don't see why not :)
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 ???
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.
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...
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)
end
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 ?
Yes
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 https://github.com/Star-Lock/LongSteel/blob/master/dialog_box
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
https://github.com/Star-Lock/LongSteel/blob/master/dialog_box
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.
function game:on_key_pressed(key)
if key == "escape" and
self.dialog.id == "_crafting" then
sol.menu.stop(dialog_box)
end
game.dialog_box = nil
end
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 "self.dialog.id" (which makes no sense). You can only index lists, and a nil variable is not a list, obviously.