using player.ActiveInventory.Name from Global Script

Started by fever44, Thu 25/05/2023 17:15:51

Previous topic - Next topic

fever44

I am trying to write a function in the global script that I can call from any of my rooms that will display "use INVENTORY ITEM on HOTSPOT", eg: "USE BLUE MUG ON ROCK". However, when I use player.ActiveInventory.Name from the global script, the value is always 0. If i make the same call from my room script, the value is correct - the actual name of the inventory object.

I was having this same issue with hotspots as well. What am I missing here?

Thank you!

eri0o

In which function in global script are you using this? What do you mean by the value of name is 0?

fever44

Thanks for the response. I made my own function and added it to the global script. When I assign 'player.ActiveInventory.Name' to a String and use Display() to display the String, it outputs "0" or "0.0000000f". However, if I move the code to my room script, it works as expected and outputs the actual name of the inventory item.



Khris

You need to use %s to insert a string value into text, it looks like you've accidentally used %d or %f.
Please always show your code when asking about coding.

https://adventuregamestudio.github.io/ags-manual/StringFormats.html

fever44

Thanks Khris, you nailed it; that is exactly what I was doing wrong. Appreciate your help!

SMF spam blocked by CleanTalk