Save empty strings in meta

User avatar
runs
Member
 
Posts: 884
Joined: Sat Oct 27, 2018 08:32
GitHub: runsy

Save empty strings in meta

by runs » Fri Aug 23, 2019 11:15

if I do,

stack_meta:set_string("data", "")

It is not saved. Why? It is not nil...
 

User avatar
Pyrollo
Member
 
Posts: 323
Joined: Mon Jan 08, 2018 15:14
Location: Paris
GitHub: pyrollo
In-game: Naj
 

User avatar
runs
Member
 
Posts: 884
Joined: Sat Oct 27, 2018 08:32
GitHub: runsy

Re: Save empty strings in meta

by runs » Fri Aug 23, 2019 17:04

Pyrollo wrote:https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L5307


Oh I see now. But a bad implementation. in Lua and majority of programming languages "" means 'Empty' not nil.

Maybe a 'remove_key(key)' would be a better solution.
 

User avatar
Krock
Developer
 
Posts: 4389
Joined: Thu Oct 03, 2013 07:48
Location: Switzerland
GitHub: SmallJoker

Re: Save empty strings in meta

by Krock » Sat Aug 24, 2019 17:20

You can still get the string reliably by using `get_string()`.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>
 


Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 2 guests