Post your modding questions here

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

Re: Post your modding questions here

by Byakuren » Wed Mar 23, 2016 07:53

Except you probably want to make sound a local var instead.
Every time a mod API is left undocumented, a koala dies.
 

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 » Wed Mar 23, 2016 10:16

You should rarely use global variables as they will be present in other mods. You should only create global variables with the same name as your mod.
 

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

Re: Post your modding questions here

by Hybrid Dog » Wed Mar 23, 2016 10:48

VaE adds a vector.dot and people may think it's added by builtin, so they don't notice that their mod crashes if pipeworks isn't installed
 

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 » Wed Mar 23, 2016 13:11

rubenwardy wrote:You should rarely use global variables as they will be present in other mods. You should only create global variables with the same name as your mod.


hmm This is a convention ? I understand the fact, avoid using global vars, because they can conflict with other mods but if I use something like that, would it be ok?:
nameofmymod_sound = 'no'
or local sound = 'no' also works inside the func?

another Q: This is documented on wiki or on somewhere?, I'm just can't remember...
That was just a "speed coding"...
Reading this I think I should review some code on my mods... XD
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 » Wed Mar 23, 2016 14:06

It's just good practice not to. Instead of nameofmymod_sound you should do nameofmymod.sound or a local variable.
Global variables are the best way to communicate between files. The alternative is passing parameters between files is a bit weird.

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
-- You can do this if you want want to make a global variable,
-- but I usually use nameofmod.sound as I prefer that personally.
local sound = "no"
dofile(minetest.get_modpath() .. "/other.lua", sound)


This doesn't seem to be mentioned anyway, except a little bit by me here: http://rubenwardy.com/minetest_modding_ ... and-global
 

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 » Wed Mar 23, 2016 14:31

Well,I finally bookmarked your modding book Sir Ruben Wardy XD, It's a very useful reference material.
So, at end the code seems like that:
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 sound = 'no'
minetest.register_tool("headphones:1headphones", {
   description = "Headphones Test Song",
   inventory_image = "testh.bmp",

   on_use = function()
        if sound == 'no' then
            sound = minetest.sound_play("test") --keep the "reference" of the sound
        else
            minestes.sound_stop(sound) --stop the sound
            sound = 'no'
       end
   end,
})
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):
 

User avatar
MineYoshi
Member
 
Posts: 4267
Joined: Wed Jul 08, 2015 13:20
GitHub: MineYosh
IRC: MineYoshi
In-game: Kirby_Retro

Re: Post your modding questions here

by MineYoshi » Wed Mar 23, 2016 21:02

I think i am a little dumb, or i don't know the "enough" yet!

Anyways THX!
People talk about freedom of speech, so i'll say that God exists.
Open your eyes!! See The big unicorn conspiracy.!! :D The government has been lying to us about unicorns!!
"I've learned there are three things you don't discuss with people: religion, politics and the Great Pumpkin" - Linus Van Pelt
I'm the Officially 1st ABJist in the world ( ͡° ͜ʖ ͡°)
 

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 » Wed Mar 23, 2016 22:15

MineYoshi wrote:I think i am a little dumb, or i don't know the "enough" yet!

Anyways THX!

Not really, you just need practice.
make little challenges to yourself:
exercises, big projects, read some good book/e-book (not only about Lua),
It comes along with time, so be patient.

And of course think out the box :D
creativity helps to find a nicer way to solve a problem.
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Post your modding questions here

by Don » Wed Mar 23, 2016 22:27

iangp wrote:
MineYoshi wrote:I think i am a little dumb, or i don't know the "enough" yet!

Anyways THX!

Not really, you just need practice.
make little challenges to yourself:
exercises, big projects, read some good book/e-book (not only about Lua),
It comes along with time, so be patient.

And of course think out the box :D
creativity helps to find a nicer way to solve a problem.

I agree! I have been slowly learning. I still have a lot more to learn. Every challenge I give myself makes me have a little more knowledge. Keep trying.
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

User avatar
MineYoshi
Member
 
Posts: 4267
Joined: Wed Jul 08, 2015 13:20
GitHub: MineYosh
IRC: MineYoshi
In-game: Kirby_Retro

