Huge shadows when generating a forest

User avatar
y.st.
Member
 
Posts: 38
Joined: Fri Mar 20, 2015 01:24
GitHub: y-st
IRC: Yst
In-game: Yst

Huge shadows when generating a forest

by y.st. » Wed Aug 12, 2015 18:24

I just set up some code to build a pine forest durring map generation, but it's messing with the lighting. Most of the blocks that the trees are in are now dark, as if in a cave. Does anyone have any ideas as to how to compensate for this effect and set the lighting back to normal?
 

User avatar
Casimir
Member
 
Posts: 1101
Joined: Fri Aug 03, 2012 16:59

Re: Huge shadows when generating a forest

by Casimir » Wed Aug 12, 2015 18:38

It is a known bug. Mapfix helps.
 

User avatar
y.st.
Member
 
Posts: 38
Joined: Fri Mar 20, 2015 01:24
GitHub: y-st
IRC: Yst
In-game: Yst

Re: Huge shadows when generating a forest

by y.st. » Wed Aug 12, 2015 19:20

I don't know if I'm using it wrong or something, but that code doesn't seem to work. Niether does "<voxelmanip>:set_lighting({day=15, night=15})".
 

User avatar
TenPlus1
Member
 
Posts: 1874
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: Huge shadows when generating a forest

by TenPlus1 » Wed Aug 12, 2015 19:38

Placing a schematic file seems to work in fixing all shadows, but you make things easier you could add the Admin Stick to your game and right-click a node inside the shadow area to remove ANY node and fix lighting...

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
minetest.register_tool("modname:admin_stick", {
   description = "Admin Stick",
   inventory_image = "default_tool_woodaxe.png",
   stack_max = 1,
   tool_capabilities = {
      full_punch_interval = 0.7,
      max_drop_level=1,
      groupcaps={
         choppy ={times={[1]=1.90, [2]=0.90, [3]=0.30}, uses=40, maxlevel=3},
         cracky ={times={[1]=1.90, [2]=0.90, [3]=0.30}, uses=40, maxlevel=3},
         crumbly={times={[1]=1.90, [2]=0.90, [3]=0.30}, uses=40, maxlevel=3},
         snappy ={times={[1]=1.90, [2]=0.90, [3]=0.30}, uses=40, maxlevel=3},
      },
      damage_groups = {fleshy=10},
   },

   on_place = function(itemstack, user, pointed_thing)

      local privs = minetest.get_player_privs(user:get_player_name())

      if privs["server"] then
         if pointed_thing.type == "node" then
            local pos = pointed_thing.under
            minetest.place_schematic(
               pos,
               -- place air schem to fix lighting and air node for update
               {size = {x = 1, y = 1, z = 1}, data = {{name="air", param1=255}}},
               "", {}, true)
         end
      end
   end,
})
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

Re: Huge shadows when generating a forest

by paramat » Thu Aug 13, 2015 02:41

> some code to build a pine forest durring map generation

How are you doing this?
It's best and fastest to use the biome API decoration code to do this, using schematic trees, the decoration code works in mgv6 too.
 

User avatar
y.st.
Member
 
Posts: 38
Joined: Fri Mar 20, 2015 01:24
GitHub: y-st
IRC: Yst
In-game: Yst

Re: Huge shadows when generating a forest

by y.st. » Thu Aug 13, 2015 03:46

I tried integrating the effect of the admin stick into the map generation code, but it doesn't seem to work at map generation time. I can't use an administrator-only tool manually, as my planned server will be a bit of an anarchy server and will have no administrators.

The problem with placing scematics is that it is a duplication of functionality. Every time an update is made, I have to figure out how to make the same change both in the schematic code and in the minetest.spawn_tree() code. It's hard enough trying to get the minetest.spawn_tree() function alone to play nicely. I can't switch to also using schematic files for saplings because, as demonstrated in minetest_game, schematic files eat nodes. If someone places a schematic-using sapling under another player's locked chest, that locked chest and all its contents will be destroyed. Schematic saplings are far too dangerous to have in a non-PVP-type subgame.

Further testing seems to indicate that this bug happens in map generators v5 and v7, but not v6. I'm not sure why.

My code looks 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
minetest.register_biome({
   name = "minetyst:negxo",
   node_dust = "minetyst:negxa_bloko",
   node_top = "minetyst:tero_kun_negxo",
   depth_top = 1,
   node_filler = "minetyst:tero",
   depth_filler = 3,
   node_stone = "minetyst:sxtono_ciankolora",
   node_water_top = "minetyst:glacio",
   depth_water_top = 2,
   node_water = "minetyst:dolcxakva_fonto",
   y_min = -31000,
   y_max = 31000,
   heat_point = 0,
   humidity_point = 100,
})

