[Mod] Image Loader [0.1.0] [imageloader]

Sokomine
Member
 
Posts: 3890
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine

Re: [Mod] Image Loader [0.1.0] [imageloader]

by Sokomine » Tue Sep 08, 2015 15:26

kaeza wrote:which translates to C:\whatever\minetest\mods\foo/bar.lua

...unless the mod deliberately searches for the slashes in order to act as a file browser. Lua just doesn't seem to be very consistent here. If all you're doing is loading some files with dofile, it's not relevant. But the pahts are just not the way they might be expected.
A list of my mods can be found here.
 

User avatar
kaeza
Moderator
 
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
Location: Montevideo, Uruguay
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: [Mod] Image Loader [0.1.0] [imageloader]

by kaeza » Tue Sep 08, 2015 17:38

If you need to manipulate paths, feel free to implement all the functionality required. In this particular case, the question was whether or not this mod would work under Windows, citing an unfounded fear that it might cause problems due to different directory separators. The C lib under windows (MSVCRT) supports using forward slashes as separators, so why should I concern myself with these details? It makes the code portable to all platforms currently supported by minetest. If it ever causes problems, it will be fixed. Until then, no more discussion on this subject from my part.
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
 

bobomb
Member
 
Posts: 115
Joined: Sat May 23, 2015 20:28
GitHub: bobombolo
IRC: bobomb

Re: [Mod] Image Loader [0.1.0] [imageloader]

by bobomb » Mon Nov 30, 2015 04:38

inspired by this mod I wanted to show some work I did today on the realterrain mod, now allowing you to map a greyscale image as a heightmap and the same image in color as a color overlay. this map is 640x480
Image
while the intent is to overlay satellite imagery onto elevation maps, it is fun for this kind of thing.
of course realterrain requires a lot of external libraries... and introduces 216 new textures to accomplish this.

viewtopic.php?f=9&t=12666
 

User avatar
lordfingle
Member
 
Posts: 65
Joined: Sat Apr 04, 2015 09:21
Location: Australia
GitHub: eidy
IRC: lordfingle
In-game: lordfingle

Re: [Mod] Image Loader [0.1.0] [imageloader]

by lordfingle » Mon Mar 20, 2017 02:13

Image
Image
Image

If you'd like to create load images vertically instead of flat on the ground, change this routine in imageloader.lua:

Code: Select all
function imageloader.to_schematic(bmp, pal)
   local data = { }
   local datai = 1
   for y = bmp.h, 1, -1 do
      for x = 1, bmp.w do
         local c = bmp.pixels[y][bmp.w + 1 - x]
         local i = palette.bestfit_color(pal, c)
         if (i == 1) and ((c.r ~= 255) or (c.g ~= 0) or (c.r ~= 255)) then
            print("WARNING: wrong color taken as transparency:"
               ..(("at (%d,%d): [R=%d,G=%d,B=%d]"):format(x, y, c.r, c.g, c.b))
            )
         end
         local node = pal[i].node
         data[datai] = { name=node }
         datai = datai + 1
      end
   end
   return {
      size = { x=bmp.w, y=bmp.h, z=1 },
      data = data,
   }
end
Attachments
trump.png
(147.39 KiB) Downloaded 1 time
bottle.png
(31.75 KiB) Not downloaded yet
theeye.png
(116.01 KiB) Not downloaded yet
----------------------------------------------------------------------------------------------
Team Lead on "eidy- Love learning"
I like reading, walks on the beach and building edutech experiences in lua (Find out more in this post)
"Coming together is a beginning; keeping together is progress; working together is success." - Henry Ford
 

User avatar
azekill_DIABLO
Member
 
Posts: 7489
Joined: Wed Oct 29, 2014 20:05
Location: OMICRON
GitHub: azekillDIABLO
In-game: azekill_DIABLO
 

Previous

Return to WIP Mods



Who is online

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