Post your modding questions here

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

Re: Post your modding questions here

by Napiophelios » Post

shouldn't it be:

Code: Select all

   minetest.clear_craft({
	output = "moreblocks:wood_tile 9",
	recipe = {
		{"default:wood", "default:wood", "default:wood"},
		{"default:wood", "default:wood", "default:wood"},
		{"default:wood", "default:wood", "default:wood"},
	}
})

FaceDeer
Member
Posts: 466
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: Post your modding questions here

by FaceDeer » Post

I actually just filed an issue over this behaviour of clear_craft, it's rather user-unfriendly of it to throw an exception when the craft you're trying to clear doesn't exist rather than just returning false. You can follow the issue here: https://github.com/minetest/minetest/issues/6513

As for a solution, you can wrap the call to clear_craft in a pcall() function like so:

Code: Select all

local success, err = pcall(function() minetest.clear_craft(parameter_recipe) end)
"success" will be a true/false success indicator and "err" will be an error string in the event that an exception is thrown.

User avatar
Lone_Wolf
Member
Posts: 2366
Joined: Sun Apr 09, 2017 05:50
GitHub: LoneWolfHT
IRC: Lone_Wolf or LoneWolfHT
In-game: Lone_Wolf
Location: Not there, THERE!

Re: Post your modding questions here

by Lone_Wolf » Post


User avatar
ManElevation
Member
Posts: 896
Joined: Tue Aug 02, 2016 22:04
GitHub: ManElevation
IRC: ManElevation
In-game: ManElevation
Location: Madrid,Spain

Re: Post your modding questions here

by ManElevation » Post

Need help, can someone one make this code work?
on kill give player gold.

Code: Select all

minetest.register_on_killplayer(
       function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
      local player_name = hitter:get_player_name()
     local inventory = hitter:get_inventory()
     inventory:add_item("main",{name="default:gold_ingot"})
         minetest.chat_send_player(player_name, '**You got gold!**')
      end
})
My Public Mods! Discord: Rottweiler Games#3368

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

Re: Post your modding questions here

by Krock » Post

ManElevation wrote:Need help, can someone one make this code work?
on kill give player gold.
First of all, register_on_killplayer does not exist. Instead, we've got a more generic callback register functions: minetest.register_on_player_hpchange and minetest.register_on_punchplayer. Whereas the latter one is interesting in his case, as it provides the puncher's name.
Here's how you could use it:

Code: Select all

minetest.register_on_punchplayer(function(player, hitter, _, _, _, damage)
	if not (hitter and hitter:is_player()) then
		return -- Punched by non-player
	end

	local hp = player:get_hp()
	if hp - damage > 0 or hp <= 0 then
		return -- Player is not dead yet or still dead
	end

	-- Player got killed by player 'hitter'
	local hitter_name = hitter:get_player_name()
	local player_name = player:get_player_name()

	local inv = hitter:get_inventory()
	inv:add_item("main", {name="default:gold_ingot"})

	minetest.chat_send_player(hitter_name, "** You killed " .. player_name
		.. ". Here, have a free gold ingot! **")
end)
Untested but will most likely work
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

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 » Post

Just a warning, that implementation would be exploitable in case a mod adds a way to block damage through register_on_player_hpchange.
Every time a mod API is left undocumented, a koala dies.

User avatar
burli
Member
Posts: 1641
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Post

What does "fertility" in the farming mod means?

Edit: got it.

User avatar
fishyWET
Member
Posts: 160
Joined: Tue Jan 01, 2013 07:43
GitHub: neinwhal
IRC: neinwhal
Location: Nowhere

Re: Post your modding questions here

by fishyWET » Post

EDIT: managed to fix first two issues, was a sily goof, removed them.

Is it possible to stop a minetest.after timer rather than countering it with another minetest.after timer that gives the opposite value?
Or perhaps a different method that isn't so "hacky"?

User avatar
Lejo
Member
Posts: 708
Joined: Mon Oct 19, 2015 16:32
GitHub: Lejo1
In-game: Lejo

Re: Post your modding questions here

by Lejo » Post

I tried to generate a trial of smoke from a player to another position.

Code: Select all

  local pos = player:getpos() ; pos.y = pos.y +1
  local goal = {x=0, y=0, z=0}
  local dir = vector.direction(pos, goal)
  local dis = vector.distance(pos, goal)
  minetest.add_particlespawner({
	amount = 15*dis,
   time = 1,
	minpos = pos,
   maxpos = pos,
   minvel = dis,
   maxvel = dis,
   minacc = dir,
	maxacc = dir,
	minexptime = 1,
	maxexptime = 1,
	minsize = 15,
	maxsize = 20,
	collisiondetection = false,
	vertical = false,
	texture = "tnt_smoke.png"
  })