minetest.register_decoration({
   deco_type = "simple",
   place_on = "minetyst:tero_kun_negxo",
   fill_ratio = 0.005,
   sidelen = 16,
   biomes = {"minetyst:negxo"},
   decoration = "minetyst:pinarbido",
})

minetest.register_node("minetyst:pinarbido", {
   description = "Pinarba Grajno",
   tiles = {"minetyst-pinarbido.png"},
   inventory_image = "minetyst-pinsemo.png",
   wield_image = "minetyst-pinsemo.png",
   drawtype = "plantlike",
   paramtype = "light",
   is_ground_content = false,
   walkable = false,
   groups = {attached_node=1, arbido=1},
   arbo = {
      axiom = "dddTTTTTTff&&RAA",
      rules_a = "[^R+R+RR+RR+RRR]G[^f+f+ff+ff+fff+RRR+RRRR+RRRR+RRRRR]G[^f+f+ff+ff+fff+fff+ffff+ffff+fffff+RRRRR+RRRRRR+RRRRRR+RRRRRRR]G[^f+f+ff+ff+fff+fff+ffff+ffff+fffff+fffff+ffffff+ffffff+fffffff]G",
      rules_d = "T",
      trunk = "minetyst:pinarbo",
      leaves = "minetyst:pinarba_folioj",
      leaves2 = "minetyst:strobilo",
      leaves2_chance = 10,
      angle = 90,
      iterations = 2,
      random_level = 1,
      trunk_type = "single",
      fruit_chance = 0,
      fruit = "minetyst:negxo"
   },
})

minetest.register_on_generated(function(minimumo, maksimumo, semo)
   local arbidoj = minetest.find_nodes_in_area(minimumo, maksimumo, "group:arbido")
   for elemento,koordinatoj in pairs(arbidoj) do
      local arbido = minetest.get_node(koordinatoj)
      minetest.remove_node(koordinatoj)
      if minetest.get_node({x=koordinatoj.x,y=koordinatoj.y+1,z=koordinatoj.z}).name == "minetyst:negxa_bloko" then
         minetest.remove_node({x=koordinatoj.x,y=koordinatoj.y+1,z=koordinatoj.z})
      end
      minetest.spawn_tree(koordinatoj, minetest.registered_nodes[arbido.name].arbo)
   end
end)


The code is a bit hard to read, but basically, it uses simple decorations to place saplings, then finds all the saplings with minetest.find_nodes_in_area(), and causes them all to grow by removing the sapling, removing the snow node (placed as a dust) on top of the sapling, then calling minetest.spawn_tree() at the location the sapling used to be.
 

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

Re: Huge shadows when generating a forest

by Sokomine » Thu Aug 13, 2015 03:57

y.st. wrote: If someone places a schematic-using sapling under another player's locked chest, that locked chest and all its contents will be destroyed.

There's a parameter for schematics so that they don't replace existing nodes.

y.st. wrote:The problem with placing scematics is that it is a duplication of functionality. Every time an update is made, I have to figure out how to make the same change both in the schematic code and in the minetest.spawn_tree() code. It's hard enough trying to get the minetest.spawn_tree() function alone to play nicely.

Understandable. I'm currently also having problems with the trees. Their code envolves - that's fine - but that also means that my version is outdated. I'm using the "manual" minetest.spawn_tree function(s) to place trees into the voxelmanip area luavoxelmanip is working on. I don't want to keep a slightly modified copy of the trees from default forever. Hope it can somehow be mixed up again :-) My code can read schematics and analyze them on the lua level without going through minetest.place_schematic if that's any help.
A list of my mods can be found here.
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

Re: Huge shadows when generating a forest

by paramat » Thu Aug 13, 2015 15:42

This is probably because 'spawn_tree' (l-system tree) includes a lighting update, it is meant for occasional use not many times at once during mapgen. Minetest has lighting bugs when many lighting updates are triggered at once, it is also very slow to do this, and unnecessary because only 1 lighting update is needed after all l-system trees are spawned. What is needed is an additional spawn_tree function that does not include a lighting update.
 

User avatar
y.st.
Member
 
Posts: 38
Joined: Fri Mar 20, 2015 01:24
GitHub: y-st
IRC: Yst
In-game: Yst

Re: Huge shadows when generating a forest

by y.st. » Thu Aug 13, 2015 17:20

Sokomine wrote:...


Alright, I'll have to look into schematics. I definitely want to use them for something, though I'm not sure I want to use them for trees. Part of my goal is to learn the Minetest API, so if I skip the minetest.spawn_tree() function, that's one part I won't learn to use. Does that make any sense?

paramat wrote:...


That explains why the bug happens so much less often when used in the ABM, though it still does cause the whole block to go dark sometimes. I suppose for now I will just spawn saplings and let them age as they happen to get set off by the ABM. It will look a bit funny for players, but not as funny as huge shadows covering the overworld.
 


Return to Minetest Problems

Who is online

Users browsing this forum: No registered users and 8 guests

cron