Need some help for dialogs, please [fixed]

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
Ethmo_Lux
Posts: 13
Joined: Thu Oct 11, 2012 6:35 pm
Location: Brussels (Belgium)

Need some help for dialogs, please [fixed]

Post by Ethmo_Lux »

As I told in another topic

I'm stuck with some dialog's display. Anyone can help me ?

Thanks. :D
Ethmo_Lux wrote: I was working on dialog, and some are very long. But it's easier form me to send them in one string. How can I split it without /n (cause it's buggy) ?

Here the code, I don't think it's optimized, still working on it. ;)

Code: Select all

pnjName = "Victor"
dialog = "Oh, so you come to see Victor! Afraid of Scotia's new toy ? Ha ha!\nWhy afraid? Look at Victor. Myself could use a shapechanger! Ha ha ha!\nYou show Victor what you want to buy. Maybe you show Victor what you sell, OK ?"
secondDialog = "You again come to see Victor ?"
byeDialog = "You again come visit, no?"
fromShop = false

function pnjTell(dialog)
	hudPrint(pnjName.." : "..dialog)
end


function pnjDialog()
	if not fromShop then
		pnjTell(dialog)
		fromShop = true
	end
	dialog = secondDialog	
end

function pnjBye()
	if fromShop then
		pnjTell(byeDialog)
		fromShop = false
	end
end
Image

A trigger the door and pnjBye()
B trigger pnjDialog()
Last edited by Ethmo_Lux on Sat Oct 13, 2012 12:06 pm, edited 1 time in total.
User avatar
Crisim
Posts: 16
Joined: Wed Aug 29, 2012 2:28 pm

Re: Need some help for dialogs, please

Post by Crisim »

you can wrap the text with double square brackets

Code: Select all

var verylongtext = [[
this is my story
...
...
...
and this is the end
]]
remember that with hudprint you can show a max of 4 rows
User avatar
Ethmo_Lux
Posts: 13
Joined: Thu Oct 11, 2012 6:35 pm
Location: Brussels (Belgium)

Re: Need some help for dialogs, please

Post by Ethmo_Lux »

Ok. Thank you very much. I'll try that. :D
User avatar
Ethmo_Lux
Posts: 13
Joined: Thu Oct 11, 2012 6:35 pm
Location: Brussels (Belgium)

Re: Need some help for dialogs, please

Post by Ethmo_Lux »

Hmmm... :/ Still not that.

I got some issues like text printed on previous texts and out of screen.

Image

Image

A guess there's something with the text's alignment.
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Need some help for dialogs, please

Post by petri »

hudPrint doesn't support linebreaks. You have to manually split the lines and call hudPrint for each line. Hope this helps!
User avatar
Ethmo_Lux
Posts: 13
Joined: Thu Oct 11, 2012 6:35 pm
Location: Brussels (Belgium)

Re: Need some help for dialogs, please

Post by Ethmo_Lux »

petri wrote:hudPrint doesn't support linebreaks. You have to manually split the lines and call hudPrint for each line. Hope this helps!
Ok. I tried with string manipulation before the squares brackets but it crashed... I don't know if it was because of the loop or the string manipulations itself.

Can I use a for to look over a string like a table, and how ?

Thanks. :)

EDIT : That was kind of simple in fact. :roll:

Code: Select all

pnjName = "Nathaniel"
dialEnd = "end of dialog"
dialog = { "Shh! Did you hear something? If Scotia does attack","they say we won't hear a thing! Quickly now, point out what you need.",dialEnd }
secondDialog = {"Did you forget something ?", dialEnd }
byeDialog = { "Farewell then.", dialEnd }
fromShop = false

function pnjTell(dialog)
	local dialNumber = 1
	hudPrint("")
	if dialog[dialNumber] ~= dialEnd then
		hudPrint(pnjName.." : "..dialog[dialNumber])
		dialNumber = dialNumber + 1
		
		while dialog[dialNumber] ~= dialEnd do
			hudPrint(dialog[dialNumber])
			dialNumber = dialNumber + 1
		end	
	end
end


function pnjDialog()
	if not fromShop then
		pnjTell(dialog)
		fromShop = true
	end
	dialog = secondDialog
		
end

function pnjBye()
	if fromShop then
		pnjTell(byeDialog)
		fromShop = false
	end
end
Post Reply