Post your modding questions here

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

Re: Post your modding questions here

by Nyarg » Post

orwell wrote: Maybe play with these two settings at the same time:
=256 nodes
I set it but have no effect.
So it's good if anyone share actual maintest.conf that gives entity be visible ~200 nods far then I comparise it with my unworked minetest.conf.
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 )

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

Re: Post your modding questions here

by Nyarg » Post

Nyarg wrote:
orwell wrote: Maybe play with these two settings at the same time:
=256 nodes
I set it but have no effect.
Thank again. Now I found what went wrong !!!
New settings aditionally need client (not even creating new world) be restarted !
Wow now my entities stay visible really FARrrrrr ! MUAHAHAHA
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
burli
Member
Posts: 1643
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Post

Nyarg wrote: Wow now my entities stay visible really FARrrrrr ! MUAHAHAHA
But you should know that other parts of the game are effected too, like ABMs

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

Re: Post your modding questions here

by burli » Post

Is it possible to use modpack names for dependencies?

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

*trying*

no. it still think it does not exist sorry. :/
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

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

Re: Post your modding questions here

by burli » Post

azekill_DIABLO wrote:*trying*

no. it still think it does not exist sorry. :/
Thx for testing. Couldn't try it myself right now. Issue submitted. I think that this would be useful

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

If you depend on whole modpacks you are doing sth wrong. What if one mod gets removed from the modpack, but you need it?
Better list exactly the mods from the modpack you depend on. If you need to distingush between a mod and a modified version of that mod in a modpack, test for something unique this modified mod defines inside your mod code.
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

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

problem with entity attach or activate

by Desour » Post

I've got a very big problem. I'm not sure if this is the right place to post this but I'm not sure enough to open an issue.

To test I made this mod:

Code: Select all

minetest.register_entity(
	"eat:test1",
	{
		on_activate = function(self, staticdata, dtime_s)
			minetest.chat_send_all("<1> activated")
			minetest.chat_send_all("<1> "..dtime_s)
			if staticdata == nil then
				minetest.chat_send_all("<1> nil")
			elseif staticdata == "" then
				minetest.chat_send_all("<1> \"\"")
			else
				minetest.chat_send_all("<1> "..staticdata)
			end
			if not self.at then
				self.at = minetest.add_entity(self.object:getpos(), "eat:test2")
			end
			if self.at then
				self.at:set_attach(self.object, "", {x=0,y=1,z=1}, {x=0,y=0,z=0})
				minetest.chat_send_all("<1> attach")
			end
			self.object:setvelocity({x=1,y=0,z=0})
		end,

		get_staticdata = function(self)
			return "sta"
		end,
	}
)

minetest.register_entity(
	"eat:test2",
	{
		on_activate = function(self, staticdata, dtime_s)
			minetest.chat_send_all("<2> activated")
			minetest.chat_send_all("<2> "..dtime_s)
			if staticdata == nil then
				minetest.chat_send_all("<2> nil")
			elseif staticdata == "" then
				minetest.chat_send_all("<2> \"\"")
			else
				minetest.chat_send_all("<2> "..staticdata)
			end
			if staticdata ~= "" then
				if not self.object:get_attach() then
					minetest.chat_send_all("<2> remove")
					self.object:remove()
				end
			end
		end,

		get_staticdata = function(self)
			return "sta"
		end,
	}
)
entity-activation-test.zip
Download
(936 Bytes) Downloaded 51 times
Entity2 should be always attached to entity1, even after de- and activation.
I spawned the entity and flew away and came again and watched what happens.
I'm pretty sure that something is wrong. I'm just not sure what exactly is wrong. The reason for this is that different things happen.
On join everything is ok.
Most of the times entity2 isn't attached for some reason.
It seems like if I don't fly far enough away the entities are deactivated but not activated again.
Try it out yourself and be confused like me.
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

User avatar
TumeniNodes
Member
Posts: 2943
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

If anyone would be able to help me please?

I am going to update my angled walls mod but...., am currently changing all the code for the angled glass (windows).

The excellent model pithy provided for the windows accepts 2 textures, the material and the glass so, I want to correct the code to utilize this. It will really clean up the code and the mod.

However, upon setting off on it..., I added a separate function to register the glass node, etc..
Nothing was showing up so, I then decided to add a dofile to the init.lua and split the glass into it's own mod.

I am stuck now because still, nothing shows up.
Does anyone see what's wrong and why this first node is not even showing up in inventory at all?
As far as I can tell, everything is as it should be, yet no results so, obviously not. WTH am I missing here?

Thank you

Code: Select all

-- [MOD] Angled Glass [angledglass] [1.2] by TumeniNodes 6-24-2016

angledglass = {}

-- Angled place function
-- To use put "on_place = angledglass.angled_place" in the node def

