Post your modding questions here

Gerald
Member
 
Posts: 91
Joined: Sun Dec 28, 2014 10:35
Location: Germany
In-game: gerald7

Re: Post your modding questions here

by Gerald » Thu Aug 10, 2017 17:37

azekill_DIABLO wrote:
Code: Select all
ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'azewheel' in callback luaentity_Step(): ...ames\minetest-0.4.16-win64\bin\..\mods\azewheel/tank.lua:105: bad argument #1 to 'set_pos' (userdata expected, got table)


I have this error with that code, why? can you help me?

Code: Select all
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

try turret:set_pos(pos)
 

mezantrop
New member
 
Posts: 9
Joined: Fri Aug 04, 2017 07:59
Location: Brno, CZ
GitHub: mezantrop

Re: Post your modding questions here

by mezantrop » Fri Aug 11, 2017 14:34

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:

Code: Select all
second = minetest.add_entity(second_pos, "my_mod:two")
second.my_var = "ImportantValue"


Obviously, I'm failing to pass the value. I suppose it's because I don't know well neither LUA nor Minetest. Couldn't you give me a clue how to pass a variable?

I also tried to define a function to achieve the task:
Code: Select all
minetest.register_entity("my_mod:second", {

 ...

set_var = function()
self.my_var = "ImportantValue"
end,
})


and in on_activate() of the First run:

Code: Select all
second:set_var("ImportantValue")


but without any success.
 

mezantrop
New member
 
Posts: 9
Joined: Fri Aug 04, 2017 07:59
Location: Brno, CZ
GitHub: mezantrop

Re: Post your modding questions here

by mezantrop » Fri Aug 11, 2017 15:18

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 unloading
So what you need to do is:
1. the first object needs to hold all relevant data
2. 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 argument
3. "bone" just needs to be an empty string
4. the attachment position is the place where the second object is positioned relative to the first
Code: Select all
first's on_activate()
  local second=add_entity(...)
  local secondle=second:get_luaentity()
  secondle.first_reference=self
  second:set_attach(self.object, ...)

5.


I have missed your reply, thank you very much! It looks like now I'm struggling on the way to pass values between first and second objects. And it seems that:

Code: Select all
local secondle=second:get_luaentity()
secondle.first_reference=self

is the answer and the key to my last question and issue :) Thank you once more.
 

User avatar
v-rob
Member
 
Posts: 671
Joined: Thu Mar 24, 2016 03:19
Location: Right behind you.
GitHub: v-rob

How to fine tune schematics?

by v-rob » Sat Aug 12, 2017 05:17

So, I don't quite understand everything about schematics. I can make them, import them, and make them spawn in a world naturally (like trees), but there are a few points I don't understand.

----- How do you make a schematic override another node? Take grass for example. I made a tree a few weeks ago, but when it spawned on grass, the grass was still there instead of the tree trunk.

Like this:

| = tree trunk
M = grass
""""" = ground

I
I
M
"""""

I want the schematic to override the grass (or any node that might also be there, mushroom, farming plant, plantlife stuff, etc.) with the tree trunk, but I can't seem to.

----- I've looked at default trees, and there are multiple versions, but only one schematic file. How does this work? I want to make multiple variations of one tree, and I have no idea how to.
 

User avatar
azekill_DIABLO
Member
 
Posts: 7488
Joined: Wed Oct 29, 2014 20:05
Location: OMICRON
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Sat Aug 12, 2017 11:46

Gerald wrote:
azekill_DIABLO wrote:
Code: Select all
ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'azewheel' in callback luaentity_Step(): ...ames\minetest-0.4.16-win64\bin\..\mods\azewheel/tank.lua:105: bad argument #1 to 'set_pos' (userdata expected, got table)


I have this error with that code, why? can you help me?

Code: Select all
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

try turret:set_pos(pos)

oh, okay.

It does work! Thanks a lot!
 

User avatar
azekill_DIABLO
Member
 
Posts: 7488
Joined: Wed Oct 29, 2014 20:05
Location: OMICRON
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Sat Aug 12, 2017 17:18

problems with set attach

Code: Select all
   turret:set_attach(turret, "azewheel:tank", {x=0,y=0,z=0}, playeryaw)


returns

Code: Select all
 ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'azewheel' in callback luaentity_Step(): Invalid position (expected table got number).
 

Nyarg
Member
 
Posts: 276
Joined: Sun May 15, 2016 04:32

Re: Post your modding questions here

