Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

PowerQuest

A Nifty 2D Adventure Toolkit for Unity · By Powerhoof

Override OnInventoryClick and Dialog Start/End calls?

A topic by JustinMucus created Oct 07, 2020 Views: 219 Replies: 2
Viewing posts 1 to 3

So, while working on my old-fashioned adventure game with clickable verb buttons, I can get everything to work fine if I edit the PowerQuest.cs script (specifically for inventory interactions where the OnInventoryClick function only reads left or right clicks and assigns either the Use or Look at actions), but of course I'd prefer not to edit that script. Is there any other way to override that specific function? 

I'm fairly certain there is not a way to add more verbs yet, which I can pretty much deal with fine by splitting the Use action into different verbs like Talk To, Pick Up, Give, etc.

Additionally, and unrelated, I'd like to prevent the dialog tree gui from turning off after a dialog choice has been made, again it appears as if that can only be changed in the OnDialogOptionClick function in the PowerQuest.cs script. I could get a workaround going if there were OnDialogStart and OnDialogEnd calls. Do those exist in any capacity?

(1 edit)

Hi Justin,

For inventory verbs- Oh man, my code for inventory gui stuff is still such a hack, just haven't got around to fixing it, something I've had on my list for forever! I've just added a quick hack to get you going- copy this over your existing PowerQuest.cs: https://www.dropbox.com/s/psiwos73ksepghc/PowerQuest.cs?dl=0.  Then in PowerQuest Project Settings i've added an "Inventory Click Style". Set that to "Use Inventory".  To set inventory as the active one when you want to, just use E.ActiveInventory = I.RubberChicken;

You can also add an "UnhandledEvent" fallback function to your Global Script, so it'll fall back to that if there's no 'Use' for an item. Copy this into your Global script- 

IEnumerator UnhandledInteractInventory( IInventory item )
{ 
    yield return E.Break; 
}

As for verbs- Like you thought, there's not currently a way to add more verbs, another thing that's been on my to-list forever, so the way you are doing thing is currently the best way.

For the Dialog Trees  question- I'm not sure what you mean exactly. The dialog tree gui should keep returning until you use the Stop() function.  There is an OnStart() and OnStop() function for dialogs already, the buttons for those functions should be in the inspector when you have the Dialog Tree selected.

Awesome, thanks!