Post your modding questions here

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

Re: Post your modding questions here

by azekill_DIABLO » Post

Okay thanks!

Code: Select all

--start registering things
minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing, tiles)
	local node = minetest.get_node_or_nil(pointed_thing.under)
	local tilenode = minetest.registered_nodes[node.name].tiles
	print(tilenode[1])
		minetest.add_particlespawner({
			amount = 54,
			time = 0.40,
			minpos = {pos},
			maxpos = {pos},
			minvel = {x = -1, y = -1, z = -1},
			maxvel = {x = 1,  y = 1,  z = 1},
			minacc = {x = -1, y = -4, z = -1},
			maxacc = {x = 1, y = -3, z = 1},
			minexptime = 1,
			maxexptime = 4,
			minsize = 0.5,
			maxsize = 1,
			texture = tilenode[1],
		})
end)
i done something wrong...
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

User avatar
Krock
Developer
Posts: 4650
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: Post your modding questions here

by Krock » Post

ozkur wrote:

Code: Select all

player:getpos(p)
        player:setpos({p.x, 25000, p.z})
.
"getpos" returns a table, takes no arguments. And then again the same coordinate table issue with "setpos". This is how your code could look like:

Code: Select all

local p = player:getpos(p)
player:setpos({x = p.x, y = 25000, z = p.z})

-- Or alternatively
local p = player:getpos(p)
p.y = 25000
player:setpos(p)
azekill_DIABLO wrote:i done something wrong...
You did not replace "{node}" with "pos", as I wrote earlier. Remove the brackets, so it will look this way:

Code: Select all

         minpos = pos,
         maxpos = pos,
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

ozkur
Member
Posts: 180
Joined: Wed Oct 07, 2015 20:59
In-game: ozkur or XoRoUZ
Location: 6 minutes in the future

Re: Post your modding questions here

by ozkur » Post

Krock wrote:
ozkur wrote:

Code: Select all

player:getpos(p)
        player:setpos({p.x, 25000, p.z})
.
"getpos" returns a table, takes no arguments. And then again the same coordinate table issue with "setpos". This is how your code could look like:

Code: Select all

local p = player:getpos(p)
player:setpos({x = p.x, y = 25000, z = p.z})

-- Or alternatively
local p = player:getpos(p)
p.y = 25000
player:setpos(p)
azekill_DIABLO wrote:i done something wrong...
You did not replace "{node}" with "pos", as I wrote earlier. Remove the brackets, so it will look this way:

Code: Select all

         minpos = pos,
         maxpos = pos,
thanks again!!
Biplanes! 'Nuff said

I am a native English speaker, Ich spreche kein Deuscht, mais je parle un pue français.

PlanetKiller
Member
Posts: 14
Joined: Mon Nov 23, 2015 22:50

Re: Post your modding questions here

by PlanetKiller » Post

I'm doing some tests with node data, and writing down my findings, but I came across an error.
Here is my tools.lua script in my sketchy mod:

Code: Select all



minetest.register_tool("sketchy:meta_rod", {
	description = "Meta Rod",
	
	inventory_image = "sketchy_meta.png",
	
	on_use = function(itemstack, user, pointed_thing)

		local name = user:get_player_name() 		
		local point = pointed_thing.under
		
		if point then -- check if it is a node/exists 
			local meta = minetest.get_meta(point)
			local tabe = meta:to_table()
			print(dump(meta:to_table()))
			--print(user)
			--print(tabe)
			if minetest.serialize(tabe) then
				local output = minetest.serialize(tabe)
				print(output)
			end
		end
	end

})

