Post your modding questions here
-
- Member
- Posts: 3015
- Joined: Sun Jan 18, 2015 13:02
- GitHub: ABJ-MV
- In-game: ABJ
- Location: In Earth orbit, with a perigee of 1048 km and an apogee of 1337 km and an inclination of 69 degrees.
Re: Post your modding questions here
How do I modify node properties while the node is in game?
-
- Member
- Posts: 3015
- Joined: Sun Jan 18, 2015 13:02
- GitHub: ABJ-MV
- In-game: ABJ
- Location: In Earth orbit, with a perigee of 1048 km and an apogee of 1337 km and an inclination of 69 degrees.
Re: Post your modding questions here
How do I get the time of day?
Re: Post your modding questions here
Not at all, but you can use ABMs, node callbacks, node timer, ... to change the meta (infotext, inventor,y ...), rotation, color palette, ... or replace the node with another node.ABJ wrote:How do I modify node properties while the node is in game?
With minetest.get_timeofday().ABJ wrote:How do I get the time of day?
https://github.com/minetest/minetest/bl ... .txt#L2458
Can your read this?
-
- Member
- Posts: 3015
- Joined: Sun Jan 18, 2015 13:02
- GitHub: ABJ-MV
- In-game: ABJ
- Location: In Earth orbit, with a perigee of 1048 km and an apogee of 1337 km and an inclination of 69 degrees.
Re: Post your modding questions here
How do I change this colorpalette?
-
- Member
- Posts: 3015
- Joined: Sun Jan 18, 2015 13:02
- GitHub: ABJ-MV
- In-game: ABJ
- Location: In Earth orbit, with a perigee of 1048 km and an apogee of 1337 km and an inclination of 69 degrees.
Re: Post your modding questions here
How do I set the light level of a node?
Re: Post your modding questions here
ABJ, you can find the answers of this questions there. https://github.com/minetest/minetest/bl ... ua_api.txt
Can your read this?
Re: Post your modding questions here
cx384 wrote: ... to change the meta (infotext, inventor,y ...), rotation, color palette, ...
oops "Myyy Precious"
What is MT version had implement palette ? It seems very profitable )
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 )
MT Strike 78a36b468554d101e0be3b0d1f587a555f396452 Great! Somebody have found it )
"My english isn't well" I know. I'm sorry )
Re: Post your modding questions here
I think Minetest 0.4.16Nyarg wrote:What is MT version had implement palette ? It seems very profitable )
The commit: https://github.com/minetest/minetest/co ... b81358a54e
Can your read this?
Re: Post your modding questions here
Nodes can't move.ABJ wrote:Ooops! I meant position!
A 'node' in minetest is defined by the following properties:
1) the position (immutable - you cannot change this)
2) the content type (a reference to what type of block this is)
3) param1/param2 values
and, secondary, there are, or may be one or more of the following `attached` to the node:
a) light levels (obtainable and changeable in limited ways on the server)
b) metadata
c) nodetimer
d) biome parameters and mapgen stuff (only obtainable or modifyable during mapgen)
e) other unspecified private node properties I forgot here.
As a consequence, if you wish to `move` a node from position A to B, you have to `change A to air` and `change B to the original block type`.
Re: Post your modding questions here
What about a mod that makes the light level of (certain/all) light sources vary over time, randomly ?
Torches and fire aren't always perfectly the same brightness even if they stay lit, right ?
Torches and fire aren't always perfectly the same brightness even if they stay lit, right ?
Re: Post your modding questions here
Since you can not modify the light level in a node, you need to create multiple nodes that look the same and have different light levels, and then swap them.Lord_Vlad wrote:What about a mod that makes the light level of (certain/all) light sources vary over time, randomly ?
Torches and fire aren't always perfectly the same brightness even if they stay lit, right ?
- christoferlevich
- Member
- Posts: 325
- Joined: Thu Dec 01, 2016 23:44
- GitHub: ChristoferL
- Location: Athol, Massachusetts
Re: Post your modding questions here
There's a mod called morefire u might like. The torches do burn out. I don't think the light varies tho.Lord_Vlad wrote:What about a mod that makes the light level of (certain/all) light sources vary over time, randomly ?
Torches and fire aren't always perfectly the same brightness even if they stay lit, right ?
everything can be a learning experience...
- Linuxdirk
- Member
- Posts: 3219
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: Post your modding questions here
When having a node with paramtype2 = 'facedir' ... how can I properly determine left/right/front/back according to the node's orientation when placed?
- BirgitLachner
- Member
- Posts: 393
- Joined: Thu May 05, 2016 10:18
- In-game: Bibs
Re: Post your modding questions here
I have a questions concerning a mod, that TalkLounge released on his homepage.
It offers an automatic spawner that drops items. Everthing is hardcoded, but as it is not used so often, this is okay.
Here I have my adopted code to spawn diamonds:
I don't know if there is a better possibility to do that, but it works ;-)
I want to hide the lower node that is build to drop items called "spawn_item:diamantspawnerunten" by, lets say, a block of dirt that I put on it, but surprisingly, the diamond falls down through the dirt and lands on the "spawn_item:diamantspawnerunten".
I want to understand, why this happens.
EDIT:
If I change the line
EDIT 2:
Well, what I said before is not always the same ... strange. Sometime gies through, sometimes not.
It offers an automatic spawner that drops items. Everthing is hardcoded, but as it is not used so often, this is okay.
Here I have my adopted code to spawn diamonds:
Code: Select all
minetest.register_node("spawn_item:diamantspawnerunten"--[[Das ist der Node, den man setzen muss]], {
description = "Spawn Diamant",
tiles = {"spawn_item_normal.png"},
sounds = default.node_sound_stone_defaults(),
light_source = 14})
minetest.register_node("spawn_item:diamantspawneroben"--[[Das ist ein Node, der nur für die Ausführung der Fuktion wichtig ist]], {
description = "Hilfsnode zum spawnen von Diamant",
light_source = 14,
tiles = {"spawn_item_normal.png"},
walkable = false,
pointable = false,
drawtype = "glasslike"})
minetest.register_abm({--[[Diese Funktion lässt den die obere Spawner-Node zwei Nodes über dem normal Node spawnen]]
nodenames = {"spawn_item:diamantspawnerunten"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.set_node({x = pos.x, y = pos.y +3, z = pos.z}, {name = "spawn_item:diamantspawneroben"})
end})
minetest.register_abm({--[[Diese Funktion lässt ein Item auf dem normal Node alle paar Sekunden spawnen. Es ist nicht möglich, direkt vom normal Node mehrere Items spawnen zu lassen]]
nodenames = {"spawn_item:diamantspawneroben"},
interval = 5--[[Diese Zahl gibt an, alle wie viele Sekunden ein Item spawnen soll]],
chance = 1--[[Diese Zahl gibt an, mit welcher Warscheinlichkeit ein Item spawnen soll]],
action = function(pos, node, active_object_count, active_object_count_wider)
if minetest.add_item({x = pos.x, y = pos.y - 1, z = pos.z}, "default:diamond"--[[Dieser Name gibt das Item an, das spawnen soll]])
then minetest.dig_node({x = pos.x, y = pos.y, z = pos.z})--[[Nachdem das Item gespawnt ist, wird der normal1 Node wieder entfernt und muss erneut vom normal Node erzeugt werden. Dieser Vorgang muss passieren, damit wenn man den normal Node abbaut, nicht weiter Items spawnen. Der Vorgang kann allerdings auch entfernt werden, dann muss man allerdings den normal1 Node per Worldedit entfernen. Wenn dieser Vorgang entfernt wird, dann führt es auch zu weniger Lags]]
end
end})
I want to hide the lower node that is build to drop items called "spawn_item:diamantspawnerunten" by, lets say, a block of dirt that I put on it, but surprisingly, the diamond falls down through the dirt and lands on the "spawn_item:diamantspawnerunten".
I want to understand, why this happens.
EDIT:
If I change the line
tominetest.set_node({x = pos.x, y = pos.y +3, z = pos.z}, {name = "spawn_item:diamantspawneroben"})
it works more or less. But water, that is flowing over ths dirt block, causes that the item goes through the water and dirt block under the water, too.minetest.set_node({x = pos.x, y = pos.y +5, z = pos.z}, {name = "spawn_item:diamantspawneroben"})
EDIT 2:
Well, what I said before is not always the same ... strange. Sometime gies through, sometimes not.
Last edited by BirgitLachner on Tue Aug 08, 2017 19:38, edited 2 times in total.
Re: Post your modding questions here
There are a few helper functions `dir_to_facedir` etc documented in lua_api.txt. For code examples, you probably want to look at things like minetest_game beds and doors, since they've got code handling orientation on placement and rotation. Screwdriver mod may also help to provide insights.Linuxdirk wrote:When having a node with paramtype2 = 'facedir' ... how can I properly determine left/right/front/back according to the node's orientation when placed?
facedir is a bit funny in a way, since '0' means north (and not cartesian where it would be east) and if you place a furnace facing north, then the "front" of the furnace faces south, so effectively the "back" side of the furnace is where you put the fuel in. Highly confusing :)
- Linuxdirk
- Member
- Posts: 3219
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: Post your modding questions here
Great :D I’ll check this out. Thanks.
- BirgitLachner
- Member
- Posts: 393
- Joined: Thu May 05, 2016 10:18
- In-game: Bibs
Re: Post your modding questions here
Another question to the Spawn-Item-Mod ...
I want the items not to spawn in the same intervall but randomly ...
I searched around the Web how to use lua to get a random number ... it is not important if it is a number between 1 and 10 o a float(?) number between 0 and 1 ... I can handle both.
I found out that I need to start/initialisize the random generator. But even if I try it, I always get the same intervall.
So can you help me please, who I need to change the code, to get random intervalls.
I want the items not to spawn in the same intervall but randomly ...
Code: Select all
minetest.register_abm({--[[Diese Funktion lässt ein Item auf dem normal Node alle paar Sekunden spawnen. Es ist nicht möglich, direkt vom normal Node mehrere Items spawnen zu lassen]]
nodenames = {"spawn_item:diamantspawneroben"},
interval = PseudoRandom(os.time()) --[[Diese Zahl gibt an, alle wie viele Sekunden ein Item spawnen soll]],
chance = 1--[[Diese Zahl gibt an, mit welcher Warscheinlichkeit ein Item spawnen soll]],
action = function(pos, node, active_object_count, active_object_count_wider)
if minetest.add_item({x = pos.x, y = pos.y - 1, z = pos.z}, "default:diamond"--[[Dieser Name gibt das Item an, das spawnen soll]])
then minetest.dig_node({x = pos.x, y = pos.y, z = pos.z})--[[Nachdem das Item gespawnt ist, wird der normal1 Node wieder entfernt und muss erneut vom normal Node erzeugt werden. Dieser Vorgang muss passieren, damit wenn man den normal Node abbaut, nicht weiter Items spawnen. Der Vorgang kann allerdings auch entfernt werden, dann muss man allerdings den normal1 Node per Worldedit entfernen. Wenn dieser Vorgang entfernt wird, dann führt es auch zu weniger Lags]]
end
end})
I found out that I need to start/initialisize the random generator. But even if I try it, I always get the same intervall.
is to start the generator andmath.randomseed(x)
to get the number.math.random([m[,n]])
So can you help me please, who I need to change the code, to get random intervalls.
Re: Post your modding questions here
Not quite like what I was thinking about, besides, I know about that mod, there's even another one called "real torches" that make torches go out.christoferlevich wrote:There's a mod called morefire u might like. The torches do burn out. I don't think the light varies tho.Lord_Vlad wrote:What about a mod that makes the light level of (certain/all) light sources vary over time, randomly ?
Torches and fire aren't always perfectly the same brightness even if they stay lit, right ?
I don't want them to go out, I want them to vary in intensity.
It could be made to have a more "moving" fire, as well as, for example, horror-movie lightbulbs in abandonned buildings.
I can't mod yet, but I'll keep the idea to make it myself if it's never done by anyone else.
- christoferlevich
- Member
- Posts: 325
- Joined: Thu Dec 01, 2016 23:44
- GitHub: ChristoferL
- Location: Athol, Massachusetts
Re: Post your modding questions here
It would seem plausible that it should be possible to make a random number generate but I'm still wrapping my head over basic things. Someday... Lol
everything can be a learning experience...
Re: Post your modding questions here
It doesn't appear to be possible to change an abm once it's registered so I don't think you can change the interval. As an alternative, you could wrap the add_item if block with a check to see if a random number falls within a range. It's not an interval but you can tweak the comparison value get a close approximation.BirgitLachner wrote:Another question to the Spawn-Item-Mod ...
I want the items not to spawn in the same intervall but randomly ...
Code: Select all
minetest.register_abm({--[[Diese Funktion lässt ein Item auf dem normal Node alle paar Sekunden spawnen. Es ist nicht möglich, direkt vom normal Node mehrere Items spawnen zu lassen]]
nodenames = {"spawn_item:diamantspawneroben"},
interval = 1 -- control the spawn rate using a random value in the function
chance = 1--[[Diese Zahl gibt an, mit welcher Warscheinlichkeit ein Item spawnen soll]],
action = function(pos, node, active_object_count, active_object_count_wider)
--Something like this
if math.random(0,1) > 0.4 then
if minetest.add_item({x = pos.x, y = pos.y - 1, z = pos.z}, "default:diamond"--[[Dieser Name gibt das Item an, das spawnen soll]])
then minetest.dig_node({x = pos.x, y = pos.y, z = pos.z})--[[Nachdem das Item gespawnt ist, wird der normal1 Node wieder entfernt und muss erneut vom normal Node erzeugt werden. Dieser Vorgang muss passieren, damit wenn man den normal Node abbaut, nicht weiter Items spawnen. Der Vorgang kann allerdings auch entfernt werden, dann muss man allerdings den normal1 Node per Worldedit entfernen. Wenn dieser Vorgang entfernt wird, dann führt es auch zu weniger Lags]]
end
end
end})
Re: Post your modding questions here
Go to https://www.lua.org/cgi-bin/demo and try this program:christoferlevich wrote:it should be possible to make a random number generator
Code: Select all
r=math.random()
print(r)
math.randomseed(6)
for i=1,7 do
print( math.random(1,6) )
end
'My' wiki-pages: Build-a-home - basic-robot - basic_robot_csm - basic-machines - digtron - xdecor -
Map-Database
Map-Database
- BirgitLachner
- Member
- Posts: 393
- Joined: Thu May 05, 2016 10:18
- In-game: Bibs
Re: Post your modding questions here
Okay, if that is true I can't do it with random intervals. But while reading your comment, I realized that I can use the chance value to have a variable spawning. May be that's enough.zing269 wrote:
It doesn't appear to be possible to change an abm once it's registered so I don't think you can change the interval.
@hajo I tried all thoose things.
- 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
1. set_attach means "attach this object (the object that the function is called on) to the specified one".mezantrop wrote:topic: set_attach usage help.
reason: I want to attach and move two nodes together.
more info: Sorry for a dumb question, I'm newbie to minetest game as well as minetest development. Now trying to create two entities and make the second to repeat all moves of the first one. Have stuck at the early beginning with attaching the second entity to the first:
Couldn't someone explain me how to use it properly, as obviously, I'm doing it wrong.Code: Select all
second = minetest.add_entity(pos_behind_first, "my_mod:second") second:set_attach(self.object, "", {x=0,y=0,z=0}, {x=0,y=0,z=0})
P.S. what is the "bone" - the second argument of set_attach?
Thank you in advance.
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, ...)
Code: Select all
second's get_staticdata()
return "blah"
end
second's on_activate(staticdata)
if staticdata=="blah" then
self.object:remove()
return
end
end
- 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
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)
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
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!
DMs are always open if you want to get in touch!
Who is online
Users browsing this forum: No registered users and 23 guests