Re: Post your modding questions here

by MineYoshi » Wed Mar 23, 2016 23:27

Don wrote:
iangp wrote:
MineYoshi wrote:I think i am a little dumb, or i don't know the "enough" yet!

Anyways THX!

Not really, you just need practice.
make little challenges to yourself:
exercises, big projects, read some good book/e-book (not only about Lua),
It comes along with time, so be patient.

And of course think out the box :D
creativity helps to find a nicer way to solve a problem.

I agree! I have been slowly learning. I still have a lot more to learn. Every challenge I give myself makes me have a little more knowledge. Keep trying.


THX for motivation i will try to be better!

=D
People talk about freedom of speech, so i'll say that God exists.
Open your eyes!! See The big unicorn conspiracy.!! :D The government has been lying to us about unicorns!!
"I've learned there are three things you don't discuss with people: religion, politics and the Great Pumpkin" - Linus Van Pelt
I'm the Officially 1st ABJist in the world ( ͡° ͜ʖ ͡°)
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Post your modding questions here

by Don » Wed Mar 23, 2016 23:52

Remember that failing is much better than not trying at all. Some of the best things in life are the result of failures.
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

User avatar
MineYoshi
Member
 
Posts: 4267
Joined: Wed Jul 08, 2015 13:20
GitHub: MineYosh
IRC: MineYoshi
In-game: Kirby_Retro

Re: Post your modding questions here

by MineYoshi » Wed Mar 23, 2016 23:54

Good advice...

Many people said that to me too...
People talk about freedom of speech, so i'll say that God exists.
Open your eyes!! See The big unicorn conspiracy.!! :D The government has been lying to us about unicorns!!
"I've learned there are three things you don't discuss with people: religion, politics and the Great Pumpkin" - Linus Van Pelt
I'm the Officially 1st ABJist in the world ( ͡° ͜ʖ ͡°)
 

User avatar
BrunoMine
Member
 
Posts: 902
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine

work with String

by BrunoMine » Fri Mar 25, 2016 17:04

How can I check each letter in a string?
How can I check the amount of characters in a string?
I want to create a verification loop of characters in a string.
 

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 » Fri Mar 25, 2016 17:10

For length: #str
For character: str.sub(i, 1)
 

User avatar
Foghrye4
Member
 
Posts: 24
Joined: Sun Mar 13, 2016 13:38
IRC: Foghrye4
In-game: Foghrye4

Re: Post your modding questions here

by Foghrye4 » Sat Mar 26, 2016 07:33

How i can hook up on existing player inventory functions like in detached inventory functions "on_put","on_take","on_move" and so on? I mean a one, that are returned by "player:get_inventory()".
 

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 » Sun Mar 27, 2016 13:08

i use formspecs to make a coffee machine but i need help
can i use itemgroup instead of an item ?

for exp instead of "flowers:tulip" i want to use group flowers

inv:contains_item("src", ItemStack("flowers:tulip"))
My Mods:

Beverage
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Post your modding questions here

by Don » Sun Mar 27, 2016 19:54

mahmutelmas06 wrote:i use formspecs to make a coffee machine but i need help
can i use itemgroup instead of an item ?

for exp instead of "flowers:tulip" i want to use group flowers

inv:contains_item("src", ItemStack("flowers:tulip"))

You can see how to do groups in this mod
viewtopic.php?f=11&t=11780
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

Lucki
New member
 
Posts: 1
Joined: Wed Mar 30, 2016 13:55
In-game: Lucki

Re: Post your modding questions here

by Lucki » Wed Mar 30, 2016 14:34

How I can check, a player is death? If this happens I want to Drop an Item.
And sorry for my english because i´m from germany and 12 years old.
I want to make a "Capture the FlagMod"
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Post your modding questions here

by Don » Wed Mar 30, 2016 14:40

Lucki wrote:How I can check, a player is death? If this happens I want to Drop an Item.
And sorry for my english because i´m from germany and 12 years old.
I want to make a "Capture the FlagMod"

Use this

http://dev.minetest.net/minetest.register_on_dieplayer
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

