Author Topic: Text box appearing when getting an item  (Read 16230 times)

0 Members and 1 Guest are viewing this topic.

hood_rad
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Text box appearing when getting an item
« Reply #15 on: September 13, 2019, 09:38:42 PM »
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!
« Last Edit: September 13, 2019, 10:18:34 PM by hood_rad »

llamazing

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: Text box appearing when getting an item
« Reply #16 on: September 13, 2019, 11:20:57 PM »
You need quotes on the dialog:
game:start_dialog("_treasure.sword.1")

hood_rad
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Text box appearing when getting an item
« Reply #17 on: September 14, 2019, 12:08:50 AM »
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?

hood_rad
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Text box appearing when getting an item
« Reply #18 on: September 14, 2019, 12:13:09 AM »
ok got it working by putting game:start_dialog("_treasure.sword.1") in function item:on_variant_changed(variant)

Max

  • Sr. Member
  • ****
  • Posts: 277
    • View Profile
Re: Text box appearing when getting an item
« Reply #19 on: September 14, 2019, 03:28:51 AM »
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?

Graw
  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Text box appearing when getting an item
« Reply #20 on: April 17, 2020, 03:16:38 AM »
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