Post your modding questions here

User avatar
Lejo
Member
Posts: 718
Joined: Mon Oct 19, 2015 16:32
GitHub: Lejo1
In-game: Lejo

Re: Post your modding questions here

by Lejo » Post

Thanks a lot so it works!

Sires
Member
Posts: 190
Joined: Mon Jan 02, 2017 21:00
GitHub: Sires0
IRC: Sires
In-game: Sires Sores Siri Seris or anything ppl call me
Location: :noitacoL

Well, halp to delete metadata

by Sires » Post

Well I searched a bit in the minetest forum, used some advanced search thingy and Ctrl+F ed some pages of modding questions, and I really don't want to check 159 pages, so my question is: How to delete an specific metadata. Something like, the metadata is:
a = false
b = true
c = "sth"
d = 1
So, lets supposed I want to delete the 'd', is there other way to delete it without doing some stuff using to_table and from_table methods ?
I don't have anything important to say.

Gerald
Member
Posts: 93
Joined: Sun Dec 28, 2014 10:35
In-game: gerald7
Location: Germany

Re: Well, halp to delete metadata

by Gerald » Post

Sires wrote:Well I searched a bit in the minetest forum, used some advanced search thingy and Ctrl+F ed some pages of modding questions, and I really don't want to check 159 pages, so my question is: How to delete an specific metadata. Something like, the metadata is:
a = false
b = true
c = "sth"
d = 1
So, lets supposed I want to delete the 'd', is there other way to delete it without doing some stuff using to_table and from_table methods ?
I think meta:set_string("d", nil) works.

Sires
Member
Posts: 190
Joined: Mon Jan 02, 2017 21:00
GitHub: Sires0
IRC: Sires
In-game: Sires Sores Siri Seris or anything ppl call me
Location: :noitacoL

Re: Well, halp to delete metadata

by Sires » Post

Gerald wrote:
Sires wrote:Well I searched a bit in the minetest forum, used some advanced search thingy and Ctrl+F ed some pages of modding questions, and I really don't want to check 159 pages, so my question is: How to delete an specific metadata. Something like, the metadata is:
a = false
b = true
c = "sth"
d = 1
So, lets supposed I want to delete the 'd', is there other way to delete it without doing some stuff using to_table and from_table methods ?
I think meta:set_string("d", nil) works.
Nope, I tested it, it just sets the data to nil, but the data key still exists in the metadata
I don't have anything important to say.

Gerald
Member
Posts: 93
Joined: Sun Dec 28, 2014 10:35
In-game: gerald7
Location: Germany

Re: Well, halp to delete metadata

by Gerald » Post

Sires wrote:
Gerald wrote: I think meta:set_string("d", nil) works.
Nope, I tested it, it just sets the data to nil, but the data key still exists in the metadata
If I read the result of minetest.serialize(meta:to_table()) the key is gone.
What is the problem of a dummy value anyway?

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

Re: Well, halp to delete metadata

by Nyarg » Post

Gerald wrote:If I read the result of minetest.serialize(meta:to_table()) the key is gone.
What is the problem of a dummy value anyway?
I think a meta isn't properly table or isn't accessible by native Lua garbage collector.
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 )

Sires
Member
Posts: 190
Joined: Mon Jan 02, 2017 21:00
GitHub: Sires0
IRC: Sires
In-game: Sires Sores Siri Seris or anything ppl call me
Location: :noitacoL

Re: Well, halp to delete metadata

by Sires » Post

Nyarg wrote:
Gerald wrote:If I read the result of minetest.serialize(meta:to_table()) the key is gone.
What is the problem of a dummy value anyway?
I think a meta isn't properly table or isn't accessible by native Lua garbage collector.
Well btw this gave-me an idea, create an function using from_table that deletes every nil value there, I think this may work
I don't have anything important to say.

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

There's one thing you need to know about LUA: There is no difference between a variable being undefined and a variable being nil, it's simply the same. So there can't be any keys inside a table whose value is 'nil'.
AFAIK, the minetest meta treats the empty string ("") as symbol for "not defined", so accessing undefined meta keys will always give you "" and set_string(key, "") is equivalent to set_string(key, nil)
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: Post your modding questions here