by Nyarg » Sat Aug 12, 2017 17:49

azekill_DIABLO wrote:
Code: Select all
  (expected table got number).
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 )
 

User avatar
cx384
Member
 
Posts: 498
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Post your modding questions here

by cx384 » Sat Aug 12, 2017 18:47

azekill_DIABLO wrote:problems with set attach

Code: Select all
   turret:set_attach(turret, "azewheel:tank", {x=0,y=0,z=0}, playeryaw)


returns

Code: Select all
 ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'azewheel' in callback luaentity_Step(): Invalid position (expected table got number).

I think this would work.
Code: Select all
   turret:set_attach(turret, "azewheel:tank", {x=0,y=0,z=0}, minetest.yaw_to_dir(playeryaw))
Can your read this?
 

User avatar
azekill_DIABLO
Member
 
Posts: 7488
Joined: Wed Oct 29, 2014 20:05
Location: OMICRON
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Sun Aug 13, 2017 10:46

i'll try, thank you!

EDIT: it crashes the game with no debug. (the window close with the Window$ error message "app has stopped working")

maybe a more detailed code should be helpful

Code: Select all
function tank_turret.on_step(self)
   local turret = self.object   
   turret:set_attach(turret, "azewheel:tank", {x=0,y=0,z=0}, minetest.yaw_to_dir(playeryaw))
end


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)
Code: Select all
(userdata expected, got table).

Code: Select all
(expected table got number).


EDIT: he is never happy. I cna't find doc on what I should do!

FINAL EDIT: i found a way out, it's all okay, except orientation, but i'm able to fix that! thanks!
 

User avatar
azekill_DIABLO
Member
 
Posts: 7488
Joined: Wed Oct 29, 2014 20:05
Location: OMICRON
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Sun Aug 13, 2017 14:59

Code: Select all
      local newdir = {x=0, y=playerdir.y, z=0}
      turret:set_attach(tankself, "", {x=0,y=10,z=0}, newdir)

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.

viewtopic.php?f=5&t=18296
 

Nyarg
Member
 
Posts: 276
Joined: Sun May 15, 2016 04:32

Re: Post your modding questions here

by Nyarg » Sun Aug 13, 2017 22:40

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 )
 

User avatar
azekill_DIABLO
Member
 
Posts: 7488
Joined: Wed Oct 29, 2014 20:05
Location: OMICRON
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Mon Aug 14, 2017 10:40

It remains a total absurdity because it seems impossible to use without workarounds...
 

sofar
Developer
 
Posts: 2059
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Post your modding questions here

by sofar » Mon Aug 14, 2017 17:17

Nyarg wrote:
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.
 

User avatar
azekill_DIABLO
Member
 
Posts: 7488
Joined: Wed Oct 29, 2014 20:05
Location: OMICRON
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Mon Aug 14, 2017 17:22

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?
 

sofar
Developer
 
Posts: 2059
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Post your modding questions here

by sofar » Mon Aug 14, 2017 17:41

azekill_DIABLO wrote:it's not a blender model. It's a voxel model and


What is a "Voxel model" ? This doesn't mean anything in minetest...

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?
 

User avatar
v-rob
Member
 
Posts: 671
Joined: Thu Mar 24, 2016 03:19
Location: Right behind you.
GitHub: v-rob

Re: Post your modding questions here

by v-rob » Mon Aug 14, 2017 19:05

How do I make a minecart force load chunks and them make them unload after it passes through? I'm pretty sure this has been made multiple times elsewhere, but I don't know how to.
 

User avatar
azekill_DIABLO
Member
 
Posts: 7488
Joined: Wed Oct 29, 2014 20:05
Location: OMICRON
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Tue Aug 15, 2017 09:40

sofar wrote:
azekill_DIABLO wrote:it's not a blender model. It's a voxel model and


What is a "Voxel model" ? This doesn't mean anything in minetest...

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?

oh, i said a voxel model, sorry. I mean a MagicaVoxel model. an .obj


Trying...

they seem to be facing the same way. A question now: isn't the dir of set_attach based on the dir of the parent object? I seem to have forgotten that...
 

User avatar
Lord_Vlad
Member
 
Posts: 112
Joined: Thu Jul 20, 2017 07:58

Re: Post your modding questions here

by Lord_Vlad » Tue Aug 15, 2017 11:06

