Post your modding questions here

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Mon Jan 18, 2016 18:54

moveto makes it look like object is grabbed and put to pos very fast, whereas
setpos makes it look like object is suddenly at pos
 

User avatar
iangp
Member
 
Posts: 114
Joined: Sat May 31, 2014 19:26
GitHub: 14NGiestas
IRC: iangp
In-game: iangp

Re: Post your modding questions here

by iangp » Mon Jan 18, 2016 19:06

@Hybrid Dog
it would be cool if this function uses "velocity" as a parameter ...
because this way there's no real reason for use that function... I can't see one...
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Post your modding questions here

by rubenwardy » Mon Jan 18, 2016 19:17

iangp wrote:@Hybrid Dog
it would be cool if this function uses "velocity" as a parameter ...
because this way there's no real reason for use that function... I can't see one...


It's for interpolation, to minimise the appearence of lag. When a player walks, you don't want them to suddenly disappear then reappear in a new place, you want the to slide across. Velocity results in extrapolation, if the player is moving/turning fast then it will be unpredictable, so you'd end up with this:

Image

^--- note the player starts here, at the bottom left.
 

User avatar
iangp
Member
 
Posts: 114
Joined: Sat May 31, 2014 19:26
GitHub: 14NGiestas
IRC: iangp
In-game: iangp

Re: Post your modding questions here

by iangp » Mon Jan 18, 2016 20:36

When a player walks, you don't want them to suddenly disappear then reappear in a new place, you want the to slide across.

Of course
It's for interpolation, to minimise the appearence of lag.

it's for: given a set of positions, if you want the player run through these points... you should use this function to the path seems more smooth...
Right?
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):
 

OmniStudent
Member
 
Posts: 261
Joined: Sat Nov 03, 2012 06:40

Re: Post your modding questions here

by OmniStudent » Tue Jan 19, 2016 04:52

Hello! Can anyone help me with this?

Topic: Need example code that "locks" doors when an object is rightpunched.
Reason: I want to make an "airlock" for entering dungeons.
More Info: I've only done the initial lua tutorial yet, but I am savvy in other languages.
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Tue Jan 19, 2016 18:02

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)?
 

Byakuren
Member
 
Posts: 441
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri

Re: Post your modding questions here

by Byakuren » Tue Jan 19, 2016 19:37

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.
 

User avatar
mahmutelmas06
Member
 
Posts: 355
Joined: Mon Mar 02, 2015 13:10
GitHub: mahmutelmas06
IRC: mahmutelmas06
In-game: masum

Re: Post your modding questions here

by mahmutelmas06 » Tue Jan 19, 2016 22:18

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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()


I want to drop an item from my vending machine mod if any of thoose above inserted.
But only the first one "default:gold_lump" works others not. So what punctuation to use for that ?
My Mods:

Beverage
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: Post your modding questions here

by kaeza » Wed Jan 20, 2016 00:33

The code:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
wieldname == (a or b or c)

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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
if wieldname == "foo" or wieldname == "bar" or wieldname == "baz" or ...

Or you can use a table mapping accepted values to `true`:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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


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.
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 | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

OmniStudent
Member
 
Posts: 261
Joined: Sat Nov 03, 2012 06:40

Re: Post your modding questions here

by OmniStudent » Wed Jan 20, 2016 05:32

[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.
 

Byakuren
Member
 
Posts: 441
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri

Re: Post your modding questions here

by Byakuren » Wed Jan 20, 2016 08:36

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.

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.
Every time a mod API is left undocumented, a koala dies.
 

User avatar
mahmutelmas06
Member
 
Posts: 355
Joined: Mon Mar 02, 2015 13:10
GitHub: mahmutelmas06
IRC: mahmutelmas06
In-game: masum

Re: Post your modding questions here

by mahmutelmas06 » Wed Jan 20, 2016 09:24

Thank you Kaeza for help.
I will use the list one
My Mods:

Beverage
 

bark
Member
 
Posts: 35
Joined: Thu Sep 24, 2015 13:25
In-game: bark

Re: Post your modding questions here

by bark » Wed Jan 20, 2016 14:30

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.
 

Dragonop
Member
 
Posts: 1178
Joined: Tue Oct 23, 2012 12:59
GitHub: Dragonop
IRC: Dragonop
In-game: Dragonop

Re: Post your modding questions here

by Dragonop » Wed Jan 20, 2016 15:39

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?
 

User avatar
jp
Member
 
Posts: 705
Joined: Wed Dec 18, 2013 09:03
GitHub: kilbith

Re: Post your modding questions here

by jp » Wed Jan 20, 2016 16:14

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?

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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: 2460
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Wed Jan 20, 2016 16:46

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.

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.
The owner is stored in meta: https://github.com/HybridDog/minetest_g ... it.lua#L87

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.

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)
 

