Is this possible?
Basically I want to show the liquid level (as well as emission per cycle) in the right panel for this entity:



Code: Select all
player.selected.backer_name = player.selected.backer_name .. "\r\n<your data goes here>"
Since spilled fluid is a simple entity and does not support backer names, can you show me a sample of the custom GUI code? I have never done anything like that before.321freddy wrote:Since you cannot edit the basegames GUIs you have to rely on a workaround.
The only one I know of which would come very close to what you want only works for entities which support custom backer names:
Basically you add a newline to the backer name of the entitiy and add your text there:Results in something like this:Code: Select all
player.selected.backer_name = player.selected.backer_name .. "\r\n<your data goes here>"
If your entitiy does not support backer names the you'd have to create your own gui inside the on_selected_entity_changed and put your data in there.
Or display a flying text entity.
Using your own gui gives you way more flexibility but is a bit detached from the base game gui. I did it like this in my attach notes mod:
I can provide code examples for this if you want.
viewtopic.php?f=25&t=56317Reika wrote:can you show me a sample of the custom GUI code? I have never done anything like that before.
Code: Select all
global[playerindex].mytooltip = player.gui.left.add{stuff/frame}.add{stuff/label}
Code: Select all
mytooltip.mylabel.text = fetch_my_data(generate_identifier(player.selected))
These entities already have a tickhandler, so I can plug it into that. I also already have UIDs based on coordinates, for exactly this ability.eradicator wrote:Simple.
Create a gui element player.left (or top) and store the referencein on_selected_entity_changed watch for your entities name, if your spill is selected start a dynamic tick handler.Code: Select all
global[playerindex].mytooltip = player.gui.left.add{stuff/frame}.add{stuff/label}
In the tick handler just:When the player unselected the spill stop the tick handler.Code: Select all
mytooltip.mylabel.text = fetch_my_data(generate_identifier(player.selected))
Not sure if simple-entity has a unit_number property, so you might have to generate a UID based on the position coordinates. Also be aware that you get no control over where on the screen that tooltip is placed. It all depends on what other mods that add gui elements are loaded before yours.
(Dynamically starting/stopping the tick handler is obviously done for performance reasons only, to not waste cpu when unnessecary)