unknown block callback?

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

unknown block callback?

by taikedz » Thu Jul 21, 2016 19:31

Hello

I did a quick search for "Unknown blocks" in this forum and the related-projects forum, and the dev wiki, and turned up suprisingly little.... so here's my question:

Would it be of relevance/desire to add a "on_unknownblock(itemstring)", "on_unknownitem" and "on_unknownentity(itemstring)" set of callbacks so that we could control behaviour on "Unknown"?

So that when a mod is removed or changed, instead of having lots of unknown blocks lying around we could define their replacements dynamically

For example this pseudocode (I am gradually learning lua, the below may contain some python or bash :-/)

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
global.on_unknowitem = function(itemstring)
    case itemstring in:
        "farming:bread":
            return "default:apple 10"
        "ethereal:fancywood":
            return "default:wood_pine"
    end-case
    return itemstring -- just leave it actually unknown
end-function

global.on_unknownblock = function(itemstring)
    return "default:dirt" -- just replace any block with dirt
end-function

global.on_unknownentity = function(itemstring)
    return null -- remove the item from the world
     -- return "mobs:rat" -- example of replacing all unknown mobs with rats...
end-function
 

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: unknown block callback?

by taikedz » Wed Aug 10, 2016 13:17

Not of interest? Or is there already a way to achieve this?
 

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

Re: unknown block callback?

by rubenwardy » Wed Aug 10, 2016 13:32

The name of the unknown node is "unknown", I'm not sure if unknown items are aliases to this. If unknown nodes are aliased to "unknown" you could write an ABM.
 

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: unknown block callback?

by taikedz » Wed Aug 10, 2016 16:46

Hmmm it's not particularly granular, and wont cover craft items and mobs...

I'll have a try with the abm nonetheless.
 

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

Re: unknown block callback?

by kaeza » Wed Aug 10, 2016 22:30

Not exactly what you're looking for, but try "clean" mod. It needs manual configuration though.
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
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: unknown block callback?

by taikedz » Thu Aug 11, 2016 08:59

kaeza - that is much closer to what I am looking for, thanks! As long as I or a player do/es no have to manually go replacing nodes and the players don't have to see the old nodes, that's fine :-p

I'll probably need to combine it with a perl script to extract all nodes, entities and tools from a mod dir to automatically generate the pre-config, and then I'll be good to do some mod cleanup!

Merci buckets :-p

Huzzah!
 


Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 32 guests

cron