The smoke should spawn at the player and disappears at position, but I don't know how to set minvel and maxvel.
Can someone help me?

User avatar
ShallowDweller
Member
Posts: 77
Joined: Thu Nov 02, 2017 22:23

Re: Post your modding questions here

by ShallowDweller » Post

sorry if this is the wrong place to ask, but i couldn't find this information anywhere (i googled, browsed github, checked the wiki...).

some mods have other dependencies than "default", but i can't figure out where to download some of said dependencies and there are many mods with similar names, so it is hard to tell if i found the right one. and i don't know if the uploaders are active in the forums (nor if necrobumping is forbiden).

the dependencies i need are the following:
"wool", "flowers", "stairs", "dye", "bucket" and "farming"*
*i belive i may have THIS one, but i'm not sure and i'd like to confirm.

the mods requesting them are:
carpet3d, compost bin and inventorybags.

Sires
Member
Posts: 188
Joined: Mon Jan 02, 2017 21:00
GitHub: Sires0
IRC: Sires
In-game: Sires Sores Siri Seris or anything ppl call me
Location: :noitacoL

Re: Post your modding questions here

by Sires » Post

ShallowDweller wrote:sorry if this is the wrong place to ask, but i couldn't find this information anywhere (i googled, browsed github, checked the wiki...).

some mods have other dependencies than "default", but i can't figure out where to download some of said dependencies and there are many mods with similar names, so it is hard to tell if i found the right one. and i don't know if the uploaders are active in the forums (nor if necrobumping is forbiden).

the dependencies i need are the following:
"wool", "flowers", "stairs", "dye", "bucket" and "farming"*
*i belive i may have THIS one, but i'm not sure and i'd like to confirm.

the mods requesting them are:
carpet3d, compost bin and inventorybags.
All this dependencies are included in the default Minetest Game subgame, if you are using another subgame that doesn't have them maybe the subgame was not made to have this mods or you would have to get this mods from the Minetest Game subgame
I don't have anything important to say.

User avatar
orwell
Member
Posts: 834
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

Lejo wrote:I tried to generate a trial of smoke from a player to another position.

Code: Select all

  local pos = player:getpos() ; pos.y = pos.y +1
  local goal = {x=0, y=0, z=0}
  local dir = vector.direction(pos, goal)
  local dis = vector.distance(pos, goal)
  minetest.add_particlespawner({
	amount = 15*dis,
   time = 1,
	minpos = pos,
   maxpos = pos,
   minvel = dis,
   maxvel = dis,
   minacc = dir,
	maxacc = dir,
	minexptime = 1,
	maxexptime = 1,
	minsize = 15,
	maxsize = 20,
	collisiondetection = false,
	vertical = false,
	texture = "tnt_smoke.png"
  })
The smoke should spawn at the player and disappears at position, but I don't know how to set minvel and maxvel.
Can someone help me?
These are velocity vectors. As far as I can tell from your code, the particles need to make the distance dis (which is a scalar) within 1 second. Because minvel and maxvel are vectors, they tell the velocity and the movement direction at the same time.
You can think of this as follows:
In one second, the particle moves exactly one time the vector's length along the velocity vector, so it's position is then vector.add(pos, vel) (in Minetest semantics)
After 2 seconds, it's vector.add(pos, vector.multiply(vel, 2)) a.s.o.
Because your particles have to move along the vector vector.subtract(goal, pos) in exactly 1 second, your velocity vector (minvel and maxvel) is simply vector.subtract(goal, pos) (which is equal to vector.multiply(dir, dis))
(if you change the expiry time to something different (lets name it 'time'), it will be vector.multiply(vector.subtract(goal, pos), 1/time) )
Acceleration is a vector as well. The procedure is the same like for the position and velocity.
new_velocity = vector.add(old_velocity, vector.multiply(acc, delta_time))
You probably don't want your particles to change their velocity at all, so you should set minacc and maxacc to {x=0,y=0,z=0}.
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

User avatar
Lejo
Member
Posts: 708
Joined: Mon Oct 19, 2015 16:32
GitHub: Lejo1
In-game: Lejo

Re: Post your modding questions here

by Lejo » Post

Thanks!
The first: vector.subtract(goal, pos) works fine.
But the second: vector.multiply(vector.subtract(goal, pos), 1/time) not. I tested it with time = 5

User avatar
ShallowDweller
Member
Posts: 77
Joined: Thu Nov 02, 2017 22:23

Re: Post your modding questions here

by ShallowDweller » Post

Sires wrote: All this dependencies are included in the default Minetest Game subgame, if you are using another subgame that doesn't have them maybe the subgame was not made to have this mods or you would have to get this mods from the Minetest Game subgame
thanks! as far as i know, Minetest Game subgame is the only one i have. two of the mods are working. i'll check the rules for necrobumping and report the crash caused by the 3rd one to its autor. thanks for the aid!