by texmex » Post

Hello fellow mese chasers. I want to integrate lua-matrix (the chat protocol) in a mod with the ultimate goal of Matrix.org bidirectional message sync, much like the IRC mod. This requires cjson however, which is binary. Is there some way around having to deal with binaries? Can they even be included in a mod?

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

you don't need cjson, minetest already has a JSON interface built in.
minetest.json_encode() / minetest.json_decode()
You just need to change all occurences of cjson calls to the minetest ones.
The same applies for HTTP
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: Post your modding questions here

by texmex » Post

orwell wrote:you don't need cjson, minetest already has a JSON interface built in.
minetest.json_encode() / minetest.json_decode()
You just need to change all occurences of cjson calls to the minetest ones.
The same applies for HTTP
Oh okay, that's helpful and sound much easier than binary headache as well. Thank you orwell!

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

json in mt? wow.
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

User avatar
Lone_Wolf
Member
Posts: 2578
Joined: Sun Apr 09, 2017 05:50
GitHub: LoneWolfHT
IRC: LandarVargan
In-game: LandarVargan

Re: Post your modding questions here

by Lone_Wolf » Post

If I want to learn lua where should I go? I'm hoping for an easy internet program. I will have learnt C before then.
My ContentDB -|- Working on CaptureTheFlag -|- Minetest Forums Dark Theme!! (You need it)

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

A Wonderful World

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

Re: Post your modding questions here

by Nyarg » Post

Lone_Wolf wrote:If I want to learn lua where should I go?
viewtopic.php?f=3&t=17851#p276215
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 )

Robsoie
Member
Posts: 104
Joined: Fri Apr 29, 2016 16:22

Re: Post your modding questions here

by Robsoie » Post

Hello,

On a specific world using Minetest 0.4.16 on win32, i have buildings made rather far from the new player starting position.
So after looking if it was possible to set on a specific world a new player new start position instead of using a conf entry that would then impact all worlds, i found this :
viewtopic.php?p=70904#p70904

That after testing unfortunately didn't worked for new player, only for respawning one.

After looking around , i found that there was a command for new player instead of respawn one.

So here was the content for this worldname\worldmods\spawn\init.lua

Code: Select all

minetest.register_on_newplayer(function(player)
    player:setpos({x=2298.2, y=105, z=2185.4})
    return true
end)
the coordinates i obtained them by placing myself exactly where i wanted the new player spawn point to be, exited the world and looked into the worldname\players\ file

Now i delete the singleplayer file from worldname\players\ to test this.
Apparently it works as i'm not spawning at all where i was spawning before as a new player.
But there's a problem, and a very big one if you compare the coordinate from the script to the actual coordinate the new singleplayer is sent to :
Image
(above is an extract of the content of worldname\players\singleplayer file created after spawning and below is the script)