function angledglass.angled_place(itemstack, placer, pointed_thing)
	local placer_pos = placer:getpos()
	local pos = pointed_thing.above
	local param2
	if pos.x > placer_pos.x then
		if pos.z > placer_pos.z then
			param2 = 1
		else
			param2 = 2
		end
	else
		if pos.z > placer_pos.z then
			param2 = 0
		else
			param2 = 3
		end
	end
	return minetest.item_place(itemstack, placer, pointed_thing, param2)
end


--Register angledglass.
--Node will be called angledglass:glass_<subname>

function angledglass.register_glass(subname, recipeitem, groups, images, description, sounds)
	groups.glass = 1
minetest.register_node(":angledglass:glass" .. subname, {
	description = description,
	drawtype = "mesh",
	mesh = "angled_glass.obj",
	tiles = images,
	use_texture_alpha = true,
	paramtype = "light",
	sunlight_propogates = true,
	paramtype2 = "facedir",
	is_ground_content = false,
	groups = groups,
	sounds = sounds,
	collision_box = {
		type = "fixed",
		fixed = {
			{0.375, -0.5, 0.375, 0.5, 0.5, 0.5},
			{-0.5, -0.5, -0.5, -0.375, 0.5, -0.375},
			{-0.4375, -0.5, -0.4375, -0.3125, 0.5, -0.3125},
			{0.3125, -0.5, 0.3125, 0.4375, 0.5, 0.4375},
			{0.25, -0.5, 0.25, 0.375, 0.5, 0.375},
			{-0.375, -0.5, -0.375, -0.25, 0.5, -0.25},
			{0.1875, -0.5, 0.1875, 0.3125, 0.5, 0.3125},
			{-0.3125, -0.5, -0.3125, -0.1875, 0.5, -0.1875},
			{0.125, -0.5, 0.125, 0.25, 0.5, 0.25},
			{-0.25, -0.5, -0.25, -0.125, 0.5, -0.125},
			{0.0625, -0.5, 0.0625, 0.1875, 0.5, 0.1875},
			{-0.1875, -0.5, -0.1875, -0.0625, 0.5, -0.0625},
			{0, -0.5, 0, 0.125, 0.5, 0.125},
			{-0.125, -0.5, -0.125, 0, 0.5, 0},
			{-0.0625, -0.5, -0.0625, 0.0625, 0.5, 0.0625},
		}
	},
	on_place = angledglass.angled_place
})
end

-- Angled glass registration function.
-- Nodes will be called angledglass:{glass}_<subname>

function angledglass.register_glass(subname, recipeitem, groups, images, desc_glass, sounds) 
end


-- Register glass

angledglass.register_glass("wood", "default:wood",
		{choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, wood = 1},
		{"default_wood.png", "default_glass.png"},
		"Wooden Glass",
		default.node_sound_glass_defaults())
This is the dofile I added

Code: Select all

-- [MOD] Angled Walls [angledwalls] [1.2] by TumeniNodes 6-24-2016

dofile(minetest.get_modpath("angledwalls").."/angledwalls.lua")
dofile(minetest.get_modpath("angledwalls").."/angledglass.lua")

if minetest.get_modpath("bakedclay") then
	dofile(minetest.get_modpath("angledwalls").."/bakedclay.lua")
end

if minetest.get_modpath("quartz") then
	dofile(minetest.get_modpath("angledwalls").."/quartz.lua")
end
A Wonderful World

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

Re: problem with entity attach or activate

by Nyarg » Post

DS-minetest wrote:It seems like if I don't fly far enough away the entities are deactivated but not activated again.
As I know server only keeps place and type destroyed entity.
Another current data (velocity, collision box, attach map etc) you must say to server via

Code: Select all

function eObj:get_staticdata()
	return minetest.serialize(self.p)	--- for self I keep all depend data in table
end 
Then init again entity at

Code: Select all

function eObj:on_activate( staticdata)
	if staticdata == "" then	
		self.p = {}
      self.p.vel = {x=1,y=0,z=0}
	else
		self.p = minetest.deserialize(staticdata)
      self.object:setvelocity(self.p.vel)
	end
end
PS: on_activate = function(self, staticdata, dtime_s)
Wiki don't explain dtime_s in on_activate
Last edited by Nyarg on Sat Feb 04, 2017 22:56, edited 9 times in total.
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 )

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

Re: problem with entity attach or activate

by Nyarg » Post

TumeniNodes wrote:I am stuck now because still, nothing shows up.
Why twice identical ?
function angledglass.register_glass(subname, recipeitem, groups, images, desc_glass, sounds)

Next give me error "attempt to index global "default" "
default.node_sound_glass_defaults())

After all I run main code as init.lua and finaly see
Spoiler
Image
Last edited by Nyarg on Sun Feb 05, 2017 01:27, edited 1 time in total.
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
GreenXenith
Member
Posts: 1356
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
Location: UTC-8:00
Contact:

Re: Post your modding questions here

by GreenXenith » Post

n00b question: How do I make a tool break after 3 uses?
Thanks!
YouTube | Mods | Patreon | Minetest Discord @greenxenith

You should not be able to read this message.

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

Re: problem with entity attach or activate

by TumeniNodes » Post

Nyarg wrote:Why twice identical ?
function angledglass.register_glass(subname, recipeitem, groups, images, desc_glass, sounds)
Apparently because I didn't want it to work :P

Thank you very much Nyarg, much appreciated :D
A second pair of eyes is always the best solution

Now I have to look at the model and figure out why the 2 materials are not working as they should
A Wonderful World

User avatar
krokoschlange
Member
Posts: 62
Joined: Sat Jul 02, 2016 08:33
GitHub: krokoschlange
In-game: krokoschlange

How to get bone rotation?

by krokoschlange » Post

I want to make a tank mod and I need the rotation of a bone to add a another vector to it.
Because if if I do

Code: Select all

self.object:get_bone_position("bone_name")
it returns two tables. How to get to the values of the second (rotation) table? What do I need instead of the x?:

Code: Select all

self.object:get_bone_position("bone_name").x

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

Re: How to get bone rotation?

by Nyarg » Post

krokoschlange wrote:it returns two tables. How to get to the values of the second (rotation) table?
Where do you found get_bone_position() ?

Anyway as I think access will like (you may check it here https://www.lua.org/cgi-bin/demo)

Code: Select all

t = {a = {11},b = {12}}
print(t.a[1])
print(t.b[1])

function fn() 
   tt = {a = {21},b = {22},c = {x = 23,y = 24, z = 25}}
   ttt = {a = {31},b = {32},c = {x = 33,y = 34, z = 35}}
   return tt,ttt
end

print(fn().b[1])
print(fn().c.x)

v, w = fn()
print(w.c.x)
Last edited by Nyarg on Sun Feb 05, 2017 20:00, edited 3 times in total.
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
krokoschlange
Member
Posts: 62
Joined: Sat Jul 02, 2016 08:33
GitHub: krokoschlange
In-game: krokoschlange

Re: Post your modding questions here

by krokoschlange » Post

Thanks I will try that. I found the function in the modding api.

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

Re: Post your modding questions here

by Nyarg » Post

krokoschlange wrote: I found the function in the modding api.
Oops it's right but wiki seems outdated now.

now I see get_bone_position() return separate table so look my previously post that I update now ) for separate table handling.
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
krokoschlange
Member
Posts: 62
Joined: Sat Jul 02, 2016 08:33
GitHub: krokoschlange
In-game: krokoschlange

Re: Post your modding questions here

by krokoschlange » Post

Unfortunately I still don't get how to get a value from the second table like the 32

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

Re: How to get bone rotation?

by orwell » Post

krokoschlange wrote:I want to make a tank mod and I need the rotation of a bone to add a another vector to it.
Because if if I do

Code: Select all

self.object:get_bone_position("bone_name")
it returns two tables. How to get to the values of the second (rotation) table? What do I need instead of the x?:

Code: Select all

self.object:get_bone_position("bone_name").x
Save in a local variable first:

Code: Select all

local _, rot = self.object:get_bone_position("bone_name")
rot.x
Underscore as a placeholder variable that is discarded.
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

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

GreenDimond wrote:n00b question: How do I make a tool break after 3 uses?
Thanks!
uses=3 in tool capabilities!?
Or maybe it's 2 or 4, there was an issue with count being off by 1
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

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

Re: problem with entity attach or activate

by orwell » Post

DS-minetest wrote:I've got a very big problem. I'm not sure if this is the right place to post this but I'm not sure enough to open an issue.

To test I made this mod:

Code: Select all

minetest.register_entity(
	"eat:test1",
	{
		on_activate = function(self, staticdata, dtime_s)
			minetest.chat_send_all("<1> activated")
			minetest.chat_send_all("<1> "..dtime_s)
			if staticdata == nil then
				minetest.chat_send_all("<1> nil")
			elseif staticdata == "" then
				minetest.chat_send_all("<1> \"\"")
			else
				minetest.chat_send_all("<1> "..staticdata)
			end
			if not self.at then
				self.at = minetest.add_entity(self.object:getpos(), "eat:test2")
			end
			if self.at then
				self.at:set_attach(self.object, "", {x=0,y=1,z=1}, {x=0,y=0,z=0})
				minetest.chat_send_all("<1> attach")
			end
			self.object:setvelocity({x=1,y=0,z=0})
		end,

		get_staticdata = function(self)
			return "sta"
		end,
	}
)

