[Mod] MAPP - map for Minetest - optimized! [0.2.4]

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

[Mod] MAPP - map for Minetest - optimized! [0.2.4]

by 4aiman » Wed Feb 27, 2013 23:26

Here how it looks like:
Image

How to use this: craft a map block out of 4 dirts:
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
none dirt none
dirt dirt dirt

Take a map into your hands and just left-click! As easy as that! ;)

Licence: WTFPL
Download: https://github.com/4aiman/mapp/archive/master.zip
Includes 16*16 and 32*32 textures!

Credit goes to:
pandaro, who made player_radar mod.
I looked into the "player_radar" mod and came up with idea to use smth similar for maps.
So I wrote a simple test-mod and start to actually test it.
RealBadAngel, who made map a tool, not a block that must be punched :)
Calinou for ideas about the playermark.
kaeza and Splizard for optimizing the code.
Last edited by 4aiman on Fri Mar 08, 2013 16:03, edited 1 time in total.
 

lkjoel
Member
 
Posts: 778
Joined: Wed Feb 29, 2012 19:27

by lkjoel » Wed Feb 27, 2013 23:56

COOL!!! +1000
My mods: The Nether | Doctor Who (WIP)

I have quit minetest ... again. I am heavily unimpressed by both the game and the community.
 

User avatar
0gb.us
Member
 
Posts: 841
Joined: Sun Sep 16, 2012 01:55

by 0gb.us » Thu Feb 28, 2013 01:47

Oh? That's awesome!

If this could be incorporated into some sort of in-menu (inventory_plus) map, that would be even better. Once you lay the foundation, the rest would be easy. I'll swap on_punch() for on_receive_fields(), and add it to my world.

I'll have to keep an eye on this and see how it progresses.
 

Josh
Member
 
Posts: 1146
Joined: Fri Jun 29, 2012 23:11

by Josh » Thu Feb 28, 2013 02:06

Looking good! however i would prefer the map to appear in the players hand and not show up when
you punch a block. But great work 4aiman :)


P.S: What do you mean by: Dont use this in your playing world? Can't we use it in singleplayer?
 

User avatar
Traxie21
Member
 
Posts: 753
Joined: Mon Dec 31, 2012 10:48

by Traxie21 » Thu Feb 28, 2013 02:10

You can't really make the map appear in the player's hand.


And I think he means that it might corrupt your world.
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Thu Feb 28, 2013 05:52

I mean that cycles like the one in this prototype is very slow.
But what's more important, they STOP client-server communication ('cause server is too busy to answer it's clients).
I tested that on 5 or 6 worlds and have to delete some of them, 'cause (after 4th-8th punch of a map node) server went "silent" (which is normal by itself - the server was computing a map formspec). Sometimes I just wait a little and server begins to response once again. But sometimes even after restarting minetest maps with map_node refuse to load. I mean, I can load the game, but it looks like the game can't load any blocks than it already loaded. That leaves me in a 30*30*30 world (approx.) w/o any way to dig smth and get node_drops (well, that's natural thing when server's too busy).

The main problem is how to allow server make it's work while still be responsible.
Smth like Application.ProcessMessages would be great. Or creating a different thread would be great.
I'll see what I can do wit what we have atm.

PS: if anyone will use this/have some ideas on this, I encourage all of those people to post here their suggestions/code samples/links to your modifications/links to things inspired by this prototype. One can never know what this thing may lead to ;)
 

User avatar
jojoa1997
Member
 
Posts: 2890
Joined: Thu Dec 13, 2012 05:11

by jojoa1997 » Thu Feb 28, 2013 12:20

could you have paper do this like looking at a map.
P=paper, C=coal
PPP
PCP
PPP
coal is to implement writing.
Coding;
1X coding
3X debugging
12X tweaking to be just right
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Fri Mar 01, 2013 20:55

UPDATE!
+ Different heights distinction
+ Shows map depending on map_block's position
+ Underground map_block will show you map of the cave you're in
 

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

by VanessaE » Fri Mar 01, 2013 22:05

Have you considered making this an item that you punch with (like using a tool or eating an apple) to display the map? I think that would be more natural than placing the block on the ground and punching it.
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

User avatar
RealBadAngel
Member
 
Posts: 556
Joined: Wed Jul 18, 2012 16:30

by RealBadAngel » Fri Mar 01, 2013 22:31

map as tool, just use it
http://realbadangel.pl/mapp.zip
 

User avatar
cHyper
Member
 
Posts: 587
Joined: Fri May 06, 2011 08:49
IRC: cHyper
In-game: cHyper

by cHyper » Sat Mar 02, 2013 07:03

awesome mod...
--------------------------------------------------------
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Sat Mar 02, 2013 07:22

VanessaE wrote:Have you considered making this an item that you punch with (like using a tool or eating an apple) to display the map? I think that would be more natural than placing the block on the ground and punching it.

This mod is merely a prototype - I just testing things, so that's why I didn't make it "more natutal" :)

RealBadAngel, thanks for tweaking this towards peoples wishes! ;)
Also, two words: naming convention. It's "mapp:map", not "map:map". ;)

