Post your modding questions here

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

Re: Post your modding questions here

by Nyarg » Sun Dec 25, 2016 23:33

I need help.

I create simple entity.
Now I need add to instance some metadata. How I may to do it ?
Next line I need read metadata. How I may to do it ?

like at concept
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_on_punchnode
  minetest.add_entity(proto)   --- instance 1 of proto
  minetest.add_entity(proto)   --- instance 2
  ??? add some meta into instance 1
  ??? add some different meta into instance 2
  ??? read added meta from instance 1
end
I am a noob. still yet. Not so noob ) [vml] WIP
"My english isn't well" I know. I'm sorry )
 

User avatar
Napiophelios
Member
 
Posts: 752
Joined: Mon Jul 07, 2014 01:14
GitHub: Napiophelios
IRC: Nappi
In-game: Nappi

Re: Post your modding questions here

by Napiophelios » Mon Dec 26, 2016 01:10

sofar wrote:
Napiophelios wrote:it just didn't seem to work with minetest.add_node
works fine with minetest.place_node


add_node ignores any placement defaults, so you have to do

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.add_node(pos, {name = "plant:name", param2 = 1})


instead.


Thank You :)
 

User avatar
DS-minetest
Member
 
Posts: 707
Joined: Thu Jun 19, 2014 19:49
GitHub: DS-Minetest
In-game: DS

Re: Post your modding questions here

by DS-minetest » Mon Dec 26, 2016 09:43

@Nyarg:
  • give the entities names:
    Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
    Code: Select all
        minetest.register_on_punchnode
          a = minetest.add_entity(proto)   --- instance 1 of proto
          b = minetest.add_entity(proto)   --- instance 2
          ??? add some meta into a
          ??? add some different meta into b
          ??? read added meta from a
        end

  • as much as i know you cant save metadata in entities but you could save something in staticdata
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
orwell
Member
 
Posts: 467
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
In-game: orwell

Re: Post your modding questions here

by orwell » Mon Dec 26, 2016 19:25

Nyarg wrote:I need help.

I create simple entity.
Now I need add to instance some metadata. How I may to do it ?
Next line I need read metadata. How I may to do it ?

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_on_punchnode
  minetest.add_entity(proto)   --- instance 1 of proto
  minetest.add_entity(proto)   --- instance 2
  ??? add some meta into instance 1
  ??? add some different meta into instance 2
  ??? read added meta from instance 1
end

add_entity() returns an ObjectRef
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local object=minetest.add_entity(pos, name)

You can get it's luaentity (the lua table that is "self" in entity functions)
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local luaentity=object:get_luaentity()

now you can write stuff into it.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
luaentity.foo="bar"
print(luaentity.bababap)
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

User avatar
DS-minetest
Member
 
Posts: 707
Joined: Thu Jun 19, 2014 19:49
GitHub: DS-Minetest
In-game: DS

Re: Post your modding questions here

by DS-minetest » Mon Dec 26, 2016 20:04

ExeterDad wrote:
sofar wrote:
DS-minetest wrote:is there a way to give two or more different textures to an entities with mesh at once, some sides the one texture, some the other one?


yes, as long as the model has the proper 2 materials defined. Use `textures = { texture1, texture2},` (off the top of my head)

That is correct

I would guess most models used in Minetest (think mobs) only contain one material though. A work around could be to overlay another texture to add something. For example if you wanted to give Sam a black eye, you would assign character.png^black_eye.png

The black eye texture would be exactly the same size as character.png. It would be transparent with a black eye drawn where Sams eye would be.

thanks for the answers but im a bit confused in materials
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
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: Post your modding questions here

by D00Med » Mon Dec 26, 2016 21:43

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local minp = {x=pos.x-5, y=pos.y, z=pos.z-5}
local maxp = {x=pos.x+5, y=pos.y, z=pos.z+5}
local doors = minetest.find_nodes_in_area(minp, maxp, "group:door")
for i = 1, #doors do
   local dpos = {x=doors[i].x, y=doors[i].y, z=doors[i].z}
   local door = doors.get(dpos)
   door:toggle(player)
end

Why does this keep crashing the game? I get this error: "attempt to call field 'get' (a nil value)"
It doesn't happen when there is no door in the area. I did get it to work after using only one position.
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

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