minetest.register_entity(
	"eat:test2",
	{
		on_activate = function(self, staticdata, dtime_s)
			minetest.chat_send_all("<2> activated")
			minetest.chat_send_all("<2> "..dtime_s)
			if staticdata == nil then
				minetest.chat_send_all("<2> nil")
			elseif staticdata == "" then
				minetest.chat_send_all("<2> \"\"")
			else
				minetest.chat_send_all("<2> "..staticdata)
			end
			if staticdata ~= "" then
				if not self.object:get_attach() then
					minetest.chat_send_all("<2> remove")
					self.object:remove()
				end
			end
		end,

		get_staticdata = function(self)
			return "sta"
		end,
	}
)
entity-activation-test.zip
Entity2 should be always attached to entity1, even after de- and activation.
I spawned the entity and flew away and came again and watched what happens.
I'm pretty sure that something is wrong. I'm just not sure what exactly is wrong. The reason for this is that different things happen.
On join everything is ok.
Most of the times entity2 isn't attached for some reason.
It seems like if I don't fly far enough away the entities are deactivated but not activated again.
Try it out yourself and be confused like me.
Someone would need to rewrite all attachment code. There are many issues with it.
Some things you should know:
When objects get unloaded, attachments are lost. You need to reattach in the on_activate function.
Try this:
- Staff your second object (the attachee) with something unique, such as a concatenation of os.time()..os.clock()
(not that I am using this in advtrains....) and save that in staticdata
- In on_activate() of the first object (attacher) or inside step as long as not found, loop through minetest.luaentites and search for exactly that unique property. When found, attach that object.

Code: Select all

attacher on_step()
....
if not self.has_attached then
  for aoid, luaentity in pairs(minetest.luaentities) do
    if luaentity.unique_id==id then
      local attachee=minetest.object_refs[aoid]
      self.object:set_attach(attachee, ....)
      self.has_attached=true
    end
  end
end

attachee on_activate(self,staticdata)
self.unique_id=staticdata
if self.unique_id=="" then
  self.unique_id=os.time()..os.clock()
end

attachee get_staticdata()
return self.unique_id
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

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

Re: Post your modding questions here

by Desour » Post

@orwell: Thanks, marking the attachee could be an interesting idea. Nevertheless the attach is obscure.
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

User avatar
krokoschlange
Member
Posts: 62
Joined: Sat Jul 02, 2016 08:33
GitHub: krokoschlange
In-game: krokoschlange

Re: How to get bone rotation?

by krokoschlange » Post

orwell wrote: Save in a local variable first:

Code: Select all

local _, rot = self.object:get_bone_position("bone_name")
rot.x
Underscore as a placeholder variable that is discarded.
Thank you, it works great!

User avatar
BrunoMine
Member
Posts: 1082
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine
Location: SP-Brasil
Contact:

Re: Post your modding questions here

by BrunoMine » Post

Hello guys.
I would like to develop a method to identify (in real time) the players that are close to a specific node.
I've put the code below:

Code: Select all

local players = {}
minetest.register_abm{
	nodenames = {"mymod:mynode"},
	interval = 1,
	action = function(pos)
		local all_objects = minetest.get_objects_inside_radius(pos, 25)
		players = {}
		for _,obj in ipairs(all_objects) do
			if obj:is_player() then
				table.insert(players, obj)
			end
		end
		print(#players .. " players found")
	end,
}
My concern is, if this is really efficient.
I imagine there may be dozens of active nodes on a server, and this can lead to high processing usage.
Is there any better way to accomplish this task?
Does Minetest have any more suitable method for this?
Do not I have to worry about processing?

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

Re: Post your modding questions here

by Byakuren » Post

BrunoMine wrote:Hello guys.
I would like to develop a method to identify (in real time) the players that are close to a specific node.
I've put the code below:

Code: Select all

local players = {}
minetest.register_abm{
	nodenames = {"mymod:mynode"},
	interval = 1,
	action = function(pos)
		local all_objects = minetest.get_objects_inside_radius(pos, 25)
		players = {}
		for _,obj in ipairs(all_objects) do
			if obj:is_player() then
				table.insert(players, obj)
			end
		end
		print(#players .. " players found")
	end,
}
My concern is, if this is really efficient.
I imagine there may be dozens of active nodes on a server, and this can lead to high processing usage.
Is there any better way to accomplish this task?
Does Minetest have any more suitable method for this?
Do not I have to worry about processing?
Instead of searching around each node for a player, use minetest.get_connected_players() and search for the node around each player. If you have a lot of nodes this will be faster, but I don't know exactly how many nodes you need for it to be faster. Probably you should try benchmarking it.
Every time a mod API is left undocumented, a koala dies.

Locked

Who is online

Users browsing this forum: No registered users and 6 guests