why is the X and Z multiplied by 10 ? (the Y probably too, as i spawned above clouds and when i exited the world i had left the character falling until underwater

The only way i found to fix that was to change

Code: Select all

    player:setpos({x=2298.2, y=105, z=2185.4})
into

Code: Select all

    player:setpos({x=229.82, y=10.5, z=218.54})
And only then the new player will then spawn at the desired X/Y/Z (x=2298.2, y=105, z=2185.4), but why do i have to input coordinates divided by 10 in comparison to the real ones ?

EDIT :
i found a reason, in fact the coordinate that are wrong are the ones from worldname\players\ , because if ingame i press F5 i can see the coordinate being 229.82, y=10.5, z=218.54 while in the worldname\players\ they're multiplied by 10 for some reason.
Very odd as i don't use a mod messing with the coordinate system in that world.

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

I noticed that some data is disappearing from my tables (after any time).
Does the Lua automatically delete data? How can I know if this is my case?

http://www.lua.org/manual/5.1/manual.html#2.10

User avatar
Lone_Wolf
Member
Posts: 2578
Joined: Sun Apr 09, 2017 05:50
GitHub: LoneWolfHT
IRC: LandarVargan
In-game: LandarVargan

Re: Post your modding questions here

by Lone_Wolf » Post

I'm making a mod that has admin armor from stu's mod. The only change is the textures which are black.
I know 0.05% lua. This is my first problem: [Censored]/Desktop\MT\minetest\bin\..\mods\adminarmor\init.lua: No such file or directory
2017-06-19 11:59:01: ERROR[Main]: Check debug.txt for details.
My ContentDB -|- Working on CaptureTheFlag -|- Minetest Forums Dark Theme!! (You need it)

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

All mods need to have an init.lua file (even if it is useless)
Does the mod have this file?
Maybe you can give more details of the problem (debug.txt).

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

Lone_Wolf wrote:I'm making a mod that has admin armor from stu's mod. The only change is the textures which are black.
I know 0.05% lua. This is my first problem: [Censored]/Desktop\MT\minetest\bin\..\mods\adminarmor\init.lua: No such file or directory
2017-06-19 11:59:01: ERROR[Main]: Check debug.txt for details.
you need to create a folder and name it adminarmor or admin_armor (which ever you prefer)
in this folder you will create another folder and name it textures. (place you textures here), where ever you list these textures, the names have to match the names in this folder.

Next you will then create some new .txt files
1. init.lua
2. dependencies.txt (in here you simply type the word default, or the name of stu's armor mod)
3. description.txt (here, type a brief description of the mod) one or two sentences.
4. license.txt (you need to list the license information here)
5. mod.conf (in here type name = adminarmor) (you have to keep the name the same everywhere)

for the init.lua, you can copy and paste the code related to the first set of armor from stu's mod..., and replace all instances of his mod's name, with your mod's name.

such as:

Code: Select all

minetest.register_node("adminarmor:blackhelmet", {
	description = "Black Admin Helmet",
	tiles = {"adminarmor_black_helmet"},
and so on
and remember to add credit and thanks to stu
A Wonderful World

User avatar
Lone_Wolf
Member
Posts: 2578
Joined: Sun Apr 09, 2017 05:50
GitHub: LoneWolfHT
IRC: LandarVargan
In-game: LandarVargan

Re: Post your modding questions here

by Lone_Wolf » Post

Ok thanks. What license would you suggest?
Question(s):
Is this needed at the beginning of the init.lua?

Code: Select all

local S = function(s) return s end
if minetest.global_exists("intllib") then
	S = intllib.Getter()
end
Last edited by Lone_Wolf on Mon Jun 19, 2017 23:33, edited 1 time in total.
My ContentDB -|- Working on CaptureTheFlag -|- Minetest Forums Dark Theme!! (You need it)

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

My code was just an example showing how you would replace those names with your own, copy the code from the armor mod.
use the license the mod you are copying the code from.
the textures you can choose a license if you hand made them, if they are simply a copy of the original textures, and you simply recolored them, use the license for the original textures.
A Wonderful World

User avatar
Lone_Wolf
Member
Posts: 2578
Joined: Sun Apr 09, 2017 05:50
GitHub: LoneWolfHT
IRC: LandarVargan
In-game: LandarVargan

Re: Post your modding questions here

by Lone_Wolf » Post

I think I got the code copied correctly. Link to github here: adminarmor
My ContentDB -|- Working on CaptureTheFlag -|- Minetest Forums Dark Theme!! (You need it)

User avatar
Lone_Wolf
Member
Posts: 2578
Joined: Sun Apr 09, 2017 05:50
GitHub: LoneWolfHT
IRC: LandarVargan
In-game: LandarVargan

Re: Post your modding questions here

by Lone_Wolf » Post

-_- xD
Image
My ContentDB -|- Working on CaptureTheFlag -|- Minetest Forums Dark Theme!! (You need it)

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

remove the .txt at the end of init.lua
A Wonderful World

Locked

Who is online

Users browsing this forum: No registered users and 12 guests