Lifting a custom_entity?

Started by Satoh, July 11, 2016, 06:02:06 AM

Previous topic - Next topic
so, I've been coding a custom entity that I can push around and lift...
Pushing isn't really a problem, but I've run into a curious issue...

I don't know how to tell the engine the hero is in the lifting or carrying states, nor how to generate a carried object...
I can't simply use a destructible, since the hero will be setting down the object later...

I can probably add a 'set_state(param)' to type hero if I alter the metatable... but even so, that won't automatically create a carried object... and the documents don't seem to suggest that it is possible to do so through the lua interface...

Am I going to have to code everything from the lifting to the walking, and placing/throwing manually?
For the first time in a while I'm 100% stumped as to how to proceed.
Patience is difficult and rarely thanked, but always appreciated, and sorely missed when absent.

July 11, 2016, 06:26:54 AM #1 Last Edit: July 11, 2016, 06:28:50 AM by Diarandor
Yes, everything has to be scripted since there is no way to carry custom entities at present, and it is not easy. I had some scripts which used to work (I have some issues now and things in the code that I want to improve and simplify), but since I am currently working on pixel-art and have other priorities, I do not know when I will finish the next version of these scripts.

Anyway, in order to integrate the scripts, you would need to modify several important events of your main scripts to allow a correct behavior, which is not trivial. For instance:
1) To allow carrying custom entities between maps or not, so you need to define some built-in events.
2) To allow some of them to save position in a map when you leave them (I call these "independent" entities like the metal ball in LA). These need to be created by your code if necessary, when the map is created.
3) To make them unique or not (this is always the case of "independent" entities, but also of some "non-independent" ones if you do not want to allow cloning them when carrying one then going to a new map and then coming back to the original map), etc.
3) You need to fix the carrying animation for the hero, which is not trivial. There are already scripts in this forum to allow to fix animations (and directions) for the hero.
4) If you want the HUD to display a "carry" text when you can carry a custom entity, then more annoying code has to be modified. (Remark: note that you need to detect the entity in front of the hero, which is currently easy thanks to the new functions "entity:get_facing_entity()" that allow to get the entity facing the hero; but this was a pain and more complicated some time ago, and I still have to simplify my scripts using that function.)
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

Alright thanks for the reply. I'll start thinking about how I need this to work.

I already created a way to run faster using a different animation, while holding the shift key... I'm guessing I'll have to do some extrapolation of that for the carrying animation...

Perhaps define a secondary 'state' variable...depending on whether I can make "state" accessible and whether it automatically reverts if no carried object reference is found...

Welp... Its a good thing I wasn't doing this a year ago, or I'd never have understood lua well enough to do any of it.
Despite all the trouble I'm having with custom entity code, I'm actually getting some cool stuff done, from a framework perspective.
...oh well. Back to work with me.
Patience is difficult and rarely thanked, but always appreciated, and sorely missed when absent.