Author Topic: Multiple Entities Sponaneously Broken  (Read 3614 times)

gmanplays@gmail.com

  • Newbie
  • *
  • Posts: 24
    • View Profile
Multiple Entities Sponaneously Broken
« on: April 08, 2019, 11:57:42 pm »
Hey again,

So I'm starting to near the end of my first dungeon, but just when I thought it was safe to move on, all of my locked doors broke (they no longer load in the game as an entity, as if they never existed), and what really confounds me is that a cutscene event I wrote that was working just fine before no longer works as well. Doors that are locked by switches are still functioning normally. There are multiple exceptions generated upon loading the game, none of which existed for most of the development process thus far. Below's an exhaustive list of those exceptions. If this has happened to you, I beg that you let me know what I need to go in and edit. Thanks much for your time.

1)
Code: [Select]
Error: In on_created: items/dungeons/small_key.lua:6: module 'sprites/items/dungeons/small_key' not found:
2)
Code: [Select]
Error: In create_door: bad argument #1 to ? (Bad field 'opening_condition' (equipment item 'dungeons/small_key' is not saved))
3) Error: In on_created: enemies/bosses/armos_knight.lua:18: attempt to call method 'set_arrow_reaction' (a nil value)

4) Error: In on_pickable_created: items/consumables/heart.lua:50: bad argument #1 to set_animation (Animation 'heart_falling' does not exist in sprite 'entities/items')

Important note: I have not tampered with any of the files pertaining to doors, pickables, or items. I have checked, and heart_falling & dungeons/small_key indeed exist and do so in their proper placement in the directory.

llamazing

  • Full Member
  • ***
  • Posts: 198
    • View Profile
Re: Multiple Entities Sponaneously Broken
« Reply #1 on: April 09, 2019, 01:15:43 am »
That first error indicates that line 6 of the items/dungeons/small_key.lua script encountered an error because it could not find the small key sprite located at sprites/items/dungeons/small_key.

I would start by adding that sprite to your quest. Errors that follow don't necessarily mean anything because when a script encounters an error it halts execution of the remainder of that script, so other scripts often have errors because of that script was not loaded fully.

gmanplays@gmail.com

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Multiple Entities Sponaneously Broken
« Reply #2 on: April 09, 2019, 01:34:55 am »
That sprite already exists in that directory, correctly named, and in the correct directory though.

llamazing

  • Full Member
  • ***
  • Posts: 198
    • View Profile
Re: Multiple Entities Sponaneously Broken
« Reply #3 on: April 09, 2019, 02:41:13 am »
Then post the code from your on_created() event. You must have an error in there somewhere.

EDIT Also, try posting the following code in the console of the quest editor while your game is running:
Code: (lua) [Select]
print(sol.main.resource_exists("sprite", "items/dungeons/small_key"))
« Last Edit: April 09, 2019, 02:47:20 am by llamazing »

gmanplays@gmail.com

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Multiple Entities Sponaneously Broken
« Reply #4 on: April 10, 2019, 08:50:46 pm »
I've printed the diagnostic you suggested, and it returned false. However, in on_created, I can't find any method looking for that sprite either. Other than that, it stopped generating that exception for some reason and replaced it with the In create_door exception upon booting the project. This is just so bizzare, I don't know where to even start. Also, where's the script the governs doors? I can't find it in the entities directory.

Anyway's here's the script for the small keys I'm using. Thanks again for all your help.

Code: [Select]
local item = ...


function item:on_created()
  require("scripts/equipment")
  self:set_shadow("small")
  self:set_brandish_when_picked(false)
  self:set_sound_when_picked("picked_small_key")
end

function item:on_obtaining(variant, savegame_variable)

  self:get_game():add_small_key()
end

froggy77

  • Full Member
  • ***
  • Posts: 137
    • View Profile
Re: Multiple Entities Sponaneously Broken
« Reply #5 on: April 11, 2019, 01:20:51 am »

That sprite already exists in that directory, correctly named, and in the correct directory though.
Your answer is incomplete.The fact that a sprite (image file and .dat file) and a script already exist in the correct directory, with the correct name, does not mean that they were added to the quest.
« Last Edit: April 11, 2019, 01:25:58 am by froggy77 »

llamazing

  • Full Member
  • ***
  • Posts: 198
    • View Profile
Re: Multiple Entities Sponaneously Broken
« Reply #6 on: April 11, 2019, 01:26:44 am »
I don't see the .dat file in that screenshot... that may be your problem.

gmanplays@gmail.com

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Multiple Entities Sponaneously Broken
« Reply #7 on: April 11, 2019, 09:54:30 pm »
So I added an animation for it now, checked the file and saw the new .dat file, double checked for naming, and then ran the quest, but no changes in the exception changed. I required the key sprite, but it said that the file still didn't exist? I don't know how to tell the engine that this sprite exists any better than I already am. Any ideas?

