[Solved] Custom global function?
Posted: Sun Sep 23, 2012 4:40 pm
Is it possible to define your own global function which you can call through script entities? This way I can avoid copy-pasting the same function into every level.
Official Legend of Grimrock Forums
http://grimrock.net/forum/
Code: Select all
pnjName = "Victor"
dialEnd = "end of dialog"
dialog = {"Oh, so you come to see Victor! Afraid of Scotia's new toy ? Ha ha!", "Why afraid? Look at Victor. Myself could use a shapechanger! Ha ha ha!", "You show Victor what you want to buy. Maybe you show Victor what you sell, OK ?", dialEnd}
secondDialog = {"You again come to see Victor ?", dialEnd}
byeDialog = {"You again come visit, no?", dialEnd}
fromShop = false
function victorSay()
fromShop =globalDialogs.pnjDialog(dialog, fromShop, pnjName)
if dialog ~= secondDialog then
dialog = secondDialog
end
end
function victorBye()
globalDialogs.pnjBye(byeDialog, fromShop, pnjName)
end
Code: Select all
function pnjTell(dialog, pnjName)
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(dialog, fromShop, pnjName)
if not fromShop then
pnjTell(dialog, pnjName)
fromShop = true
end
return fromShop
end
]function pnjBye(dialog, fromShop, pnjName)
if fromShop then
pnjTell(byeDialog, pnjName)
fromShop = false
end
return fromShop
end