Page 1 of 1

[0.16.36] Sprite Path from file not working

Posted: Thu Apr 05, 2018 9:01 pm
by blueblue
According to the documentation on sprite paths it is possible to load sprite files from base. I cannot get this to work in sprite buttons. As a minimal example, the following two commands create a button, however it is invisible although the file exists in the base mod.

Code: Select all

/c game.player.gui.top.add{type="sprite", sprite="file/__base__/graphics/icons/alien-artifact-goo.png", name="button"}
/c game.player.gui.top.add{type="sprite", sprite="file/graphics/icons/alien-artifact-goo.png", name="button2"}

Re: [0.16.36] Sprite Path from file not working

Posted: Thu Apr 05, 2018 11:11 pm
by sparr
First, "sprite" is not the element type you want for a button. You want a "sprite-button".

Second... I have no idea why that sprite path doesn't work.

Code: Select all

/c game.player.gui.top.add{type="sprite-button", sprite="file/__base__/graphics/icons/alien-artifact-goo.png", name="button"} 
This creates a visible button... with no sprite. I'm stumped there.

Re: [0.16.36] Sprite Path from file not working

Posted: Fri Apr 06, 2018 3:45 am
by osldgoth
I too have been trying to use file for a sprite path. I've tried validating the path with gui.is_valid_sprite_path() which returns true for the sprite I try to use but the button is empty. however I am not convinced is_valid_sprite_path() works right.

I am trying to use "__core__/graphics/questionmark"

FALSE --as expected

Code: Select all

/c game.print(game.player.gui.is_valid_sprite_path("file"))
TRUE --not sure why, but ok.

Code: Select all

/c game.print(game.player.gui.is_valid_sprite_path("file/"))
TRUE --as expected

Code: Select all

/c game.print(game.player.gui.is_valid_sprite_path("file/__core__"))
TRUE --expected false

Code: Select all

/c game.print(game.player.gui.is_valid_sprite_path("file/__core__/questionmark"))
TRUE --as expected

Code: Select all

/c game.print(game.player.gui.is_valid_sprite_path("file/__core__/graphics/questionmark"))

Re: [0.16.36] Sprite Path from file not working

Posted: Fri Apr 06, 2018 7:35 am
by posila
The documentation is misleading (or rather wrong).
Sprite path of type file references files from scenario folder, its purpose is to be able to show some images in tutorials and campaign, without having to keep them in memory all the time. is_valid_sprite_path doesn't check if file exists in this case, because that is not deterministic.

You can access question mark through is_valid_sprite_path("utility/questionmark"), and I assume alien-artifact-goo is an item icon so you can access that through "item/alien-artifact-goo"

I fixed the documentation for next release

Re: [0.16.36] Sprite Path from file not working

Posted: Fri Apr 06, 2018 11:45 am
by blueblue
The alien artifact icon is in base but only as an image file, not an item, which is why I was looking at file sprite paths in the first place. Since I am working with a scenario I'll look into how the tutorials are doing this.

Re: [0.16.36] Sprite Path from file not working

Posted: Fri Apr 06, 2018 4:13 pm
by sparr
So if an image file is not used by any sprite-ful prototype then to use that icon as a button sprite you might need to make a new item with a sprite of that file, then reference that item/itemname for your sprite?

Re: [0.16.36] Sprite Path from file not working

Posted: Fri Apr 06, 2018 4:19 pm
by Bilka
sparr wrote:So if an image file is not used by any sprite-ful prototype then to use that icon as a button sprite you might need to make a new item with a sprite of that file, then reference that item/itemname for your sprite?
No, you define a sprite: https://github.com/Bilka2/Quill/blob/master/data.lua#L3