User avatar
ynong123
Member
 
Posts: 17
Joined: Fri Mar 11, 2016 13:24
GitHub: ynong123
IRC: ynong123
In-game: ynong123

Post A Topic

by ynong123 » Fri Apr 01, 2016 07:12

Question: How to post a topic?
Reason: I want to release a mod.
 

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 » Fri Apr 01, 2016 07:26

rubenwardy wrote:For length: #str
For character: str.sub(i, 1)

Correction: `str:sub(i, i)`

Arguments are start and end pos, not start pos and length.
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
 

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

Re: work with String

by kaeza » Fri Apr 01, 2016 07:31

BrunoMine wrote:[...]I want to create a verification loop of characters in a string.

Patterns are probably faster. For example, this code tells you if you have any non-alphanumeric chars:

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 str:find("[^A-Za-z0-9]") then
  error("please only use letters or digits")
end


Read more about patterns here.

Edit: If you need to know the position for whatever reason:
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 start, fin, what = str:find("[^A-Za-z0-9]")
if start then
  error("character "..what.." (at position "..start..") is not allowed")
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 | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

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

Re: Post your modding questions here

by jp » Fri Apr 01, 2016 09:31

This would be even simpler using :

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
str:find("%W")
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Post A Topic

by Don » Fri Apr 01, 2016 12:10

ynong123 wrote:Question: How to post a topic?
Reason: I want to release a mod.

You release a mod in the wip mods section.
When the mod is complete and the forum topic is set up following the guidelines then you request that your mod gets moved to releases.
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

User avatar
MineYoshi
Member
 
Posts: 4267
Joined: Wed Jul 08, 2015 13:20
GitHub: MineYosh
IRC: MineYoshi
In-game: Kirby_Retro

Re: Post your modding questions here

by MineYoshi » Fri Apr 01, 2016 20:59

A question!

How make when i use an item send a message to the player who have it?

It's for a very big project, it's an easter egg!
People talk about freedom of speech, so i'll say that God exists.
Open your eyes!! See The big unicorn conspiracy.!! :D The government has been lying to us about unicorns!!
"I've learned there are three things you don't discuss with people: religion, politics and the Great Pumpkin" - Linus Van Pelt
I'm the Officially 1st ABJist in the world ( ͡° ͜ʖ ͡°)
 

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

Re: Post your modding questions here

by Hybrid Dog » Sat Apr 02, 2016 19:10

http://dev.minetest.net/minetest.register_node#on_use

minetest.chat_send_player(player:get_player_name(), "some text")
 

User avatar
MineYoshi
Member
 
Posts: 4267
Joined: Wed Jul 08, 2015 13:20
GitHub: MineYosh
IRC: MineYoshi
In-game: Kirby_Retro

Re: Post your modding questions here

by MineYoshi » Mon Apr 04, 2016 00:37

how to make, when i click a chest of one space(left click) with a craft_item, drop the item in the chest?
People talk about freedom of speech, so i'll say that God exists.
Open your eyes!! See The big unicorn conspiracy.!! :D The government has been lying to us about unicorns!!
"I've learned there are three things you don't discuss with people: religion, politics and the Great Pumpkin" - Linus Van Pelt
I'm the Officially 1st ABJist in the world ( ͡° ͜ʖ ͡°)
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Post your modding questions here

by Don » Mon Apr 04, 2016 04:34

MineYoshi wrote:how to make, when i click a chest of one space(left click) with a craft_item, drop the item in the chest?

Use on_use.
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

User avatar
BrunoMine
Member
 
Posts: 902
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine

Re: Post your modding questions here

by BrunoMine » Mon Apr 11, 2016 17:46

How can I place an item in a biome.
For example: I want to appear in a chest in a jungle forest.

I can not check the area next to jungle trees that have just been generated.
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Post your modding questions here

by Don » Mon Apr 11, 2016 19:11

BrunoMine wrote:How can I place an item in a biome.
For example: I want to appear in a chest in a jungle forest.

I can not check the area next to jungle trees that have just been generated.

Are you trying to do it when the map loads or could you use an abm or lbm to make it place?
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron