Hello,
I'm using the Gspot library to create UI for my game and I want to create a inventory with a menu appearing beside the name of the item when I hover it.
See my attached "helpme.love" (it's in love 11)
-- Edit
The problem is that only one sub-menu is appearing (the last one created).
(Sorry if my english is bad btw)
I need help with Gspot
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
I need help with Gspot
- Attachments
-
- helpme.love
- (11.15 KiB) Downloaded 89 times
Last edited by Quôzul on Tue Apr 17, 2018 7:55 am, edited 1 time in total.
Re: I need help with Gspot
Hello, welcome to the forums.
I'm not sure I understand. My understanding is that you want to have a series of items as names in a list, and when you hover over one, a menu appears and you can select from it, or it disappears if you move the mouse. Is that right?
I'm not sure I understand. My understanding is that you want to have a series of items as names in a list, and when you hover over one, a menu appears and you can select from it, or it disappears if you move the mouse. Is that right?
Re: I need help with Gspot
Thanks you
That's the idea, and from the menu that appears I can remove the items from the inventory and see the attributes of it.
But the problem is that only one menu is appearing (the last one)
Re: I need help with Gspot
One more clarification. When you say menu, do you mean the tooltip text? that is, the little window with a text?
If you mean just that, you can use the tip property instead, like this:
If you actually mean a menu with options like wield, drop, etc. then that needs more work.
Note that there's a bug when showing multiline tooltips like the above, that I'm going to fix right now
If you mean just that, you can use the tip property instead, like this:
Code: Select all
display.item.tip = "This is a" .. (e:match("^[aeio]") and "n " or " ") .
. e .. "; you can place the\nstats you want here"
Note that there's a bug when showing multiline tooltips like the above, that I'm going to fix right now
Re: I need help with Gspot
I meant the little window that popup next to the item.
Thank you I didn't thought of that!pgimeno wrote: ↑Tue Apr 17, 2018 12:30 pmIf you mean just that, you can use the tip property instead, like this:
Code: Select all
display.item.tip = "This is a" .. (e:match("^[aeio]") and "n " or " ") . . e .. "; you can place the\nstats you want here"
For dropping the item, I've add a small button next to the item but how can I update the list?
- Attachments
-
- game.love
- (10.86 KiB) Downloaded 63 times
Re: I need help with Gspot
First, you need to remove the element and the extra button with gui:rem(element). Then you will need to reposition the other elements.
You need to rethink your code a bit, though:
- You're creating a new window and new buttons every time display.update is created, and not removing any. If you want to recreate buttons, you need to delete all first; a quick way is to remove display.inventory.bag if it is not nil, right at the beginning. You can use something like print(#gui.elements) to track how many GUI elements you have active.
Even better, you can have the bag created at the start (not every time you call display.update), and make a function to add an item to the player's inventory, that also adds the controls to the GUI, and another function to remove from it, that also removes the controls from the GUI. Then, to add one item to the player's inventory, you call that function and it will automatically add the button for you. And to remove an item, you call the other function, which will also remove the controls.
- You're trying to remove from the inventory by number, but your items are names. The remove won't succeed. I'd suggest you switch your inventory to numeric, because then the order is preserved (pairs() does not iterate in any particular order, and in fact the order can change when it rehashes). You can then also use the numeric index for repositioning the GUI buttons.
Re: I need help with Gspot
I've merged the multiline fix now.
Re: I need help with Gspot
I'll try this out, thank you for theses tips
Sorry to have taken a long time to answer, I had a problem with my computer.
Who is online
Users browsing this forum: Google [Bot] and 85 guests