I've updated this mod at GitHub, so link from the first post now leads to a tool. Those, who for any reason still want a block, look into init_.lua.

Any ideas for adding player mark? Not only a point, but rather an arrow, which shows what wilder is looking at?
[Rotate modifier can't rotate less than 90 deg...
Last edited by 4aiman on Sat Mar 02, 2013 07:30, edited 1 time in total.
 

User avatar
pandaro
Member
 
Posts: 266
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro

by pandaro » Sat Mar 02, 2013 18:18

Any ideas for adding player mark? Not only a point, but rather an arrow, which shows what wilder is looking at?
player:getyaw()

and +1 good work
sorry for bad english
Linux debian 7 wheezy 64
kde
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Sat Mar 02, 2013 18:48

pandaro wrote:player:getyaw()

I mean, how to rotate texture to show that yaw, not how to get it ;)
 

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

by kaeza » Sat Mar 02, 2013 19:04

Hmm... this may sound complicated, but how about you draw a bunch of textures for, let's say, angles 0-90 in 10deg increments, and use them as a base, rotating to get the other angles as needed?
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
Calinou
Member
 
Posts: 3124
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou

by Calinou » Sat Mar 02, 2013 20:52

Some very basic textures (4 is probably enough, will give 16 directions by rotating them in the mod):
Image
Image
Image
Image
License: WTFPL
Last edited by Calinou on Sat Mar 02, 2013 20:53, edited 1 time in total.
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Sun Mar 03, 2013 15:42

Hmm.. 4 textures + rotate... Thanks, kaeza, Calinou, I'll add this ;)
Added!
Last edited by 4aiman on Sun Mar 03, 2013 21:30, edited 1 time in total.
 

User avatar
Inocudom
Member
 
Posts: 2889
Joined: Sat Sep 29, 2012 01:14
IRC: Inocudom
In-game: Inocudom

by Inocudom » Tue Mar 05, 2013 22:17

A feature that turns whether liquids show on the map on or off would be a good idea (or the liquids could be transparent with the nodes below showing in them.)
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Wed Mar 06, 2013 11:50

Inocudom wrote:A feature that turns whether liquids show on the map on or off would be a good idea (or the liquids could be transparent with the nodes below showing in them.)


I had the same idea ;) Will implement once be at home.

Also, there are some questions:
1. Could anyone teach me how to "cut" a single frame from a sprite-sheet? Things like flowing water and lava can be shown using water/lava~source texture, but what about animated torches & grass and other things?
2. I wanted to hide landscape if player is underground. I made a func is_ug(pos) that checks that.
But the problem is where to stop. Currently I go up if the block at y=player.pos.y in not an "air" block and go down if it is.
But imagine a cave, that splits into to paths each going in the opposite direction to another: one up goes and one goes down. So, my question is about logic:

How can I know when I need to go DOWN instead of going UP, if the block at y=player.pos.y in not an "air"?

Currently I go 10-15 blocks down and if there's still non-air block then I go up. Is there any better way to draw only what player would see, e.g w/o drawing the surface?
 

User avatar
Splizard
Member
 
Posts: 220
Joined: Wed Jan 25, 2012 07:20
GitHub: Splizard
IRC: Splizard
In-game: Splizard

by Splizard » Thu Mar 07, 2013 22:20

I have made a pull request on github with some misc performance improvements:

  • Making minetest.env and minetest.registered_nodes local.
  • Using table.concat instead of concatenating in a loop.
  • And other small things.

The map is now generated up to 2x as fast as before and the time it takes to generate is now printed in the terminal.
https://github.com/4aiman/mapp/pull/1
Games: The Hungry Games.
Mods: Lifters (Simple Lifts), Snow Biomes and Gates.
Also checkout my texture pack Gridtoon!
View all of them plus more at http://minetest.splizard.com! (may not always be online).
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Fri Mar 08, 2013 07:14

I'm still far from my place, so anyone will have to wait а little longer before I can do anything...

Although I can't say my version was slow, I'll test your improvements and merge them. But I'm going to delete the part with generation time, 'cause if we talk about performance, then we must clean up all unnecessary code. I believe that was added for me to notice speed up.

Where can I read about lua tricks like using tables instead of strings to get higher performance?
Last edited by 4aiman on Fri Mar 08, 2013 07:28, edited 1 time in total.
 

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

by kaeza » Fri Mar 08, 2013 11:11

https://github.com/4aiman/mapp/pull/2
A small contribution.
Just tested this mod (been too busy [read as lazy] lately :) ); it's very impressive.
Excellent work.
Edit:
Small suggestion: make the visible range customizable in the script. This can be useful for singleplayer where the mod runs fast (without network overhead).
Last edited by kaeza on Fri Mar 08, 2013 11:32, edited 1 time in total.
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
RealBadAngel
Member
 
Posts: 556
Joined: Wed Jul 18, 2012 16:30

by RealBadAngel » Fri Mar 08, 2013 13:53

well if this mod could make efficent and good rules to display the map, maybe i or some1 else could implement it as a engine hud feature...
 

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