Code: Select all
floodables = {
  { name = "carts:rail"},


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 ?
 

User avatar
azekill_DIABLO
Member
 
Posts: 7488
Joined: Wed Oct 29, 2014 20:05
Location: OMICRON
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Wed Aug 16, 2017 17:59

Code: Select all
      local tank360 = tankyaw*180/math.pi         -- tank yaw to degrees
      local player360 = playeryaw*180/math.pi     -- player yaw to degrees
      local turretdir = tank360+player360         -- the attach direction of the turret [CAUSE PROBLEM]
      local newdir = {x=0, y=turretdir, z=0}
      turret:set_attach(tankself, "", {x=0,y=6,z=0}, newdir)

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!
 

User avatar
DS-minetest
Member
 
Posts: 1107
Joined: Thu Jun 19, 2014 19:49
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.
GitHub: DS-Minetest
In-game: DS

Re: Post your modding questions here

by DS-minetest » Sat Aug 19, 2017 20:39

Does
lua_api.txt wrote:Deprecated: Everything in object properties is read directly from here
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.
 

User avatar
Baryhobal
Member
 
Posts: 17
Joined: Tue Nov 01, 2016 15:33
In-game: Baryhobal

Re: Post your modding questions here

by Baryhobal » Sun Aug 20, 2017 08:23

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 2
More 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.
 

Byakuren
Member
 
Posts: 816
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: Post your modding questions here

by Byakuren » Sun Aug 20, 2017 19:07

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 2
More 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.
Every time a mod API is left undocumented, a koala dies.
 

User avatar
Baryhobal
Member
 
Posts: 17
Joined: Tue Nov 01, 2016 15:33
In-game: Baryhobal

Re: Post your modding questions here

by Baryhobal » Mon Aug 21, 2017 03:56

Ok thanks I will try it
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.
 

User avatar
BirgitLachner
Member
 
Posts: 379
Joined: Thu May 05, 2016 10:18
In-game: Bibs

Re: Post your modding questions here

by BirgitLachner » Mon Aug 21, 2017 07:50

Hi again ...

I wanted to have a couple of nodes that are quite similar und want to use a function to register them easily. But I get an error wtha I dont understand. Here is my code:

Code: Select all
minetest.register_node("edusigns:symbol_1", {
   description = "Number 1",
    tiles = {"symbol_empty.png","symbol_empty.png","symbol_1.png","symbol_1.png","symbol_1.png","symbol_1.png"},
   groups = {oddly_breakable_by_hand=2},
})

minetest.register_node("edusigns:symbol_2", {
   description = "Number 1",
    tiles = {"symbol_empty.png","symbol_empty.png","symbol_2.png","symbol_2.png","symbol_2.png","symbol_2.png"},
   groups = {oddly_breakable_by_hand=2},
})


function edusigns.register_infonodes(what)
    minetest.register_node("edusigns:symbol_"..what, {
        description = "Number "..what,
        tiles = {"symbol_empty.png","symbol_empty.png","symbol_"..what..".png","symbol_"..what..".png","symbol_"..what..".png","symbol_"..what..".png"},
        groups = {oddly_breakable_by_hand=2},
    })
end   
   
edusigns.register_infonodes("3")


The first nodes are okay, but the function gives an error.
Code: Select all
 Undeclared global variable "edusigns" accessed at /home/birgit/.minetest/mods/edusigns/init.lua:14
2017-08-21 09:49:59: ERROR[Main]: ModError: Failed to load and run script from /home/birgit/.minetest/mods/edusigns/init.lua:
2017-08-21 09:49:59: ERROR[Main]: /home/birgit/.minetest/mods/edusigns/init.lua:14: attempt to index global 'edusigns' (a nil value)
2017-08-21 09:49:59: ERROR[Main]: stack traceback:
2017-08-21 09:49:59: ERROR[Main]:    /home/birgit/.minetest/mods/edusigns/init.lua:14: in main chunk


Line 14 is the "line" with "function ..."
What do I miss?

EDIT Got it ...
if I define
Code: Select all
edusigns={}

it works. I thought that "edusigns" is already there ...
 

hajo
Member
 
Posts: 596
Joined: Thu Oct 13, 2016 10:45
Location: DE

Re: Post your modding questions here

by hajo » Tue Aug 22, 2017 20:29

With entries in depends.txt it is possible for a mod to check if other needed mods are installed.

Is it possible to check for a minimum version of the minetest-engine (e.g."needs 0.4.16-dev") ?
 

PreviousNext

Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 7 guests