Re: Post your modding questions here

by Nyarg » Tue Dec 27, 2016 00:09

D00Med wrote:error: "attempt to call field 'get' (a nil value)"

??? doors:get(dpos) VS doors.get(dpos) VS doors.get[dpos]
I am a noob. still yet. Not so noob ) [vml] WIP
"My english isn't well" I know. I'm sorry )
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: Post your modding questions here

by D00Med » Tue Dec 27, 2016 02:22

doors:get(dpos) won't work, it isn't a real method.
doors.get[dpos] I don't know, I'm pretty sure square brackets can't be used for that sort of thing.
The code, by the way, was mostly copied from xdecor, and it worked fine for that.
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

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

Re: Post your modding questions here

by sofar » Tue Dec 27, 2016 04:08

D00Med wrote:Why does this keep crashing the game? I get this error: "attempt to call field 'get' (a nil value)"


Did you forget to add `doors` to `depends.txt` ?
 

User avatar
TumeniNodes
Member
 
Posts: 1335
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes

Re: Post your modding questions here

by TumeniNodes » Tue Dec 27, 2016 04:14

sofar wrote:
D00Med wrote:Why does this keep crashing the game? I get this error: "attempt to call field 'get' (a nil value)"


Did you forget to add `doors` to `depends.txt` ?


ehem... speaking of doors. Would anyone be able to give the nodebox/selection box coords to set doors to the center of blocks, and when open they come a bit into the next node space?
I realize not many like the idea but I would like it for personal use and I do not know how to use the / positions I'm to used to 0.5 type positions.
I already tried it a few times and cannot get it to work, I think mainly due to the hidden part for the hinges.
I also realize some may feel this will break things but I will take full blame on myself if it does :P
Flick?... Flick who?
 

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

Re: Post your modding questions here

by sofar » Tue Dec 27, 2016 04:28

TumeniNodes wrote: ehem... speaking of doors. Would anyone be able to give the nodebox/selection box coords to set doors to the center of blocks, and when open they come a bit into the next node space?
I realize not many like the idea but I would like it for personal use and I do not know how to use the / positions I'm to used to 0.5 type positions.
I already tried it a few times and cannot get it to work, I think mainly due to the hidden part for the hinges.
I also realize some may feel this will break things but I will take full blame on myself if it does :P


it's entirely possible - this is how the fence gate works. But yes, the top door part is an issue, you'll have to make a top door half to create the proper collision box.
 

User avatar
TumeniNodes
Member
 
Posts: 1335
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes

Re: Post your modding questions here

by TumeniNodes » Tue Dec 27, 2016 05:30

sofar wrote:
TumeniNodes wrote: ehem... speaking of doors. Would anyone be able to give the nodebox/selection box coords to set doors to the center of blocks, and when open they come a bit into the next node space?
I realize not many like the idea but I would like it for personal use and I do not know how to use the / positions I'm to used to 0.5 type positions.
I already tried it a few times and cannot get it to work, I think mainly due to the hidden part for the hinges.
I also realize some may feel this will break things but I will take full blame on myself if it does :P


it's entirely possible - this is how the fence gate works. But yes, the top door part is an issue, you'll have to make a top door half to create the proper collision box.


Thank you sofar, I'll give it a try again.
Flick?... Flick who?
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: Post your modding questions here

by D00Med » Tue Dec 27, 2016 06:18

sofar wrote:Did you forget to add `doors` to `depends.txt` ?

Nope, it's there.
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

User avatar
DS-minetest
Member
 
Posts: 707
Joined: Thu Jun 19, 2014 19:49
GitHub: DS-Minetest
In-game: DS

Re: Post your modding questions here

by DS-minetest » Tue Dec 27, 2016 10:42

D00Med wrote:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local minp = {x=pos.x-5, y=pos.y, z=pos.z-5}
local maxp = {x=pos.x+5, y=pos.y, z=pos.z+5}
local doors = minetest.find_nodes_in_area(minp, maxp, "group:door")
for i = 1, #doors do
   local dpos = {x=doors[i].x, y=doors[i].y, z=doors[i].z}
   local door = doors.get(dpos)
   door:toggle(player)
end

