Text box appearing when getting an item

Started by hood_rad, September 08, 2019, 11:26:23 PM

Previous topic - Next topic
September 13, 2019, 09:38:42 PM #15 Last Edit: September 13, 2019, 10:18:34 PM by hood_rad
sol.language.set_language("en") was already in my main.lua. Should it be added somewhere else? I tried adding game:start_dialog(_treasure.sword.1) to the item script and main.lua and I just get the error "Error: Failed to load script 'main': main.lua:11: ')' expected near '.1'" I also tried adding to main.lua and got the same error but no error about the language not being set. 

And I was thinking it might be something to do with the file directory that the item is in. I tried messing around by changing the dialog to "_treasure.equipment.sword.1" but haven't had any luck yet. Ill mess around a bit tonight to see if I can figure it out.

Thanks again for all the suggestions guys!

You need quotes on the dialog:
game:start_dialog("_treasure.sword.1")

ok Im dumb sorry. I tried adding game:start_dialog("_treasure.sword.1") to sword.lua under function item:on_created() and under no function and I get this error for both: Error: In on_created: items/equipment/sword.lua:7: Cannot start dialog: this game is not running

should I be adding game:start_dialog("_treasure.sword.1") somewhere else maybe?

ok got it working by putting game:start_dialog("_treasure.sword.1") in function item:on_variant_changed(variant)

Yeah, the on_created event is called before the game starts. It creates all the items, it's better than not creating the item in memory until you get it for a lot of reasons.

On variant changed would be the right place, but I still can't figure out why it wouldn't be playing automatically. If you game is on gitlab or GitHub I can pull it down and take a look if you want. Have you made other items and the dialogues display automatically?

Sorry to resurrect this topic but I ran into this problem and tried OP's solution but it led to a small delay after brandishing. I figured out that any items in subfolders need to have their dialog named as _treasure.subdirectory/item.

ie. For the sword with the alttp resource pack: _teasure.equipment/sword.1