function tank_turret.on_step(self) --tank_turret is an entity local turret = self.object local pos = {x=playerpos.x, y=playerpos.y, z=playerpos.z} --the position of player is correct turret.set_pos(pos) -- this line causes the bug, but why?end

topic: Passing values between objects.reason: I want to pass a custom value from one entity to another entity.more info: There is an entity named "First", and in on_activate() I run this code o spawn a second entity and later to pass the value:

orwell wrote:1. set_attach means "attach this object (the object that the function is called on) to the specified one".2. the attachment status is lost on unloadingSo what you need to do is:1. the first object needs to hold all relevant data2. in the on_activate function of the first object, create the second object, give it a reference to the first object for data storage (if you need this) and call set_attach on the second object and give the first object as argument3. "bone" just needs to be an empty string4. the attachment position is the place where the second object is positioned relative to the first

function tank_turret.on_step(self) --tank_turret is an entity local turret = self.object local pos = {x=playerpos.x, y=playerpos.y, z=playerpos.z} --the position of player is correct turret.set_pos(pos) -- this line causes the bug, but why?end

I am a noob.still yet. Not so noob ) [vml] WIP and a little proof for fun PlantedTorch )))MT Strike 78a36b468554d101e0be3b0d1f587a555f396452 Great! Somebody have found it ) "My english isn't well" I know. I'm sorry )

EDIT: i don't have a small idea on how to make it work. I followed the instructions, my values are correct, i followed the syntax of helicopter mod... but nothing to do it crashes the app or says that (it depends if I switch from self to self.object and if I remove yaw_to_dir)

I can't manage to get the turret facing the same way as the player horizontaly. It does wierd things. The Y axis of the player controls the rotation of the turret. WTF?

EDIT: after testing, i found that the API is not very well informed, coause it's not precised that set_attach() works with degrees, meanwhile all other functions works in radiant... which is a bit ilogical. Then if you use set_attach with the values of player:get_dir(), with the conversion from radiants to degrees... you will find that the XYZ axis from the player is different from the one of an attached entity. Example, the x of the player conresponds to the Y of the entity, which is a total absurdity.

azekill_DIABLO wrote:Example, the x of the player conresponds to the Y of the entity, which is a total absurdity.

As I know it's because entity have a bone too, but for example Blender have by default opposite axis orientation or something like this.

I am a noob.still yet. Not so noob ) [vml] WIP and a little proof for fun PlantedTorch )))MT Strike 78a36b468554d101e0be3b0d1f587a555f396452 Great! Somebody have found it ) "My english isn't well" I know. I'm sorry )

azekill_DIABLO wrote:Example, the x of the player conresponds to the Y of the entity, which is a total absurdity.

As I know it's because entity have a bone too, but for example Blender have by default opposite axis orientation or something like this.

The "front" of a node or entity is entirely arbitrary. It's what you determine it to be. So if you made a tank entity in blender, and export it so that with yaw=0 it's cannon points south-east then that would be just fine and dandy.

So if you attach a player to an entity, and now things are looking weird, then that's probably because you didn't consistently declare "front" the same in between the entity and the player. Most likely you exported the entity in blender with incorrect axes. Try re-exporting the entity with different export axes, so that the models are consistent.

it's not a blender model. It's a voxel model and it's facing the right way, as far as i know.... the problem is that when i use rotation it rotates differently if i face a way and another. It's inverted sometimes... can you show me a bit of code that makes an attached entity face the same deirection as the player?

Entities in minetest are either static models (.obj) or animated (.x or .b3d). I don't care what program where used to create them, but the fundamentals are all the same - axes are arbitrary and exporting them incorrectly may cause strange directions.

So if you set the yaw of the player to 0, and the yaw of the entity to 0, are they facing the same way? and after attachment with those yaws?

In the floodables mod I want to make rails floodable so it's faster to pick them up using water instead of mining them.But when I add the above line in the floodable category it tells me that it's trying to overide a non-existent node. What am I supposed to do ?

I have a problem with this code I can't get an object attached to another entity face the same way as the player... can you help me, please, I did all I could, but I can't find an issue to that... Thanks!

EDIT: neverming, it was a - instead of a + at the problmatic line xD, that five days i'm working on that, i never been so happy! yeeee!

here mean that it's deprecated to use the "initial_properties" field that is directly beyond this and the reason for that is that now everything in object properties is read directly from here or that it's deprecated that everything in object properties is read directly from there?I thought I had understood it correctly but now I'm not sure, maybe I'm doing it always wrong. >_<

Do not call me -minetest.Call me DS or DS-minetest.I am German, so you don't have to pm me English if you are also German.The background is a lie.

Title: How to create a function that unlock a craft and only for one person ?Reason: I want to make a research mod like in the minecraft mod Ancient Warfare 2More info: I have already do the interface but I don't know how to do this.

Sorry if my english isn't good.I love making mesecon mechanisms. If you want a system, just tell it to me and I will try to make it.

Baryhobal wrote:Title: How to create a function that unlock a craft and only for one person ?Reason: I want to make a research mod like in the minecraft mod Ancient Warfare 2More info: I have already do the interface but I don't know how to do this.

You will have to do more than just make one function. Minetest doesn't have any built-in craft recipe unlocking mechanism so you will have to write it yourself (I assume the same thing is true for Minecraft).

First of all, you will need to keep track of what recipes the player has access to. I would recommend representing this as a "set" (a table where the keys are the values in the set, and the values are all true) of the names of the recipe output items. You can store it as a player attribute using the set_attribute and get_attribute methods of players (https://github.com/minetest/minetest/bl ... .txt#L3279) to store the table after turning it into a string with minetest.write_json (https://github.com/minetest/minetest/bl ... .txt#L2979).

Secondly, to actually prevent the player from crafting the unlockable items, you will need to intercept the crafting attempts and prevent that craft from happening. For this you will need to use minetest.register_on_craft and minetest.register_craft_predict (https://github.com/minetest/minetest/bl ... .txt#L2347). In the callback you pass to register_on_craft, you would check if the player has access to the item, and if not, return an empty ItemStack. If they have access to the item then you let it be (return nil or the original ItemStack). The callback you pass to register_craft_predict should do the same thing (just pass the same function to both).

After you have done all that you can write a function that unlocks a craft for a player, by getting the attribute that stores the unlock table, deserializing it (with minetest.parse_json), adding the item name, then serializing it and storing it back again to the attribute.