Code: Select all
function gtkDidLoad()
GTK.Core.GUI:addImage({ name="book-of-monsters", path="mod_assets/ext/grimtk/samples/book-of-monsters.tga", size={545, 400} });
end
questAccepted = false;
function biteParty()
local champion = party.party:getChampion(1);
champion:damage(10, "physical");
playSound("consume_food");
champion:playDamageSound();
end
function enableBook()
local e = findEntity("book_of_monsters");
if ( e ) then
e.item:enable();
e.item:setUiName("Book of Monsters!");
isDone = true;
end
end
function showDemoDialogue(sender)
if ( questAccepted == true ) then
return;
end
local dialogue = {
lockParty = true,
pages = {
{
id = "first",
mainImage = "book-of-monsters",
speakerMessage = "A small book lies still on an altar behind the bars...",
playSound = "polymorph_bear",
responses = {
{ text = "<Poke It>", nextPage = "poke", onSelect = self.go.id..".script.biteParty" },
{ text = "<Stare At It>", nextPage = "stare" },
{ text = "<Walk Away>" },
}
},
{
id = "poke",
mainImage = "book-of-monsters",
mainMessage = "*Gnash* *Gnash* *Gnash*",
responses = {
{ text = "Okay...", nextPage = "first" },
}
},
{
id = "stare",
mainImage = "book-of-monsters",
mainMessage = "WHAD YA WANT?",
questAccepted = true,
responses = {
{ text = "To read you!", nextPage = "okay" },
{ text = "<Walk Away>" }
}
},
{
id = "okay",
mainImage = "book-of-monsters",
mainMessage = "OKAY THEN!",
responses = {
{ text = "<Done>", onSelect = self.go.id..".script.enableBook" },
}
}
}
}
GTKGui.Dialogue.startDialogue(dialogue);
end
function hideDemoDialogue()
GTKGui.Dialogue.hideDialogue();
end
No. You must access the variable through the script. Variables that are declared in a script —but outside of a function, are accessible from within that script by those functions, and saved with it in the saved-game. The variables are also accessible from outside of the script, by other scripts.supercell1970 wrote: ↑Wed Mar 13, 2024 2:00 am When I change a variable in a script, how do I keep it the same throughout the dungeon level? In other words, is it a global variable?
Code: Select all
magic_itemOwnerName = "Ralph"
Code: Select all
magic_itemOwnerName = "Ralph"
function setItemOwnerName(name)
magic_itemOwnerName=name
end
function getItemOwnerName()
return magic_itemOwnerName
end
--_________________________________________________________________
--Example of result: (Not needed in your own implementation.)
print("magic_itemOwnerName is currently:", getItemOwnerName())
setItemOwnerName("Robert")
function output()playSound("secret")party:spawn('blob')print("magic_itemOwnerName has been changed to:",getItemOwnerName())end
delayedCall(self.go.id,2,"output")
--_________________________________________________________________