Both minetest.serialize(tabe) and print(dump(meta:to_table())) throw a massive error (Can't serialize data of type userdata) when I strike anything with an inventory (furnace, shelves, ect.).
Is this a bug, or is there a graceful way to catch this error?
I'd like to be able to see/change metadata on blocks, even give them metadata on generation.
I'm thinking about swapping the tilled soil with something that can track soil fertility/toxicity.
([noun].. " tried to " ..[verb]..[noun].. " at protected position "..[noun].. " with a bucket")

User avatar
Krock
Developer
Posts: 4650
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: Post your modding questions here

by Krock » Post

PlanetKiller wrote:Both minetest.serialize(tabe) and print(dump(meta:to_table())) throw a massive error (Can't serialize data of type userdata) when I strike anything with an inventory (furnace, shelves, ect.).
Interesting. I'm getting the same error. The stacks seem to be returned as an ItemStack, thus not possible to serialize (Minetest does not know what for an object type it is).

Code: Select all

        inventory = {
                fuel = {
                        <userdata>
                },
                dst = {
                        <userdata>,
                        <userdata>,
                        <userdata>,
                        <userdata>
                },
                src = {
                        <userdata>
                }
        }
}
2016-10-17 19:16:46: ERROR[Main]: ServerError: Lua: Runtime error from mod 'test' in callback Script
ApiItem::item_OnUse(): E:\Programme\minetest\bin\..\builtin\common\serialize.lua:151: Can't serializ
e data of type userdata
2016-10-17 19:16:46: ERROR[Main]: stack traceback:
2016-10-17 19:16:46: ERROR[Main]:       [C]: in function 'error'
2016-10-17 19:16:46: ERROR[Main]:       E:\Programme\minetest\bin\..\builtin\common\serialize.lua:15
1: in function 'dump_or_ref_val'
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

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

Re: Post your modding questions here

by azekill_DIABLO » Post

Krock wrote:
ozkur wrote:

Code: Select all

player:getpos(p)
        player:setpos({p.x, 25000, p.z})
.
"getpos" returns a table, takes no arguments. And then again the same coordinate table issue with "setpos". This is how your code could look like:

Code: Select all

local p = player:getpos(p)
player:setpos({x = p.x, y = 25000, z = p.z})

-- Or alternatively
local p = player:getpos(p)
p.y = 25000
player:setpos(p)
azekill_DIABLO wrote:i done something wrong...
You did not replace "{node}" with "pos", as I wrote earlier. Remove the brackets, so it will look this way:

Code: Select all

         minpos = pos,
         maxpos = pos,
thnkas!
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

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

Re: Post your modding questions here

by BirgitLachner » Post

I wanted to have a formspec defintion where I show some parts depending on a variable. Something like ...

Code: Select all

  			minetest.show_formspec(player_name, "turtleminer:turtle_formspec",
  				"size[9,4]" ..
  				"label[0,0;Click buttons to move the turtle around!]" ..
  				"button_exit[5,1;2,1;exit;Exit]" ..
  				"image_button[1,1;1,1;turtleminer_remote_arrow_up.png;up;]" ..
  				"image_button[2,1;1,1;turtleminer_remote_arrow_fw.png;forward;]"
  				if number >= 3 then 
					"..button[3,1;2,1;digfront;dig front]" ..
					"button[3,3;2,1;digbottom;dig under]" ..
				end
  				"image_button[1,2;1,1;turtleminer_remote_arrow_left.png;turnleft;]"..
  				"image_button[3,2;1,1;turtleminer_remote_arrow_right.png;turnright;]" ..
  				"image_button[1,3;1,1;turtleminer_remote_arrow_down.png;down;]" ..
  				"image_button[2,3;1,1;turtleminer_remote_arrow_bw.png;backward;]"
  				--.. "button[3,3;1,1;build;build]"
  				)
I will have about 5 different possibilites for nearly the same formspecs and it would the best, if I can handle it with one code and only some if-statements.

Thanks!

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

Re: Post your modding questions here

by azekill_DIABLO » Post

then use on-reicive_field (oh my orthograph) for activing things after pushing button.
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

bell07
Member
Posts: 604
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: Post your modding questions here

by bell07 » Post

BirgitLachner wrote:I wanted to have a formspec defintion where I show some parts depending on a variable
just concatenate the string, like

Code: Select all

local spec = "size[9,4]"
spec = spec.."label[0,0;Click buttons to move the turtle around!]"
if something then
   spec=spec.."button1[]"
else
  spec=spec.."otherbutton[]"
end
 minetest.show_formspec(player_name, "turtleminer:turtle_formspec",spec)

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

Re: Post your modding questions here

by BirgitLachner » Post

Thanks @bell07

amadin
Member
Posts: 549
Joined: Tue Jun 16, 2015 16:23

Re: Post your modding questions here

by amadin » Post

Hi all. Why looking through the transparent texture of colored glass, I do not see another colored glass? This is not always observed-effect (for example this depend on the sequence of different blocks installation), but with some laws. It seems this bug is for different mods with transparent blocks (for example caverealms). I use the code from "xpanes" mod from minetest_game for colored glass. Also this effect available in this mod too viewtopic.php?f=9&t=10456&hilit=glass
Image
Image
Last edited by amadin on Fri Oct 21, 2016 19:53, edited 3 times in total.

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

Re: Post your modding questions here

by azekill_DIABLO » Post

links broken sorry.
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

amadin
Member
Posts: 549
Joined: Tue Jun 16, 2015 16:23

Re: Post your modding questions here

by amadin » Post

azekill_DIABLO wrote:links broken sorry.
Fixed

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

Re: Post your modding questions here

by azekill_DIABLO » Post

Still broken.
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

User avatar
rubenwardy
Moderator
Posts: 6977
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: Post your modding questions here

by rubenwardy » Post

partial transparency doesn't work very well
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

amadin
Member
Posts: 549
Joined: Tue Jun 16, 2015 16:23

Re: Post your modding questions here

by amadin » Post

rubenwardy wrote:partial transparency doesn't work very well
Maybe is another method for colored glass?

amadin
Member
Posts: 549
Joined: Tue Jun 16, 2015 16:23

Re: Post your modding questions here

by amadin » Post

In brewing stand i have one inv:set_size("src", 2) slot for 2 different ingredients (it looks like 2 slots). How check ingredient in the src slot is from my mod or not from my mod, even if placed only one ingredient? Source here http://github.com/amadin/lottpotion/blo ... rewing.lua

User avatar
taikedz
Member
Posts: 698
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: Post your modding questions here

by taikedz » Post

Heyaz

I am trying to define a chest and need to add funcitonality to prevent taking/putting certain items. For now I am testing with this:

Code: Select all

minetest.register_node("interchest:wormhole_chest", {
        description = "Wormhole Chest",
        on_construct = function(pos)
                local meta = minetest.get_meta(pos)
                meta:set_string("formspec",
                                "size[8,9]"..
                                "list[current_player;interchest:wormhole;0,0;8,4;]"..
                                "list[current_player;main;0,5;8,4;]" ..
                                "listring[current_player;interchest:wormhole]" ..
                                "listring[current_player;main]")
                meta:set_string("infotext", "Wormhole Chest")
        end,
        allow_metadata_inventory_put = function(pos, listname, index, stack, player)
                --minetest.chat_send_all(dump(stack))
                return 0 -- deny
        end,
        allow_metadata_inventory_take = function(pos, listname, index, stack, player)
                --minetest.chat_send_all(dump(stack))
                return 0 -- deny
        end,
})
You can see that for now I have defined "return 0" for the put and take callbacks

However these do not seem to get called at all.... I can happily transfer items to and from the chest , even though I expect the return 0 to cause a denial. The chats aren't printed when de-commented either.

Tried in singleplayer, and in multi-player modes...

User avatar
orwell
Member
Posts: 958
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell
Location: Raxacoricofallapatorius

Re: Post your modding questions here

by orwell » Post

You see, the inventory location of your 'interchest' inventory is 'current_player'. This inventory belongs to the player and not to the node, so the node callbacks aren't called. AFAIK you can't override allow_* methods for the player inventory. Try to use a detached inventory and set the allow_* methods there.
Approach (not approved)

Code: Select all

register_detached_inventory("interchest_"..pname, {
     allow_put=function (whatever) return 0 end,
     allow_take=function (whatever) return whatelse end,
})
--and
meta:set_string("formspec", "... list[detached:interchest_"..pname..";a,s,o]  ..."
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

User avatar
stu
Member
Posts: 923
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11
Location: United Kingdom

Re: Post your modding questions here

by stu » Post

taikedz wrote: I can happily transfer items to and from the chest , even though I expect the return 0 to cause a denial. The chats aren't printed when de-commented either.
If you make changes to a node's formspec after placement then those changes will not take effect until you re-place the node causing on_construct to be re-called. Could that be the problem?

User avatar
taikedz
Member
Posts: 698
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: Post your modding questions here

by taikedz » Post

stu - whilst that was a relevant remakr, it did not resolve the prolem

orwell, I adjusted your code to match what I have, and after digging/replacing the blocks I have.... no chest inventory. Blank space above my player inventory...

Code: Select all

minetest.register_node("interchest:wormhole_chest", {
        description = "Wormhole Chest",                  
        paramtype2 = "facedir", 
        groups = {oddly_breakable_by_hand=2,choppy=3},
        after_place_node = function(pos,player,itemstack,pointedthing)
                local meta = minetest.get_meta(pos)
                local pname = player:get_player_name()
                meta:set_string("formspec",
                                "size[8,9]"..
                                "list[detached;interchest_"..pname..";0,0;8,4;]"..
                                "list[current_player;main;0,5;8,4;]" ..
                                "listring[detached;interchest_"..pname.."]" ..
                                "listring[current_player;main]")
                meta:set_string("infotext", "Wormhole Chest")
        end,
})

minetest.register_on_joinplayer(function(player)
        local pname = player:get_player_name()
        minetest.create_detached_inventory("interchest_"..pname, {
                allow_put=function (inv, listname, index, stack, player) return 0 end,
                allow_take=function (inv, listname, index, stack, player) return 0 end,
        })
end)


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

Re: Post your modding questions here

by hajo » Post

Some mods have a file mod.conf, but I found no documentation about that file and its usage.

Can someone explain, or give a pointer to more info ?

User avatar
kaeza
Moderator
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza
Location: Montevideo, Uruguay
Contact:

Re: Post your modding questions here

by kaeza » Post

hajo wrote:Some mods have a file mod.conf, but I found no documentation about that file and its usage.

Can someone explain, or give a pointer to more info ?
It's a text file containing mod metadata.

At the moment, only the `name` field is used. The engine uses this as the mod's "internal" name. If this is not present, the engine uses the directory name.

Simply create such a file with:

Code: Select all

name = my_mod_name
See also: This topic, original proposal, issue #2201.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal

amadin
Member
Posts: 549
Joined: Tue Jun 16, 2015 16:23

Re: Post your modding questions here

by amadin » Post

deleted. understood by himself

User avatar
orwell
Member
Posts: 958
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell
Location: Raxacoricofallapatorius

Re: Post your modding questions here

by orwell » Post

taikedz wrote:stu - whilst that was a relevant remakr, it did not resolve the prolem

orwell, I adjusted your code to match what I have, and after digging/replacing the blocks I have.... no chest inventory. Blank space above my player inventory...

Code: Select all

minetest.register_node("interchest:wormhole_chest", {
        description = "Wormhole Chest",                  
        paramtype2 = "facedir", 
        groups = {oddly_breakable_by_hand=2,choppy=3},
        after_place_node = function(pos,player,itemstack,pointedthing)
                local meta = minetest.get_meta(pos)
                local pname = player:get_player_name()
                meta:set_string("formspec",
                                "size[8,9]"..
                                "list[detached;interchest_"..pname..";0,0;8,4;]"..
                                "list[current_player;main;0,5;8,4;]" ..
                                "listring[detached;interchest_"..pname.."]" ..
                                "listring[current_player;main]")
                meta:set_string("infotext", "Wormhole Chest")
        end,
})

minetest.register_on_joinplayer(function(player)
        local pname = player:get_player_name()
        minetest.create_detached_inventory("interchest_"..pname, {
                allow_put=function (inv, listname, index, stack, player) return 0 end,
                allow_take=function (inv, listname, index, stack, player) return 0 end,
        })
end)

Please look anywhere how detached inventories work. It seems like the detached inventory has size 0. You need to set it somehow. I don't even know if my definition is right. This was just the approach, no working code.
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

Locked

Who is online

Users browsing this forum: No registered users and 5 guests