User avatar
burli
Member
Posts: 1641
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Post

Do any of you have an example for the new underground decoration? I don't really understand how it works to place something on the floor or the ceiling or both

I was able to place something on the floor, but it was pure luck to find some decoratios

User avatar
burli
Member
Posts: 1641
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Post

I found some decoration with this values

Code: Select all

minetest.register_decoration({
	deco_type = "simple",
	place_on = "default:stone",
	sidelen = 16,
	--~ fill_ratio = 0.5,
	noise_params = {
		offset = 2,
		scale = 0.01,
		spread = {x = 200, y = 200, z = 200},
		seed = 23454,
		octaves = 5,
		persist = 0.9
	},
	biomes = {"underground",},
	decoration = "mapgen:cavefern1",
	height = 1,
	flags = {"all_floors","all_ceilings"},
})
And it looks like this

Image

All decoration is only on this height and in this area. Also it is only placed on the floor, not on the ceilings.

What's wrong? How can I get decoration on any height?
Attachments
screenshot_20171103_173243.png
(769.79 KiB) Not downloaded yet

User avatar
burli
Member
Posts: 1641
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Post

I set fill_ratio to 5, just to get everything filled. I found that cave, filled with grass. But hundreds of nodes around, below or above is nothing

Image

In the front you can see a straight cut where the decoration just ends. This can't be correct
Attachments
screenshot_20171103_180920.jpg
(141.85 KiB) Not downloaded yet

User avatar
TumeniNodes
Member
Posts: 2861
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

Re: Post your modding questions here

by TumeniNodes » Post

it seems to be being affected by above ground biome paramters?
Ich mag keine grünen Eier und Schinken, ich mag sie nicht Sam I Am

User avatar
christoferlevich
Member
Posts: 324
Joined: Thu Dec 01, 2016 23:44
GitHub: ChristoferL
Location: Athol, Massachusetts

Re: Post your modding questions here

by christoferlevich » Post

Does anyone think its possible to enlarge the squares in the inventory formspec, even if it means making the quantity of the inventory smaller? The idea would be to make it easier for students to distinguish denominations of cash in the game. If I could enlarge the bills it would go a long way.
everything can be a learning experience...

Vansius
New member
Posts: 1
Joined: Mon Nov 06, 2017 01:23

Re: Post your modding questions here

by Vansius » Post

Topic: How do I manage players and such?
Reason: I want to make a team manager that has a gui where users can join teams.
More Info: I believe not much of this is mentioned in the tutorial book.

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

Re: Post your modding questions here

by cx384 » Post

Vansius wrote:Topic: How do I manage players and such?
Reason: I want to make a team manager that has a gui where users can join teams.
More Info: I believe not much of this is mentioned in the tutorial book.
You can find everything there:
https://github.com/minetest/minetest/bl ... ua_api.txt
Last edited by cx384 on Mon Nov 06, 2017 17:44, edited 1 time in total.
Can your read this?

User avatar
azekill_DIABLO
Member
Posts: 7497
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

christoferlevich wrote:Does anyone think its possible to enlarge the squares in the inventory formspec, even if it means making the quantity of the inventory smaller? The idea would be to make it easier for students to distinguish denominations of cash in the game. If I could enlarge the bills it would go a long way.
The place where the items are? i don't think it's possible, howver you can change gui_size to something bigger, it should maybe work. Or maybe it only works for menu.

User avatar
burli
Member
Posts: 1641
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Post

TumeniNodes wrote:it seems to be being affected by above ground biome paramters?
Not really. I made a video and opened an issue

https://www.youtube.com/watch?v=f-6g16ahCIs

Doesn't look like an effect from other biomes.

User avatar
orwell
Member
Posts: 834
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

azekill_DIABLO wrote:
christoferlevich wrote:Does anyone think its possible to enlarge the squares in the inventory formspec, even if it means making the quantity of the inventory smaller? The idea would be to make it easier for students to distinguish denominations of cash in the game. If I could enlarge the bills it would go a long way.
The place where the items are? i don't think it's possible, howver you can change gui_size to something bigger, it should maybe work. Or maybe it only works for menu.
You might implement a workaround using image buttons. This would no longer be a real inventory but if I understand you right your student's task is to give money change.
Click on button: add this coin/bill to a bar at the bottom
Click on some button on that bar on the bottom: put money back.
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

User avatar
burli
Member
Posts: 1641
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Post

How can I get the version of the engine in Lua? I want to know if the engine is 0.4 or 0.5

Locked

Who is online

Users browsing this forum: No registered users and 0 guests