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

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: 198
    • 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

  • Full Member
  • ***
  • Posts: 223
    • 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?