Post your modding questions here
- Hybrid Dog
- Member
- Posts: 2835
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
iangp, player movement is predicted in minetest, else constantly the position of the player would need to be sent. l tried to make a spin bot, but it doesn't work because the player's yaw is sent less than every 0.2 seconds.
OmniStudent, in minetest an object is a spawned entity, e.g. a dropped item (http://dev.minetest.net/ObjectRef)
What exactly should locking doors do (or how are they locked)?
OmniStudent, in minetest an object is a spawned entity, e.g. a dropped item (http://dev.minetest.net/ObjectRef)
What exactly should locking doors do (or how are they locked)?
-
- Member
- Posts: 818
- Joined: Tue Apr 14, 2015 01:59
- GitHub: raymoo
- IRC: Hijiri
- In-game: Raymoo + Clownpiece
Re: Post your modding questions here
I want to write a spell that will dig a 3x3x3 area of nodes when used, and I want this to check protection and add entries to the rollback log, so it can be rolled-back if necessary. I could write a function that does everything other than the rollback, but I don't know if there is a way to add things to the rollback log this way. Is there? Or maybe there is a better way to do this.
Every time a mod API is left undocumented, a koala dies.
- mahmutelmas06
- Member
- Posts: 367
- Joined: Mon Mar 02, 2015 13:10
- GitHub: mahmutelmas06
- IRC: mahmutelmas06
- In-game: masum
Re: Post your modding questions here
Code: Select all
if wieldname == (
"default:gold_lump" or
"currency:minegeld" or
"currency:minegeld_5" or
"currency:minegeld_10" or
"bitchange:minecoin" or
"bitchange:mineninth" or
"homedecor:coin" )
then
wielditem:take_item()
But only the first one "default:gold_lump" works others not. So what punctuation to use for that ?
- 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
The code:
Does not do what you expect. What it does is evaluate `a`, and if it results in a "true" value (anything other than `false` or `nil`), it uses that value. Otherwise, it evaluates `b`, and if it results on a "true" value, it uses that value. Same for `c`.
Since `a` in your case is the string "default:gold_lump", `a` is not "false", so the expression (a or b or c) results in "default:gold_lump". Then Lua compares `wieldname` to the result of the expression. The expression `("default:gold_lump" or ...)` always result in "default:gold_lump".
You have two approaches. You can explicitly test for the strings:
Or you can use a table mapping accepted values to `true`:
Which one is better is up to you. I'd use the former if the list of valid options is short, but use the latter if you need lots of items.
Code: Select all
wieldname == (a or b or c)
Since `a` in your case is the string "default:gold_lump", `a` is not "false", so the expression (a or b or c) results in "default:gold_lump". Then Lua compares `wieldname` to the result of the expression. The expression `("default:gold_lump" or ...)` always result in "default:gold_lump".
You have two approaches. You can explicitly test for the strings:
Code: Select all
if wieldname == "foo" or wieldname == "bar" or wieldname == "baz" or ...
Code: Select all
local valid = {
["default:foo"] = true,
["default:bar"] = true,
-- ...
}
-- Then in your check
if valid[wieldname] then
print("I am doing something.")
end
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
Check out my stuff! | Donations greatly appreciated! PayPal
-
- Member
- Posts: 261
- Joined: Sat Nov 03, 2012 06:40
Re: Post your modding questions here
[quote=
OmniStudent, in minetest an object is a spawned entity, e.g. a dropped item (http://dev.minetest.net/ObjectRef)
What exactly should locking doors do (or how are they locked)?[/quote]
Ah, I suppose I should have written "node" instead of object.
The purpose of the locked door is to prevent players from exiting or entering (new players) a dungeon until they've completed some sort of objective.
OmniStudent, in minetest an object is a spawned entity, e.g. a dropped item (http://dev.minetest.net/ObjectRef)
What exactly should locking doors do (or how are they locked)?[/quote]
Ah, I suppose I should have written "node" instead of object.
The purpose of the locked door is to prevent players from exiting or entering (new players) a dungeon until they've completed some sort of objective.
-
- Member
- Posts: 818
- Joined: Tue Apr 14, 2015 01:59
- GitHub: raymoo
- IRC: Hijiri
- In-game: Raymoo + Clownpiece
Re: Post your modding questions here
To answer my own question, it looks like minetest.node_dig will do the job of checking protection and digging for some player, though it's not clear if it adds to the rollback log. I will try it out when I have time.Byakuren wrote:I want to write a spell that will dig a 3x3x3 area of nodes when used, and I want this to check protection and add entries to the rollback log, so it can be rolled-back if necessary. I could write a function that does everything other than the rollback, but I don't know if there is a way to add things to the rollback log this way. Is there? Or maybe there is a better way to do this.
Every time a mod API is left undocumented, a koala dies.
- mahmutelmas06
- Member
- Posts: 367
- Joined: Mon Mar 02, 2015 13:10
- GitHub: mahmutelmas06
- IRC: mahmutelmas06
- In-game: masum
Re: Post your modding questions here
Thank you Kaeza for help.
I will use the list one
I will use the list one
Re: Post your modding questions here
Would it be possible to create an NPC as a node, and not as an object?
The reason I would like to do this: I want to place talking NPC's that add a backstory to the world. You know, with interactive dialogue. I don't want to replace them everytime I run /clearobjects.
The reason I would like to do this: I want to place talking NPC's that add a backstory to the world. You know, with interactive dialogue. I don't want to replace them everytime I run /clearobjects.
-
- Member
- Posts: 1233
- Joined: Tue Oct 23, 2012 12:59
- GitHub: Dragonop
- IRC: Dragonop
- In-game: Dragonop
- Location: Argentina
Re: Post your modding questions here
How you do get the number of items in a stack that is inside an inventory slot in a formspec to display in the infotext of a node?
Re: Post your modding questions here
Dragonop wrote:How you do get the number of items in a stack that is inside an inventory slot in a formspec to display in the infotext of a node?
Code: Select all
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
meta:set_string("infotext", tostring(inv:get_stack("listname", index):get_count()))
- Hybrid Dog
- Member
- Posts: 2835
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
You could set a locked steel door and then set its owner to some string which can't be a playername, e.g. "§singleplayer", and if you completed the objective, the steel door's owner is changed to your name.OmniStudent wrote:Ah, I suppose I should have written "node" instead of object.
The purpose of the locked door is to prevent players from exiting or entering (new players) a dungeon until they've completed some sort of objective.
The owner is stored in meta: https://github.com/HybridDog/minetest_g ... it.lua#L87
it's possible but it would be fairly immobile (compare with a chest which looks like a player and talks to you via changing its infotext)bark wrote:Would it be possible to create an NPC as a node, and not as an object?
The reason I would like to do this: I want to place talking NPC's that add a backstory to the world. You know, with interactive dialogue. I don't want to replace them everytime I run /clearobjects.
- qwertymine3
- Member
- Posts: 202
- Joined: Wed Jun 03, 2015 14:33
- GitHub: Qwertymine
- In-game: qwertymine3
Re: Post your modding questions here
If you want to have object NPCS, you may want to look at the item frame mod.bark wrote:Would it be possible to create an NPC as a node, and not as an object?
The reason I would like to do this: I want to place talking NPC's that add a backstory to the world. You know, with interactive dialogue. I don't want to replace them everytime I run /clearobjects.
These mods have a node which recovers the object used to display the item after a /clearobjects.
Looking at the code, it looks like the npcs wouldn't be able to move - but they would still have the
advantage of being animate-able.
Avatar by :devnko-ennekappao:
-
- Member
- Posts: 1233
- Joined: Tue Oct 23, 2012 12:59
- GitHub: Dragonop
- IRC: Dragonop
- In-game: Dragonop
- Location: Argentina
Re: Post your modding questions here
Thanks jp!jp wrote:-snip-
Re: Post your modding questions here
Thanks for the great input! Will look further into this.
-
- Member
- Posts: 261
- Joined: Sat Nov 03, 2012 06:40
Re: Post your modding questions here
Thanks for the suggestion! I didn't know about the default locked steel door. In that case, can I just replace a real steel door with a steel door-skinned regular door when its supposed to be open. Or just delete the steel door.Hybrid Dog wrote:You could set a locked steel door and then set its owner to some string which can't be a playername, e.g. "§singleplayer", and if you completed the objective, the steel door's owner is changed to your name.OmniStudent wrote:Ah, I suppose I should have written "node" instead of object.
The purpose of the locked door is to prevent players from exiting or entering (new players) a dungeon until they've completed some sort of objective.
The owner is stored in meta: https://github.com/HybridDog/minetest_g ... it.lua#L87
- swordpaint12
- Member
- Posts: 191
- Joined: Sat Aug 22, 2015 00:50
- In-game: [swordpaint12][Belching_Balladeer]
- Location: Foobass, isle of Atlantis, castle of Bardvendelle
Re: Post your modding questions here
Hi guys,
I am learning to make mods and recently I created a simple mud mod. I was unable to create a crafting recipe which I wanted to be a water bucket and block of dirt shapeless. I don't remember what I wrote but I was following the outline found on rubenwardy's tutorial. Could someone show me what the proper recipe would look like?
(PS: Here is the code for the mud block.
I am learning to make mods and recently I created a simple mud mod. I was unable to create a crafting recipe which I wanted to be a water bucket and block of dirt shapeless. I don't remember what I wrote but I was following the outline found on rubenwardy's tutorial. Could someone show me what the proper recipe would look like?
(PS: Here is the code for the mud block.
Code: Select all
minetest.register_node("mud:mud", {
description = "Mud",
tiles = {"mud_v.1.png"},
groups = {crumbly=1,soil=3,oddly_breakable_by_hand=10},
})
God's not dead; remember that!
Yay for MT! No MC here!
I am a human. I'm younger than 100 years old.
I've been playing Minetest since December 2014.
I'm amazed that I haven't been on here in so long! My latest minetest accomplishment was mining by hand (well, as close as you can get in a computer game) a circle 30 blocks in diameter. It took forever but it's pretty cool.
Yay for MT! No MC here!
I am a human. I'm younger than 100 years old.
I've been playing Minetest since December 2014.
I'm amazed that I haven't been on here in so long! My latest minetest accomplishment was mining by hand (well, as close as you can get in a computer game) a circle 30 blocks in diameter. It took forever but it's pretty cool.
-
- Member
- Posts: 1233
- Joined: Tue Oct 23, 2012 12:59
- GitHub: Dragonop
- IRC: Dragonop
- In-game: Dragonop
- Location: Argentina
Re: Post your modding questions here
swordpaint12 wrote:Hi guys,
I am learning to make mods and recently I created a simple mud mod. I was unable to create a crafting recipe which I wanted to be a water bucket and block of dirt shapeless. I don't remember what I wrote but I was following the outline found on rubenwardy's tutorial. Could someone show me what the proper recipe would look like?
Code: Select all
minetest.register_node("mud:mud", {
description = "Mud",
tiles = {"mud_v.1.png"},
groups = {crumbly = 1, soil = 3, oddly_breakable_by_hand = 10}
})
minetest.register_craft({
type = "shapeless",
output = "mud:mud",
recipe = {"bucket:bucket_water", "default:dirt"},
replacements = {
{"bucket:bucket_water", "bucket:bucket_empty"},
}
})
I also recommend putting spaces when doing stuff like "group = 1".
"type" specifies if your craft is shapeless, shaped, etc. It is shaped by default, if you don't specify anything.
Check lua_api.txt it should be on your docs folder. It has useful info.
BTW: you can't break by hand a node that is oddly_breakable_by_hand = 10 ...
Re: Post your modding questions here
I have a question about using minetest.after to call a function. Is it possible to use a variable time for minetest.after or does it have to be a static time? I wanted to try and use minetest.after vs a global step timer but I'm getting errors when using variables for the time. I wasn't sure if there was some way to make it see the variable as a number rather than a variable so it would work.
-
- Member
- Posts: 1233
- Joined: Tue Oct 23, 2012 12:59
- GitHub: Dragonop
- IRC: Dragonop
- In-game: Dragonop
- Location: Argentina
Re: Post your modding questions here
I'm making a mod, it adds a way to create clay with a machine, its formspec is mostly based in furnace.lua from default, but when there is no more room but there is still fuel (in this case called water) and an item (it uses compressed dirt), it stays active and won't change back into the inactive node (claycrafter:claycrafter_active to claycrafter:claycrafter), so far I have managed to make it change, but then it immediatly goes back to the active node (it flickers from active to inactive).
https://github.com/Dragonop/claycrafter ... rafter.lua
Also, feel free to make suggestions about the mod.
https://github.com/Dragonop/claycrafter ... rafter.lua
Also, feel free to make suggestions about the mod.
- Hybrid Dog
- Member
- Posts: 2835
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Post your modding questions here
use node timer instead of abmDragonop wrote:Also, feel free to make suggestions about the mod.
- everamzah
- Member
- Posts: 490
- Joined: Thu Jan 29, 2015 00:47
- GitHub: everamzah
- IRC: everamzah
- In-game: everamzah
Re: Post your modding questions here
The original furnace does not use a node timer, so why should Dragonop's claycrafter? I'd like to also point out that in minetest_game there are only two nodes which use node timers: Bones, and TNT. In my experience they are not always reliable.
-
- Member
- Posts: 818
- Joined: Tue Apr 14, 2015 01:59
- GitHub: raymoo
- IRC: Hijiri
- In-game: Raymoo + Clownpiece
Re: Post your modding questions here
There's no reason you can't use a variable for the time argument. Mind posting your error (including stack trace) and the relevant mod code? (In a spoiler, or a paste site like lpaste.net)isaiah658 wrote:I have a question about using minetest.after to call a function. Is it possible to use a variable time for minetest.after or does it have to be a static time? I wanted to try and use minetest.after vs a global step timer but I'm getting errors when using variables for the time. I wasn't sure if there was some way to make it see the variable as a number rather than a variable so it would work.
Every time a mod API is left undocumented, a koala dies.
Re: Post your modding questions here
I got it figured out now! What was happening is that when I changed my code over from using global step timers to minetest.after timers I overlooked something. I had a minetest.after with a 0 second delay and inside that there was something that was trying to get the time of day. Because the delay was 0 the world apparently doesn't load yet (did not know that) so the value was null/not a number. I was then trying to pass that bad value to another minetest.after as the time. Thank you for letting me know it was possible though! I would have given up thinking it just didn't want variables.There's no reason you can't use a variable for the time argument. Mind posting your error (including stack trace) and the relevant mod code? (In a spoiler, or a paste site like lpaste.net)
-
- Member
- Posts: 818
- Joined: Tue Apr 14, 2015 01:59
- GitHub: raymoo
- IRC: Hijiri
- In-game: Raymoo + Clownpiece
Re: Post your modding questions here
I want an item that's not used for digging to display wear. If I register it as a tool and override on_use, will it still dig?
Or maybe there is a better way to achieve this?
EDIT: Tried it, overriding on_use prevents it from digging.
Or maybe there is a better way to achieve this?
EDIT: Tried it, overriding on_use prevents it from digging.
Every time a mod API is left undocumented, a koala dies.
-
- Member
- Posts: 818
- Joined: Tue Apr 14, 2015 01:59
- GitHub: raymoo
- IRC: Hijiri
- In-game: Raymoo + Clownpiece
Re: Post your modding questions here
Does it matter if I put a non-number as the value for a custom group? E.g.
Code: Select all
groups = { favorite_color = "red" }
Every time a mod API is left undocumented, a koala dies.
Who is online
Users browsing this forum: No registered users and 16 guests