Page 1 of 1

Entity attachement

Posted: Fri Apr 22, 2016 17:03
by azekill_DIABLO
Is it possible to make a player ALWAYS ride an entity, like a car of my mod???

Re: Entity attachement

Posted: Fri Apr 22, 2016 17:10
by sofar
Yes, you can do this several ways:

1 - attach on login, attach on respawn, and disallow detaching.
2 - change the player model

Re: Entity attachement

Posted: Sat Apr 23, 2016 10:38
by azekill_DIABLO
precision on the first way??

with some code pls

Re: Entity attachement

Posted: Mon May 02, 2016 11:04
by azekill_DIABLO
hey can somone help?? :(

Re: Entity attachement

Posted: Mon May 02, 2016 14:02
by oleastre
I don't want to be rude, but did you tried to do what sofar explained ?

You have your own car mod working with entities, so at least you already have an example of code that attach the player to an entity.

I did not tried by myself, but from sofar comment, I just had a look in the minetest api, searched for "connect" and "spawn" and found two functions: minetest.register_on_joinplayer and minetest.register_on_respawnplayer.

So, you just have to use those two functions to register callbacks that will attache your player to an entity, just like it's done when a player use the "use" button to get into your car mod.

Maybe you already tried and got some errors, then ignore the above comment and let us know what the problem is.

Re: Entity attachement

Posted: Mon May 02, 2016 14:34
by azekill_DIABLO
hey! i made that thread becuz i already tried things without sucess and becuz i'm a noob in lua!

if we can ask an exemple of code.........

but thanks i wasn't knowing this Minetest api

Re: Entity attachement

Posted: Mon May 02, 2016 14:48
by oleastre
I understand you are beginning; and I can only encourage you to continue making efforts.

If you do not get answers, maybe try other ways (like the various irc channels), or give us some hints.

As a daily programmer, when you ask for code examples, it seems like you want me to write the code for you :)

And if I never did precisely what you are asking for, I will not answer you with something I did not tested. And so, probably do not answer.

If you asked "How can I know when a player connects or respawn ?" then you would probably have got a quick answer pointing to the correct location in the minetest api.

Did you already read rubenwardy's minetest modding tutorial ?

( and if it's easier for you to ask questions in french, do so in the dedicated forum section ;-) )

Re: Entity attachement

Posted: Mon May 02, 2016 14:55
by azekill_DIABLO
oh no i just know if someone was able to show some functions or part of code!

if i don't code in lua that not funny ...

you just gave me docs and that perfect! and for code i better understand english ;)