Hi
Is there a way to override syntax based on a hotspot rather than an inventory object?
example:
I have a "slice of bread" inventory item.
I have a "plate" inventory item.
I have a "toaster" hotspot.
Syntax should be:
Use slice of bread in toaster
Use slice of bread on plate
Kinda feels like you could have "override syntax" tickbox on the "Use" action within the Hotspot component.
I've attached a snapshot of a recommended location for it.
Thanks
Kev
https://drive.google.com/open?id=1GloRQEDb29t-SN7cYLNznZpYi5RgycB0
Comments
The code below works brilliantly, except for an error on Line 17 about accessing a null object.
Also, I spent a while going through documentation and trying to understand the scripts, but I just can't figure out the last two things that would make this perfect.
1) set the hotspot to (this), the hotspot that the script is attached to.
2) a dropdown list of all active inventory items in place of "public string invItem;"
If anybody wants to make use of this script, be sure to untick "Override use syntax" from the Inventory Manager menu, as that overrides this script.
thanks again
Kev
I've tidied up the script a little and incorporated your suggestions - it works perfectly thank you
If I could change the "Inventory Item" to a drop down... that would be the cherry on top
Kev
I have attached the entire script here: https://codepad.co/snippet/yXKKIfVy
I'm hoping you take pity on me and can fix the couple of lines of code needed to get this working.... Or in fact anybody else on the forum?
Fingers crossed...
KevRev
I know its core files that'll be overwritten when I update AC, but thats my lookout (unless you like it enough to integrate it... )
1 line added to "Button.cs" to add the "syntax" element to a button:
1 line added to "HotspotEditor.cs" to allow you to type the new syntax:
invButton.syntax = EditorGUILayout.TextField("Override 'Use' syntax:", invButton.syntax);
Then (because I didnt know how to integrate it) i've still had to add the following script as a component:
https://codepad.co/snippet/S2jUbXFq
So i think all I need is a little tweak in the above code to reference (InvButton.syntax) and to apply it.
I really think this could be an excellent addon to Adventure Creator.
Use Can of Paint to spray on wall
Use water to fill watering can
Use scissors to cut paper
It opens up a whole lot of context sensitive commands that you could add to a game.
Any help greatly appreciated.
Ta
Kev
I finally have this working EXACTLY as I wanted.
DESCRIPTION:
You can now override the "Use" syntax on a per inventory/hotspot interaction basis.
For instance, if you want to use a slice of bread with a toaster OR a plate, you'll want to:
Use slice of bread on plate
Use slice of bread in toaster
You may even want to:
Use sponge to mop up puddle
VIDEO DEMO:
https://youtu.be/CbxMvPmTyBk
ADD TO YOUR OWN PROJECT:
There are three script files:
ItemOverride.cs
https://codepad.co/snippet/oEfT8Wtw
InvManager.cs
https://codepad.co/snippet/gyag7smQ
And in an "EDITOR" folder beneath the main script, InvManagerEditor.cs:
https://codepad.co/snippet/Dk9WIyyx
Massive thanks to @ChrisIceBox for his excellent support and advice.
I've spent HOURS and HOURS working on this (being a N00b and all). I've learnt basic C# and a LOT about Unity and AC, which will help with my projects.
Hi everybody. First of all thanks @KevRev for sharing the code.
Now, could InvManager be modified to override the "Use" part of the sentence as well?
Drop slice of bread in toaster.
If it's possible to do it OnSpotSelect, it might be a good way to add custom syntax per hotspot.
I know @Selzier has a tutorial that covers getting the text to say "Equip" instead of "Use" on specific occasions, but I don't know how to combine both.
Thanks!
The Inventory Manager already allows for this without modification. Checking Override 'Use' syntax? in an item's list of properties allows you to change both the 'Use' and 'on' words in the sentence.
Thanks @ChrisIceBox !
I am using that already, but I find myself wanting to define different Verbs for different hotspots with the same item.
I would also love to be able to change the verb that appears when Using, Looking at or Talking to a hotspot (without an item).
I am aware I can create another cursor, but since I am using Click on Hotspot then Interaction with a custom Unity UI, I am having trouble linking interaction buttons to 'new' cursors.
I see. @KevRev's scripts only seem to override the "on" word, but I'd imagine it could be adapted to incorporate "Use" as well with some tweaks. You may like to PM him directly.
You can rename "Use", "Look at", etc - but creating new cursors is definitely the way to go.
To link a cursor to a menu, you need to create an Interaction element and select the correct "Cursor" field from the drop-down. Since custom Unity UI canvases do add another layer of complexity, you can temporarily switch your Menu's Source to Adventure Creator and getting it working in that mode before incorporating Unity UI.
I adapted @KevRev's script to include the verb too. You only need very minimal C# knowledge. I don't have access to my project right now, but all you need to do is add an extra parameter to ItemOverride, and then do everything he did for hotspotPrefix2 but for hotspotPrefix1 this time (and then add a field to the editor script to account for that).
@ChrisIceBox how would I go about scanning these fields when I click "Gather text"? They would need to be localised.
Have your script implement the ITranslatable interface - see the Manual's "Custom translatables" chapter for more.
Thank you! I'll check it out.