]> git.lizzy.rs Git - Crafter.git/blob - mods/redstone/space_maker.lua
Push incomplete version of doubletap running due to possible hardware failure
[Crafter.git] / mods / redstone / space_maker.lua
1 --this is a debug for creating flat planes to test redstone
2 local items = {
3 "redstone:dust 50",
4 "redstone:repeater_off_0 50", 
5 "redstone:comparator_0 50", 
6 "redstone:torch 50", 
7 "redstone:switch_off 50", 
8 "redstone:button_off 50", 
9 "redstone:piston_off 50",
10 "redstone:light_off 50",
11 "redstone:inverter_off 50",
12 "redstone:player_detector_0 50"}
13
14 minetest.register_node("redstone:space", {
15     description = "Stone",
16     tiles = {"stone.png"},
17     groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,pathable = 1},
18     sounds = main.stoneSound(),
19     after_place_node = function(pos, placer, itemstack, pointed_thing)
20                 local min = vector.subtract(pos,50)
21                 min.y = pos.y
22                 local max = vector.add(pos,50)
23                 max.y = pos.y
24                 local vm = minetest.get_voxel_manip()   
25                 local emin, emax = vm:read_from_map(min,max)
26                 local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
27                 local data = vm:get_data()
28                 local content_id = minetest.get_name_from_content_id
29                 
30                 local y = pos.y
31                 
32                 for x = -50,50 do
33                         for z = -50,50 do
34                                 local i = vector.add(pos,vector.new(x,0,z))
35                                 i.y = pos.y
36                                 local p_pos = area:index(i.x,i.y,i.z)   
37                                 data[p_pos] = minetest.get_content_id("main:stone")
38                         end
39                 end
40                 vm:set_data(data)
41                 vm:write_to_map()
42                 
43                 local placer_pos = placer:getpos()
44                 placer_pos.y = pos.y + 1
45                 placer:move_to(placer_pos)
46                 
47                 pos.y = pos.y + 1
48                 for _,item in pairs(items) do
49                         local obj = minetest.add_item(pos,item)
50                         local x=math.random(-2,2)*math.random()
51                         local y=math.random(2,5)
52                         local z=math.random(-2,2)*math.random()
53                         obj:setvelocity({x=x, y=y, z=z})
54                 end
55     end,
56     
57     
58 })
59
60