Why does this keep crashing the game? I get this error: "attempt to call field 'get' (a nil value)"
It doesn't happen when there is no door in the area. I did get it to work after using only one position.

maybe you should name the table not doors, like this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local minp = {x=pos.x-5, y=pos.y, z=pos.z-5}
local maxp = {x=pos.x+5, y=pos.y, z=pos.z+5}
local doorss = minetest.find_nodes_in_area(minp, maxp, "group:door")
for i = 1, #doorss do
   local dpos = {x=doorss[i].x, y=doorss[i].y, z=doorss[i].z}
   local door = doors.get(dpos)
   door:toggle(player)
end
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.
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

by Hybrid Dog » Tue Dec 27, 2016 16:32

Alternatively you could use following:
local door = _G.doors.get(dpos)
 

JackWilliam
Member
 
Posts: 10
Joined: Tue Dec 27, 2016 14:41

Re: Post your modding questions here

by JackWilliam » Tue Dec 27, 2016 17:25

Topic: How to add texture
Reason: I have an error
More Info(optional): hello everyone . I followed the tutorial but I don't understand. I call the image tutorial_decowood end the code is that :
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_node("tutorial:decowood", {
   tile_images = {"tutorial_decowood.png"},
   groups={level=1},
})

and the error is :
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
ERROR[main]: generateImage(): could not load image "tutorial_decowood.png" while building texture
ERROR[main]:  generateImage(): Creating a dummy image for "tutorial_decowood.png"


Can anyone help me?
 

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

Re: Post your modding questions here

by sofar » Tue Dec 27, 2016 19:34

DS-minetest wrote:maybe you should name the table not doors


ahh yeah, I didn't spot that error. You just overwrote the `doors` global this way.

This kind of programming stuff can be found by luacheck. I strongly recommend you start learning how to use it - it really helps you find bugs early.
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: Post your modding questions here

by D00Med » Tue Dec 27, 2016 19:58

Oh ok, thankyou
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

User avatar
DS-minetest
Member
 
Posts: 707
Joined: Thu Jun 19, 2014 19:49
GitHub: DS-Minetest
In-game: DS

Re: Post your modding questions here

by DS-minetest » Wed Dec 28, 2016 11:41

@JackWilliam:
as you can see in lua_api.txt line 3713:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
tiles = {tile definition 1, def2, def3, def4, def5, def6}, --[[
^ Textures of node; +Y, -Y, +X, -X, +Z, -Z (old field name: tile_images)
^ List can be shortened to needed length ]]

=> its called "tiles", not "tile_images"
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.
 

JackWilliam
Member
 
Posts: 10
Joined: Tue Dec 27, 2016 14:41

Re: Post your modding questions here

by JackWilliam » Wed Dec 28, 2016 17:54

thanks DS-minetest, I have modified the code, but the error is still there.
the node in game is like this:
error.PNG
error.PNG (757.56 KiB) Viewed 7181 times

and the color change when I restart minetest or when I try to mine the node.
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Post your modding questions here

by Krock » Wed Dec 28, 2016 19:04

JackWilliam wrote:and the color change when I restart minetest or when I try to mine the node.

This error happens when the texture could not be found.
Check or create a texture at the location mods/tutorial/textures/tutorial_decowood.png. Make sure it's exactly that path, otherwise Minetest will not be able to find the texture.
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
Tmanyo
Member
 
Posts: 151
Joined: Mon Sep 29, 2014 01:20
GitHub: Tmanyo
IRC: Tmanyo
In-game: tmanyo

Re: Post your modding questions here

by Tmanyo » Wed Dec 28, 2016 21:35

Is there a way to tie detached inventories into meta data?
Tmanyo
http://rrhmsservers.weebly.com/
Servers I Host:
Xtremetest
Vault-81
 

JackWilliam
Member
 
Posts: 10
Joined: Tue Dec 27, 2016 14:41

Re: Post your modding questions here

by JackWilliam » Wed Dec 28, 2016 23:06

Krock wrote:This error happens when the texture could not be found.
Check or create a texture at the location mods/tutorial/textures/tutorial_decowood.png. Make sure it's exactly that path, otherwise Minetest will not be able to find the texture.

Yes I know but the path is correct. Can be the editor?? I use Geany.
 

User avatar
Napiophelios
Member
 