llamazing

  • Full Member
  • ***
  • Posts: 198
    • View Profile
Re: Multiple Entities Sponaneously Broken
« Reply #8 on: April 11, 2019, 11:40:11 pm »
So I added an animation for it now

You can't just go adding any old animation, it has to be the correct one. You should import the .dat file from the project where you got the small_key png file, then the dat file will be setup correctly and automatically get added to your quest (sprites need both the .png and .dat files to work correctly, so make sure you get both when importing).

If you simply copy the .dat file over to your project without using the import feature then it doesn't get added to your quest automatically, and in that case you will have to find the sprite in the quest tree (left sidebar of the quest editor), which will have a '?' icon. Right-click it then choose the option to add it to your quest.

Diarandor

  • Hero Member
  • *****
  • Posts: 1052
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Multiple Entities Sponaneously Broken
« Reply #9 on: April 12, 2019, 05:42:50 pm »
General remarks:

1) Do not mix these 2 different concepts:
sprites (which  are dat files with metadata) and source images (the image files). In other forums or for other engines, image files are called sprites, but that is not the case with the Solarus API.
2) Do not mix these other 2 concepts:
adding a file (copy-pasting files to the data folder) and adding a resource to the quest (right click with the mouse and select the option to add it, or use the import feature that the others mentioned before).

It may seem annoying for newbies to learn these things, but it is very important when you have a problem and need others to understand you.
« Last Edit: April 12, 2019, 05:44:35 pm by Diarandor »
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

gmanplays@gmail.com

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Multiple Entities Sponaneously Broken
« Reply #10 on: April 20, 2019, 07:14:31 am »
So I don't see the option to add these items to the quest; nor can I import them from another quest. Should I go back to the CoS github and download the entire thing so I can import it from there?

Diarandor

  • Hero Member
  • *****
  • Posts: 1052
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Multiple Entities Sponaneously Broken
« Reply #11 on: April 22, 2019, 02:52:27 pm »
So I don't see the option to add these items to the quest; nor can I import them from another quest. Should I go back to the CoS github and download the entire thing so I can import it from there?

If you took them from CoS it is better to import them, because that will automatically add the author/license metadata. Otherwise, right click on the file at the Quest Tree, then select the option "Add to quest" or something like that.
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

gmanplays@gmail.com

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Multiple Entities Sponaneously Broken
« Reply #12 on: July 08, 2019, 05:43:00 am »
Hey guys, sorry for a late response; I've been busy lately.

So I finally figured out how to import assets, and I've promptly imported the small key scripts, but I couldn't find the .png files OR the sprite files for those various items in the Children of Solarus github. I therefore found third-hand pngs and dropped those into their proper file destination. Upon doing so, I booted the quest editor to go and press the "Add to quest" button, but when I right clicked on each png, there wasn't one. I booted the quest, and I got the same error message:

Code: [Select]
Error: In create_door: bad argument #1 to ? (Bad field 'opening_condition' (equipment item 'dungeons/small_key' is not saved))
What might be going wrong now that I've imported those scripts?

IMPORTANT ADDENDUM: I've tested one of locked doors by setting their unlock condition to rupees instead of keys, and I get the very same error message, except with rupees not being saved instead of small keys. Given this, I think that it'd be more important for me to learn how to get my quest to save the states of these items. I've double-checked both scripts, and I found the line
Code: [Select]
item:on_obtaining(variant, savegame_variable) in both. Is this supposed to save the items?
« Last Edit: July 08, 2019, 06:01:53 am by gmanplays@gmail.com »

Kamigousu

  • Newbie
  • *
  • Posts: 27
  • Game Design 'Hobbyist'...for now.
    • View Profile
Re: Multiple Entities Sponaneously Broken
« Reply #13 on: July 14, 2019, 07:50:28 pm »
Hey gman, not sure if you got any further with this but when adding sprites to a quest you can’t simply click the png file as with other categories. You have to manually create a sprite (by right clicking on the folder and selecting add sprite) and then define the source image as your png file. That won’t clear up your error but it is how you can add sprites to your quest from png files.

As for the item:on_obtaining(variant, savegame_variable) code you posted, that is an event that is called by the engine when you obtain an item. Variant and savegame_variable pull that info from the item in question so if the hero is obtaining a green rupee, the engine sets the variant to 1 and the savegame_variable to whatever the savegame_variabke is for that item (I think it is just rupees for the rupee item, but I’m at work so I can’t check right now). That event doesn’t save the item to the game, I don’t believe. You can use game:get/set_value() to save things but there should be default behaviour for items like rupees and keys. Unless you are missing scripts still...which it seems like you might be.

Edit: can you post the item scripts you have for rupee and small_key?
« Last Edit: July 14, 2019, 11:48:07 pm by Kamigousu »
Build a man a fire, he will be warm for the night. Set a man on fire, he will be warm for the rest of his life.