User avatar
qwertymine3
Member
 
Posts: 194
Joined: Wed Jun 03, 2015 14:33
GitHub: Qwertymine
In-game: qwertymine3

Re: Post your modding questions here

by qwertymine3 » Wed Jan 20, 2016 17:00

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.


If you want to have object NPCS, you may want to look at the item frame mod.
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:
 

Dragonop
Member
 
Posts: 1178
Joined: Tue Oct 23, 2012 12:59
GitHub: Dragonop
IRC: Dragonop
In-game: Dragonop

Re: Post your modding questions here

by Dragonop » Wed Jan 20, 2016 17:22

jp wrote:-snip-

Thanks jp!
 

bark
Member
 
Posts: 35
Joined: Thu Sep 24, 2015 13:25
In-game: bark

Re: Post your modding questions here

by bark » Wed Jan 20, 2016 18:44

Thanks for the great input! Will look further into this.
 

OmniStudent
Member
 
Posts: 261
Joined: Sat Nov 03, 2012 06:40

Re: Post your modding questions here

by OmniStudent » Thu Jan 21, 2016 05:39

Hybrid Dog wrote:
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.

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.
The owner is stored in meta: https://github.com/HybridDog/minetest_g ... it.lua#L87



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.
 

User avatar
swordpaint12
Member
 
Posts: 187
Joined: Sat Aug 22, 2015 00:50
In-game: [swordpaint12][Belching_Balladeer]

Re: Post your modding questions here

by swordpaint12 » Sun Jan 24, 2016 00:00

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.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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},
})
Winter Cumicles
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.
Fruit!

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.
 

Dragonop
Member
 
Posts: 1178
Joined: Tue Oct 23, 2012 12:59
GitHub: Dragonop
IRC: Dragonop
In-game: Dragonop

Re: Post your modding questions here

by Dragonop » Sun Jan 24, 2016 01:12

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?

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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"},
         }
})

Added replacements, so you get the bucket back after using the water.
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 ...
 

isaiah658
Member
 
Posts: 14
Joined: Sun Jan 24, 2016 14:58

Re: Post your modding questions here

by isaiah658 » Sun Jan 24, 2016 15:07

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.
 

Dragonop
Member
 
Posts: 1178
Joined: Tue Oct 23, 2012 12:59
GitHub: Dragonop
IRC: Dragonop
In-game: Dragonop

Re: Post your modding questions here

by Dragonop » Sun Jan 24, 2016 15:57

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.
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Sun Jan 24, 2016 16:55

Dragonop wrote:Also, feel free to make suggestions about the mod.

use node timer instead of abm
 

User avatar
everamzah
Member
 
Posts: 490
Joined: Thu Jan 29, 2015 00:47
GitHub: everamzah
IRC: everamzah
In-game: everamzah

Re: Post your modding questions here

by everamzah » Sun Jan 24, 2016 17:38

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.
 

Byakuren
Member
 
Posts: 441
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri

Re: Post your modding questions here

by Byakuren » Sun Jan 24, 2016 18:55

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.

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)
Every time a mod API is left undocumented, a koala dies.
 

isaiah658
Member
 
Posts: 14
Joined: Sun Jan 24, 2016 14:58

Re: Post your modding questions here

by isaiah658 » Mon Jan 25, 2016 01:39

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)


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.
 

Byakuren
Member
 
Posts: 441
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri

Re: Post your modding questions here

by Byakuren » Mon Jan 25, 2016 03:35

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.
Every time a mod API is left undocumented, a koala dies.
 

Byakuren
Member
 
Posts: 441
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri

Re: Post your modding questions here

by Byakuren » Mon Jan 25, 2016 04:39

Does it matter if I put a non-number as the value for a custom group? E.g.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
groups = { favorite_color = "red" }
Every time a mod API is left undocumented, a koala dies.
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 10 guests

cron