Posts: 752
Joined: Mon Jul 07, 2014 01:14
GitHub: Napiophelios
IRC: Nappi
In-game: Nappi

Re: Post your modding questions here

by Napiophelios » Thu Dec 29, 2016 00:07

try making a folder in the texture pack directory and place the image there too.
then select your new "texture pack" when you start the game.

Almost every time I get this error it's because I mispelt something somewhere.
 

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

Re: Post your modding questions here

by Nyarg » Thu Dec 29, 2016 04:21

DS-minetest wrote:as much as i know you cant save metadata in entities but you could save something in staticdata

It's looks like metadata ~= staticdata ?

orwell wrote: ... ObjectRef
... get it's luaentity (the lua table that is "self" ...)
... write stuff into it.


Thank you all now it works )
But little question still yet. What exactly data of entity will be saved in world file when server shutdown ?
Is wiki have somewhere the explanation what data structures will be save ?

Some mods and get_staticdata() seems like only scripter need carry about save and init each entity with unique data.
I am a noob. still yet. Not so noob ) [vml] WIP
"My english isn't well" I know. I'm sorry )
 

User avatar
DS-minetest
Member
 
Posts: 707
Joined: Thu Jun 19, 2014 19:49
GitHub: DS-Minetest
In-game: DS

Re: Post your modding questions here

by DS-minetest » Thu Dec 29, 2016 10:55

to save data from the entity for the next load you use the get_staticdata function
return <what you need (only strings, to make tables to strings use minetest.de-/serialize, note: this doesnt work with userdata)>
then write into the on_activate(self, staticdata, dtime_s)
and use staticdata as the returned string
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.
 

ManElevation
Member
 
Posts: 213
Joined: Tue Aug 02, 2016 22:04
GitHub: ManElevation
IRC: ManElevation
In-game: ManElevation

Re: Post your modding questions here

by ManElevation » Fri Dec 30, 2016 04:42

can some one write a block lua script. just a plain block
with a {"front.png"} a {"side.png"} and a {"top.png"} {"back.png"}

a full one pleas
Hey there im going to be off minetest for a while because my company has been deleloping a game called Ground Conflict, if you wish to see some screenshots or have some info, than please join our discord server https://discord.gg/C9ygXJn
 

User avatar
Napiophelios
Member
 
Posts: 752
Joined: Mon Jul 07, 2014 01:14
GitHub: Napiophelios
IRC: Nappi
In-game: Nappi

Re: Post your modding questions here

by Napiophelios » Fri Dec 30, 2016 12:28

ManElevation wrote:can some one write a block lua script. just a plain block
with a {"front.png"} a {"side.png"} and a {"top.png"} {"back.png"}
a full one pleas


test_node.zip
basic block nodes
(124.31 KiB) Downloaded 181 times

Image
basic_blocks.png
basic_blocks.png (174.38 KiB) Viewed 7181 times
 

User avatar
GreenDimond
Member
 
Posts: 460
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
IRC: GreenDimond
In-game: GreenDimond

Re: Post your modding questions here

by GreenDimond » Fri Dec 30, 2016 23:42

For my Sandplus Mod, I would like to add an ability to have a recipe canceled and replaced with a grinder recipe if the technic mod is enabled. I know I would have to use something along the lines of "if minetest.get_modpath("technic") then...", and somewhere in there the technic grinding recipe (table.insert(recipes, {"modname:node1", "modname:node2"})), but I don't know how to do this. Help?
EDIT: I think I got it :P
I am Green. I tend to binge-post. "All of this over a 16x16 representation of a cartoon cat ?!?! what has this world come to..." -TenPlus1, 2017.
Diz mah mods! :D ↑ github.com/minetest/minetest_game/issues/1647#issuecomment-288134572 ↑
Sand Plus - Tac Nayn - Waffles - Coming Soon: Caverealms Plus
 

User avatar
BrunoMine
Member
 
Posts: 902
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine

Re: Post your modding questions here

by BrunoMine » Mon Jan 02, 2017 20:27

Is there a way to track the status of a player?

For example, if the player is in a car, bed, boat, helicoter and others.

Is there a unified way of checking this sort of thing?
I'd like to know how to control these things to prevent a player from being able to make and control multiple cars simultaneously, or even crash the server.
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron