Add files via upload

master
AiTechEye 2022-07-14 23:15:20 +02:00 committed by GitHub
parent 712e1bd85e
commit 4a2c9de68d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 89 additions and 3 deletions

View File

@ -25,7 +25,7 @@ maps.maps.MyMap={
store_disabled=true, -- optional, disabled the store
on_enter=function(player) -- required, when player enter
if default.storage:get_int("mymap") == 0 then -- in this case, only generating the map 1 time
if default.storage:get_int("mymap") < 1 then -- in this case, only generating the map 1 time, could also use it as a version number, to replace the map with a newer version, smart huh?
default.storage:set_int("mymap",1)
nodeextractor.set(maps.get_pos({x=0,y=0,z=0}),minetest.get_modpath("maps").."/nodeextractor/".."maps_tutorial.exexn",true)
end

View File

@ -15,8 +15,8 @@ maps = {
special_disabled=true,
store_disabled=true,
on_enter=function(player)
if default.storage:get_int("Tutorials") == 0 then
default.storage:set_int("Tutorials",1)
if default.storage:get_int("Tutorials") < 2 then
default.storage:set_int("Tutorials",2)
nodeextractor.set(maps.get_pos({x=0,y=0,z=0}),minetest.get_modpath("maps").."/nodeextractor/".."maps_tutorial.exexn",true)
end
minetest.after(0.1, function(player)

View File

@ -233,4 +233,90 @@ minetest.register_node("maps:settime", {
minetest.set_timeofday(minetest.get_meta(pos):get_float("t")/24)
end
}
})
minetest.register_node("maps:protect", {
description = "protects area, removes area when reused",
tiles={"default_stone.png^[invert:gbr"},
groups = {unbreakable=1,exatec_wire_connected=1,not_in_creative_inventory=1},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
minetest.get_meta(pos):set_string("formspec","size[2,1]button_exit[0,0;2,1;setup;Setup]")
end,
after_place_node=function(pos, placer, itemstack, pointed_thing)
local m = minetest.get_meta(pos)
m:set_string("owner",placer:get_player_name())
m:set_int("id",-1)
end,
on_receive_fields=function(pos, formname, pressed, sender)
if (pressed.save or pressed.setup or pressed.toggle) and minetest.check_player_privs(sender:get_player_name(), {server=true}) then
local m = minetest.get_meta(pos)
local pos1
local pos2
if pressed.save then
local name = sender:get_player_name()
local p = protect.user[name]
if p and p.pos1 and p.pos2 then
pressed.node = minetest.get_node(p.pos1).name
node = true
pos1 = p.pos1
pos2 = p.pos2
pressed.pos1 = p.pos1.x.." "..p.pos1.y.." "..p.pos1.z
pressed.pos2 = p.pos2.x.." "..p.pos2.y.." "..p.pos2.z
protect.clear(name)
end
elseif pressed.toggle then
minetest.registered_nodes["maps:protect"].exatec.on_wire(pos)
end
m:set_string("name",pressed.name)
if pos1 and (pos1.y > 26000 and pos1.y < 31000) then
m:set_string("pos1l",minetest.pos_to_string(vector.subtract(pos1,pos)))
m:set_string("pos1",pressed.pos1:gsub(","," "))
end
if pos2 and (pos2.y > 26000 and pos2.y < 31000) then
m:set_string("pos2l",minetest.pos_to_string(vector.subtract(pos2,pos)))
m:set_string("pos2",pressed.pos2:gsub(","," "))
end
m:set_string("formspec","size[1.5,4]"
.."button_exit[-0.2,-0.2;2,1;save;Save]"
.."field[0,1;2,1;name;;"..m:get_string("name").."]"
.."field[0,2;2,1;pos1;;"..m:get_string("pos1").."]"
.."field[0,3;2,1;pos2;;"..m:get_string("pos2").."]"
.."tooltip[save;Mark with both /protect 1 /protect 2 to select the position/area.\nDo not protect, just mark it then press save]"
.."tooltip[node;A valid node, eg default:stone]"
.."tooltip[pos1;Position 1]"
.."tooltip[pos2;Position 2]"
.."button_exit[-0.2,3.5;2,1;toggle;Toggle "..(m:get_int("id") == -1 and "on" or "off").."]"
)
end
end,
exatec={
on_wire = function(pos)
local m = minetest.get_meta(pos)
local id = m:get_int("id")
local owner = m:get_string("owner")
if id ~= -1 then
protect.remove_game_rule_area(id)
m:set_int("id",-1)
return
end
local pos1 = minetest.string_to_pos(m:get_string("pos1l"))
local pos2 = minetest.string_to_pos(m:get_string("pos2l"))
if pos1 and pos2 and owner ~= "" then
pos1,pos2 = protect.sort(vector.add(pos1,pos),vector.add(pos2,pos))
local pr,o = protect.test(pos1,pos2,owner)
if pr == false then
minetest.chat_send_player(owner,"The area is protected by "..o)
return
end
id = protect.add_game_rule_area(pos1,pos2,m:get_string("name"),owner,false)
if id then
m:set_int("id",id)
end
end
end
}
})