Author Topic: Carrying custom entities  (Read 42068 times)

0 Members and 1 Guest are viewing this topic.

Diarandor

  • Hero Member
  • *****
  • Posts: 1062
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Carrying custom entities
« Reply #60 on: October 05, 2015, 12:45:04 AM »
Ok, I think the new script is working now (I have tested it this time), sorry for the problems.

The problem was that I forgot to save/load the "is_independent" property when the entity was saved. It was working for me because for a "specialized" portable entity with the "independent property", I usually start the script with this:
Code: [Select]
local entity = ...
sol.main.load_file("entities/generic_portable")(entity)

entity.is_independent = true -- I PUT THIS HERE INSTEAD OF THE MAP SCRIPT.
... -- ETC.
so I didn't need to save/load the "entity.is_independent" value. Can you confirm that the new script is working for you?
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

wizard_wizzle (aka ZeldaHistorian)
  • Sr. Member
  • ****
  • Posts: 263
    • View Profile
Re: Carrying custom entities
« Reply #61 on: October 05, 2015, 02:05:15 PM »
Error: In on_map_changed: [string "scripts/save_between_maps.lua"]:122: attempt to index field 'active_maps' (a nil value)

Diarandor

  • Hero Member
  • *****
  • Posts: 1062
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Carrying custom entities
« Reply #62 on: October 05, 2015, 03:59:58 PM »
Maybe I am wrong, but I think you copied the wrong file. I have two repositories, the one for my game, and the one with the simplified scripts to carry custom entities (for other people, including you). The variable "active_maps" of that error does not appear in the simplified script in:
https://github.com/Diarandor/portable_entities/tree/master/scripts
which is the one you have been using before. Can you try the new script?
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

wizard_wizzle (aka ZeldaHistorian)
  • Sr. Member
  • ****
  • Posts: 263
    • View Profile
Re: Carrying custom entities
« Reply #63 on: October 06, 2015, 01:19:23 AM »
Yeah, you're right. I was using the correct repository all the other times, this last time I just followed the wrong link.

The script works perfectly, but only if the entity.is_independent is set when the entity is created. Putting self.is_independent in the on_custom_created() of the custom entity script doesn't result in an independent entity (it's recreated in the same spot and doesn't persist when left in a new map).

Diarandor

  • Hero Member
  • *****
  • Posts: 1062
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Carrying custom entities
« Reply #64 on: October 07, 2015, 03:54:17 PM »
That's very strange, it should work with "self.is_independent = true" inside the on_custom_created() event. Is that event being called? You can check it playing some sound. Maybe the name of the event "on_custom_created" or the variable "is_independent" are not correctly written, can you check them?
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

wizard_wizzle (aka ZeldaHistorian)
  • Sr. Member
  • ****
  • Posts: 263
    • View Profile
Re: Carrying custom entities
« Reply #65 on: October 08, 2015, 02:12:29 PM »
Sorry, it works. I was still using the wrong model (generic_portable) instead of the new custom entity.

Diarandor

  • Hero Member
  • *****
  • Posts: 1062
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Carrying custom entities
« Reply #66 on: October 08, 2015, 03:01:16 PM »
That's good news.

If you want, I will explain what I do to allow pushing custom entities which are buttons using some generic portable entities. (I usually set a property "entity.can_push_buttons=true" in the specialized script.) You will need the script of the button.

Also, we will need to add a custom event to the throw function, to add a collision test to the metal ball when it is falling, and remove the collision test when it has fallen. This will be useful to hurt enemies and destroy other objects if we create the metal ball of Link's awakening.
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

Diarandor

  • Hero Member
  • *****
  • Posts: 1062
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Carrying custom entities
« Reply #67 on: October 08, 2015, 04:20:04 PM »
Another suggestion. When the player leaves the level, we should delete the info of the metal ball from the corresponding list with game.independent_entities[metal_ball_id]=nil, so when the player enters the level the ball is created at the initial position again. That behaviour is maybe the best one. We can use the teleporter of the exit of the level to do that.
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

wizard_wizzle (aka ZeldaHistorian)
  • Sr. Member
  • ****
  • Posts: 263
    • View Profile
Re: Carrying custom entities
« Reply #68 on: October 08, 2015, 11:32:49 PM »
Didn't you mention you were also working on (or wanted to) allowing enemies to lift these custom entities?

Diarandor

  • Hero Member
  • *****
  • Posts: 1062
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Carrying custom entities
« Reply #69 on: October 09, 2015, 12:44:52 AM »
Yes, but I haven't done that yet. It can be done if we modify the generic_portable.lua script, but I don't have time this month to work on this. I will try to implement that sometime soon.
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”