by kaeza » Fri Mar 08, 2013 15:43

Added experimental threading support to avoid freezing the server.

https://github.com/kaeza/mapp/tree/threading

Need to do some testing first, then I'll open a pull request.
Can someone help testing this?
EDIT: Works a bit slow on singleplayer; threading support can be disabled by setting ENABLE_THREADS to false.
Last edited by kaeza on Fri Mar 08, 2013 15:44, edited 1 time in total.
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
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Fri Mar 08, 2013 15:59

Merged both.
Thanks for help, guys!

PS: I believe the only thing that needs to be in a separate thread is logging. (Don't confuse logging with debug info and writing to StdErr output.)
Very often when I think smth is slow, simple deletion of any output to the terminal make things usable.
I don't say we don't need threading, but single core PCs won't benefit from it much.
 

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

by kaeza » Fri Mar 08, 2013 16:07

4aiman wrote:Merged both.
Thanks for help, guys!

PS: I believe the only thing that needs to be in a separate thread is logging. (Don't confuse logging with debug info and writing to StdErr output.)
Very often when I think smth is slow, simple deletion of any output to the terminal make things usable.
I don't say we don't need threading, but single core PCs won't benefit from it much.

It's not threading per-se. It's collaborative multithreading.
What this means is that a routine suspends execution ("yields") to the caller routine.
What the patch does is incrementally generate the formspec at each game step. This means the server does not get frozen in the for loop, yielding at every line of the map.
When this happens, the server regains control, and allows other mods (and the game itself) to do their stuff. Then, at the next game step, it resumes the "threads" to generate another map line, and so on until it is complete and the map is shown to the player. It's not perfect, but at least leaves some time for other tasks.

EDIT: This also means no real threads are created. For more info, see this: http://www.lua.org/manual/5.1/manual.html#2.11
Last edited by kaeza on Fri Mar 08, 2013 16:10, edited 1 time in total.
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
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Fri Mar 08, 2013 17:17

I know how threads work ;)
The problem is that some other mod (like floatlands) will do it's stuff w/o letting anyting to interfere, and a player may wait for a very long time before entire map will be drawn... It's not the problem of this mod, though.

Also, shrinking yaw calculation wasn't flawless: Server keeps printing messages like this
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
Creating a dummy image for "d-30.png"

That's because in my version there wasn't negative angles: you've deleted this:
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 yaw<0 then yaw = 360 + yaw end
           if yaw>360 then yaw = yaw - 360 end


Edit:
Works too slow with any world-generating mod...
Kaeza, maybe you can add "threading" support to, for example, floatlands mod, so anyone can test that with current mod?
Last edited by 4aiman on Fri Mar 08, 2013 19:40, edited 1 time in total.
 

User avatar
0gb.us
Member
 
Posts: 841
Joined: Sun Sep 16, 2012 01:55

by 0gb.us » Fri Mar 08, 2013 18:52

If you can't rotate less than 90 degrees, can you rotate more that 360 to simulate angles less than 90?

I don't know if that will work, it's just something you could try.
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Fri Mar 08, 2013 19:40

0gb.us wrote:If you can't rotate less than 90 degrees, can you rotate more that 360 to simulate angles less than 90?
I don't know if that will work, it's just something you could try.

Can't say I got your point.
Lua API provides a way to rotate images by 90, 180 and 360 degrees only.
Besides, why do I need to rotate smth more than 360?
I wanted to have more precise angles and that resulted (after following a piece of advice provided me by Calinou) into having 9 textures (0 to 80 degrees) which are rotated by that implemented values. So now we can show player's direction with a step of 10 degrees - that's pretty "smooth", I think.
The only problem with negative angles was rooted to deletion of the quoted piece of code.
 

User avatar
Splizard
Member
 
Posts: 220
Joined: Wed Jan 25, 2012 07:20
GitHub: Splizard
IRC: Splizard
In-game: Splizard

by Splizard » Sun Mar 10, 2013 20:58

4aiman wrote:I'm still far from my place, so anyone will have to wait а little longer before I can do anything...

Although I can't say my version was slow, I'll test your improvements and merge them. But I'm going to delete the part with generation time, 'cause if we talk about performance, then we must clean up all unnecessary code. I believe that was added for me to notice speed up.

Where can I read about lua tricks like using tables instead of strings to get higher performance?


Yes it wasn't too slow but extra speed is nice :)
Thanks for merging it, you could just comment out the generation time stuff so you can use it if you need it again.

You can find some Lua optimizing tricks here:
http://www.lua.org/gems/sample.pdf
http://lua-users.org/wiki/OptimisationTips
http://stackoverflow.com/questions/154672/what-can-i-do-to-increase-the-performance-of-a-lua-program
Games: The Hungry Games.
Mods: Lifters (Simple Lifts), Snow Biomes and Gates.
Also checkout my texture pack Gridtoon!
View all of them plus more at http://minetest.splizard.com! (may not always be online).
 

Next

Return to WIP Mods

Who is online

Users browsing this forum: Google [Bot] and 13 guests