This commit is contained in:
HybridDog 2016-01-24 13:47:33 +01:00
parent 9dc7ef278d
commit 36c0a5ffa5
29 changed files with 1232 additions and 96 deletions

BIN
2.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 664 KiB

View File

@ -34,6 +34,7 @@ or / if you not have a keyboard, use switcher: dipalzer:box / di_box
Place:
Place nodes front of you
if there is atleast 1 block over the pointed, it will place backwards
if there is a block on the backside of the pointed, it will use its rotation (between you and the pointed)
Dc: taking from inventory
Dg: taking from inventory if not have give
Da:
@ -41,10 +42,10 @@ Dan:
[][B][D][][][][][]
Shoot lazer:
Dc: hurts 10hp if pvp is off / can pick up droped stuff / taking from inventory
Dg: always hurts 10hp / can pick up droped stuff / taking from inventory if not have give
Da: always kills / can pick up droped stuff
Dan: always kills / destroy droped stuff
Dc: hurts 10hp if pvp is off / can pick up drops
Dg: always hurts 10hp / can pick up drops
Da: always kills / can pick up drops
Dan: always kills / destroy drops
[][?][D][][][][][]
@ -108,6 +109,18 @@ this will always palce stack x stack (like 2=4, 5=25, 10=100 ...)
to use more then 10 do /di_1112 to get access until next time you change mods or if someone leaves the game
[][B][D][][][][][]
================Mode13================
Place cube:
this works like mode11, but in 3d like stack x stack x stack (2=8, 5=125, 10=1000)
to use more then 10 do /di_1112 to get access 1 time
[][B][D][][][][][]
================Mode14================
Dig cube:
this works like mode13, but will dig instand stack x stack x stack (2=8, 5=125, 10=1000)
to use more then 10 do /di_1112 to get access 1 time
[][B][D][][][][][]
==================================================
================Diplazer 3D Transfer================
==================================================

21
Licence.txt Normal file
View File

@ -0,0 +1,21 @@
Copyright (C) UjEdwin 2016
Its only 2 agruments.
You are not alowed to take files from the mod and use to other things (but ok to link form other mods).
You have to show me (UjEdwin) as the orginal creater (if you want to make another version / spread the mod)
It does not mather what you is doing with the mod as long you folow this 2 agruments.
So: its ok to do stuff like: use in public servers/edit/spread/upload/make an update / using in a video (like youtube)...
The reasons the the arguments.
It does not feel good if someone takes hard work and or characteristics of your work, and says its him self created it.
In some mods i spended more then 30 hours... so its a good reason to add this license :-)

View File

@ -1,8 +1,3 @@
Copyright (C) UjEdwin 2015
Mod by UjEdwin
See the version in the init.lua or type /dihelp in game
Rename this folder to diplazer
@ -11,7 +6,7 @@ More info: https://forum.minetest.net/viewtopic.php?f=9&t=12395
Other info: type /dihelp in game
type /di_dropme to drop you self from mode7 and mode8 (or with diplazer_admin priv /di_dropall)
type /di_dropme to drop you self from mode7 and mode8 (or drop all with diplazer_admin priv /di_dropall)
Diplazer is a kind of lasergun / fast placing / diging tool, and it can even teleport, object teleporter and gravitygun, and more!!
@ -22,16 +17,16 @@ Dipalzer works with pipeworks:nodebreaker
Diplazer works with pipeworks:nodebreaker (make smooth doors / traps and other)
modes that are supported with nodebreakers
:com & :gun womodes:1 2,4,5,12
:admin & :adminno: 1 2 4 5 8 9 11 12
:com & :gun modes:1 2,4,5,6,7,9,10,11,12,13,14
:admin & :adminno: 1 2,4,5,6,7,8,9,10,11,12,13,14
place a block front of the breaker before it can use the tool
Change the amount in the init.lua file (diplazer_amount=15) admin have double
Change the amount in the init.lua file (diplazer_amount=15) admin using double
In place mode (1 & 3): In invetory: place stack with blocks / nodes to left side of the tool , the tool will use all of same type of nodes from the inventory, then the stack to left.
In dig mode (2 & 4): In invetory: place stack-amout to dig.
In place mode (1,3,11,13): In invetory: place stack with blocks / nodes to left side of the tool , the tool will use all of same type of nodes from the inventory, then the stack to left.
In dig mode (2 & 4,12,15): In invetory: place stack-amout to dig.
The common version: diplazer:com (di_com)
The common version: diplazer:com (di_com) [com = common]
Toogleable
Limeted (toogleable) [craft with meseblock to reload]
can place / dig 7 blocks
@ -71,7 +66,7 @@ same as diplazer:admin
don't keep stuff on dig, can destroy locked stuff / special nodes
require diplazer_admin priv to use
in mode: 1,3,11 you can use next mode if you hold right+left click instead of change
in mode: 1,3,11,13 you can use next mode if you hold right+left click instead of change
Mode1: Place front (can shoot lazer if no stack set)
Mode2: Dig nodes front
@ -83,8 +78,10 @@ Mode7: Teleport Objects
Mode8: Gravity gun (click to pickup, click it again to drop, click+right to throw it away [dont work on players])
Mode9: Replace: stack to left replace with stack to right
Mode10: AutoSwitch: using from all stacks in hotbar from left to right [place dipalzer to right for max use]
Mode11: Place platform nXn
Mode12: Dig platform nXn
Mode11: Massive place: platform NxN
Mode12: Massive dig: platform NxN
Mode13: Massive place: cube NxNxN
Mode14: Massive dig: cube NxNxN
Use mode8
Use / left click - pick up something or a node
@ -131,14 +128,48 @@ diplazer:vaccum / di_vac
Just vaccum, at same time it prevents players to teleport to inside.
The blocks are invisible, and have to place somethine on it, or dig with any diplazer to remove.
Diplazer 3D Transfer
3D Transfer
diplazer:di3dt / di_3dt
left click top copy, right to place your place.
see Help-Controls.txt for more info
You can easy toogle / functions in the init.lua
Service Bot:
This tool using 8 modes, only the owner can control it:
Goto somthing (then do then nothing)
Attack object (then do then nothing)
Protect (will folow the object and attacks every other object around it without you
Place block: using from your inventory [left side of the tool] (then do then nothing)
Dig a block [you will get the stuff] (then do then nothing)
Keep digging: [you will get the stuff] will dig any block it can find (same as the pointed)
Folow will folow the selected object
Destroy: remove the bot
[it will teleport to the target if its too faraway])
The Flashlight:
use to turn off or on in darknes, it also works in default water
it turns of if you:
are inside a block (not water)
if you are in daylight
and if you chnage its possition in the inventory
The Portable chest:
the title says all, put down the blue chest, put in stuff, pick up the chest, put it somewhere else, and you stuff are there.
the chest cant save metadata / info from tools, that means it will be restored, but tool damage.
You can easy toogle / functions and see all items in the init.lua
Changes log:
V18:
Fixed shadows from lazer
Added: portable chest (imported from pollution)
Added: flashlight (works in default water too)
Fixed 1112access (/di_1112) removes acces when anyone leave
Added: mode13: Massive place NxNxN
Added: mode14: Massive dig NxNxN
Added: mode1: support from param2 (node rotation)
Fixed: mode8: players stuck in air (no gravity) happend when a player hold another player and selected a node
Added: servive bot
V17:
Added: diplazer:chip
Added: diplazer:pick

208
base.lua
View File

@ -9,6 +9,9 @@ local function diplazer_getAmount(player, mode,admin)
elseif stack_count>diplazer_amount*2 and admin==1 then stack_count=diplazer_amount*2
elseif stack_count>diplazer_com_amount and admin==-1 then stack_count=diplazer_com_amount
end
if (mode==13 or mode==14) then
return stack_count
end
if (mode==11 or mode==12) then
return stack_count
end
@ -49,8 +52,10 @@ Mode[7]="Teleport objects"
Mode[8]="Gravity gun (click to pickup, click it again to drop, right+click to throw it away jump+click to drop single block/stack)"
Mode[9]="Replace front: stack to left replace with stack to right"
Mode[10]="AutoSwitch using from all stacks in hotbar from left to right [place dipalzer to right for max use]"
Mode[11]="Place platform NxN amo"
Mode[12]="Dig platform NxN amo"
Mode[11]="Massive Place: platform NxN nodes"
Mode[12]="Massive Dig: platform NxN nodes"
Mode[13]="Massive Place: cube NxNxN nodes (be extremely careful!)"
Mode[14]="Massive Dig: cube NxNxN nodes (be extremely careful!)"
minetest.chat_send_player(name,"Diplazer Mode" .. msg .. ": ".. Mode[msg])
end
end
@ -70,7 +75,7 @@ minetest.register_chatcommand("dihelp", {
minetest.chat_send_player(name, "/dihelp (V" ..diplazer_vesrion ..") ... Use while sneaking / hold shift and left-click / use the switcherbox")
minetest.chat_send_player(name, "Set a [stack] of blocks [left of the tool], the [amount of stack] sets how many to place/dig")
minetest.chat_send_player(name, "If someone keep teleporting or wear you, type /di_dropme (for admins /di_dropall)")
if diplazer_pipeworks==1 then minetest.chat_send_player(name, "dipalzer also works with pipeworks:nodebreaker") end
if diplazer_pipeworks==1 then minetest.chat_send_player(name, "diplazer also works with pipeworks:nodebreaker") end
return true
end})
@ -167,7 +172,7 @@ function have_1112access(name,remove)
if remove==1 then
for i=1,diplazer_getLength(diplazer_1112access),1 do
if name==diplazer_1112access[i] then
diplazer_1112access[i]=nil
table.remove(diplazer_1112access,i)
return true
end
end
@ -568,7 +573,7 @@ if GGunInUse>0 then
end
end)
local function diplazer_is_unbreakable(pos)
function diplazer_is_unbreakable(pos)
local nodedef
nodedef = minetest.registered_nodes[minetest.get_node(pos).name]
@ -597,7 +602,7 @@ local function diplazer_dig(pos,player,drops,admin)
end
end
function diplazer_getdir (player)
function diplazer_getdir(player)
local dir=player:get_look_dir()
if math.abs(dir.x)>math.abs(dir.z) then
if dir.x>0 then return 0 end
@ -682,15 +687,13 @@ local function diplazer_place(pos, player, stack_count,Name,Node,creative,admin)
if Node.name=="diplazer:box" and admin<1 then return false end
local fn = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y, z=pos.z}).name]
local fn = minetest.registered_nodes[minetest.get_node(pos).name]
if admin<0 and fn.drop=="" and fn.name:find("maptools:",1)~=nil then return false end
if fn.walkable==false then
if fn.walkable==false then
if stack_count>0 then
minetest.add_node({x=pos.x, y=pos.y, z=pos.z}, Node)
minetest.set_node(pos, Node)
if not creative and admin==0 and diplazer_Enable_gun_limitation==true then
player:get_inventory():remove_item("main", Name)
return true
@ -809,6 +812,7 @@ local function diplazer_use(pos, player, meta,admin,drops,keys,com)
end
end
if Items==0 then
minetest.sound_play("diplazer_error", {pos = player:getpos(), gain = 1.0, max_hear_distance = 10,})
minetest.chat_send_player(player:get_player_name(), "You need at least 1 slot free while digging")
return false
end
@ -1023,8 +1027,7 @@ end
-- Place front
if mode == 1 then
local lazer=0
local lazer=0
if is_node then
if drops==0 then Name="diplazer:lazer_adminno"
elseif admin==0 then Name="diplazer:lazer_gun"
@ -1042,10 +1045,9 @@ end
local plus=1
local minus=-1
local dir = diplazer_getdir(player)
local tp2node1=minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y, z=pos.z}).name].walkable
local tp2node2=minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name].walkable
local dir = diplazer_getdir(player)
if tp2node1==true and tp2node2==true then
pos.y=pos.y-1
plus=-1
@ -1059,6 +1061,14 @@ end
minetest.sound_play("diplazer_place", {pos = player:getpos(), gain = 1.0, max_hear_distance = 5,})
pos.y=pos.y+1
local param=0
if dir==0 then param=minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z}).param2 end
if dir==1 then param=minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z}).param2 end
if dir==2 then param=minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1}).param2 end
if dir==3 then param=minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1}).param2 end
Node.param2=param
for i=1,diplazer_amountT,1 do
if lazer==1 then
@ -1081,8 +1091,6 @@ end
end
end
end
if diplazer_place(pos, player, stack_count,Name,Node,creative,admin)==true then
stack_count=stack_count-1
if dir==0 then pos.x=pos.x+plus end
@ -1248,6 +1256,119 @@ end
end
return true
end
if mode == 13 or mode == 14 then
local y=1
local pos3={x=pos.x,y=pos.y+1,z=pos.z}
local pos2={x=pos.x,y=pos.y+1,z=pos.z}
local pos1={x=pos.x,y=pos.y+1,z=pos.z}
if mode==14 then
y=-1
pos3={x=pos.x,y=pos.y,z=pos.z}
pos2={x=pos.x,y=pos.y,z=pos.z}
pos1={x=pos.x,y=pos.y,z=pos.z}
end
local plus=1
local minus=-1
local dir=diplazer_getdir(player)
if stack_count>diplazer_amountT and admin>0 then
stack_count=diplazer_amountT*2
elseif stack_count>diplazer_amountT then
stack_count=diplazer_amountT
end
if stack_count>diplazer_mode1314_Max then
stack_count=diplazer_mode1314_Max
end
if mode==13 and (admin<1 or creative==0) then
local stackcount=0
local stack_should_be=(stack_count*stack_count)*stack_count
for i=0,32,1 do
local st=player:get_inventory():get_stack("main",i)
if st:get_name()==Name then
stackcount=stackcount+st:get_count()
end
if stackcount>=stack_should_be then
break
end
if i==32 then
minetest.sound_play("diplazer_error", {pos = player:getpos(), gain = 1.0, max_hear_distance = 10,})
minetest.chat_send_player(player_name, "You need more blocks to place (will place: ".. stack_should_be .. " missing: " .. stack_should_be-stackcount .. ")")
return false
end
end
end
if mode==14 and (admin<1 or creative==0) then
local stack_should_be=(stack_count*stack_count)*stack_count
local stackcount=stack_should_be+99
for i=0,32,1 do
local st=player:get_inventory():get_stack("main",i)
if st:get_name()=="" then
stackcount=stackcount-99
end
if stackcount<=0 then
break
end
if i==32 then
local tmpnfree=stackcount
local nfree=0
for i2=0,stackcount,1 do
tmpnfree=tmpnfree-99
nfree=nfree+1
if tmpnfree<=0 then break end
end
minetest.sound_play("diplazer_error", {pos = player:getpos(), gain = 1.0, max_hear_distance = 10,})
minetest.chat_send_player(player_name, "You need a more empty inventory to dig (will dig: ".. stack_should_be .. " need empty slots: " .. nfree .. ")")
return false
end
end
end
if stack_count>10 and have_1112access(player_name,0)==false then
minetest.sound_play("diplazer_error", {pos = player:getpos(), gain = 1.0, max_hear_distance = 10,})
return false
elseif stack_count>10 then
have_1112access(player_name,1)
end
if mode==13 then
minetest.sound_play("diplazer_massive3dplace", {pos=player:getpos(), gain = 1.0, max_hear_distance = 10,})
else
minetest.sound_play("diplazer_massive3ddig", {pos=player:getpos(), gain = 1.0, max_hear_distance = 10,})
end
for i1=1,stack_count,1 do --level
for i2=1,stack_count,1 do --front
for i3=1,stack_count,1 do --side
if mode==13 then
if diplazer_place(pos3, player, stack_count,Name,Node,creative,admin)==false then
break
end
else
if diplazer_dig(pos3,player,drops,admin)==false then
break
end
end
if dir==0 then pos3.z=pos3.z+plus end
if dir==1 then pos3.z=pos3.z+minus end
if dir==2 then pos3.x=pos3.x+minus end
if dir==3 then pos3.x=pos3.x+plus end
end
if dir==0 then pos3.z=pos2.z pos3.x=pos3.x+1 pos2.x=pos2.x+1 end
if dir==1 then pos3.z=pos2.z pos3.x=pos3.x-1 pos2.x=pos2.x-1 end
if dir==2 then pos3.x=pos2.x pos3.z=pos3.z+1 pos2.z=pos2.z+1 end
if dir==3 then pos3.x=pos2.x pos3.z=pos3.z-1 pos2.z=pos2.z-1 end
end
pos1.y=pos1.y+y
pos2={x=pos1.x,y=pos1.y,z=pos1.z}
pos3={x=pos2.x,y=pos2.y,z=pos2.z}
end
end-- end of cube mode
end
@ -1289,17 +1410,10 @@ local function diplazer_setmode(user,itemstack,admin,keys,drops,com)
else mode=mode+1
end
have_1112access(player_name,1)
-- Settings mode for :com
if mode==11 and diplazer_Enable_com_mode12==true and diplazer_Enable_com_mode11==false and admin==-1 and keys.jump then mode=10 end
if mode<=0 and diplazer_Enable_com_mode12==false and diplazer_Enable_com_mode11==true and admin==-1 and keys.jump then mode=11 end
if mode<=0 and diplazer_Enable_com_mode12==false and diplazer_Enable_com_mode11==false and admin==-1 and keys.jump then mode=10 end
if mode==11 and diplazer_Enable_com_mode11==false and admin==-1 then mode=12 end
if mode==12 and diplazer_Enable_com_mode12==false and admin==-1 then mode=1 end
if diplazer_Enable_com_mode8==false then
if mode==8 and keys.sneak and keys.jump and admin==-1 then mode=7 end
if mode==8 and admin==-1 then mode=9 end
@ -1307,19 +1421,8 @@ local function diplazer_setmode(user,itemstack,admin,keys,drops,com)
-- Settings mode for :gun or better
if mode==11 and diplazer_Enable_mode12==true and diplazer_Enable_mode11==false and admin>=0 and keys.jump then mode=10 end
if mode<=0 and diplazer_Enable_mode12==false and diplazer_Enable_mode11==true and admin>=0 and keys.jump then mode=11 end
if mode<=0 and diplazer_Enable_mode12==false and diplazer_Enable_mode11==false and admin>=0 and keys.jump then mode=10 end
if mode==11 and diplazer_Enable_mode11==false and admin>=0 then mode=12 end
if mode==12 and diplazer_Enable_mode12==false and admin>=0 then mode=1 end
if mode>=13 and admin>=0 then mode=1 end
if mode<=0 and admin>=0 then mode=12 end
--
if mode>=13 then mode=1 end
if mode<=0 then mode=12 end
if mode>=15 then mode=1 end
if mode<=0 then mode=14 end
--
if mode==8 and diplazer_Enable_mode8==false and keys.jump then mode=7 end
@ -1430,11 +1533,25 @@ end
if GGunInUse<0 then GGunInUse=0 end
local len=diplazer_getLength(diplazer_UserTele)
for i=1,len,1 do
if diplazer_Tele[i] and diplazer_Tele[i]~=false and diplazer_UserTele[i]~=false then
if diplazer_UserTele[i]=="8?" .. player_name and diplazer_Tele[i]:is_player() then
diplazer_Tele[i]:set_physics_override({gravity=diplazer_restore_gravity_to,})
diplazer_Tele[i]=false
diplazer_UserTele[i]=false
GGunInUse=GGunInUse-1
break
end
end
end
for i=1,len,1 do
if meta.mode .."?".. player_name==diplazer_UserTele[i] and (not diplazer_Tele[i]==false ) then
if diplazer_Tele[i]==nil or diplazer_Tele[i]==0 then return false end
if minetest.get_node(diplazer_Tele[i]:getpos())
.name ~="air" then return end
@ -1654,10 +1771,7 @@ minetest.register_tool("diplazer:adminno", {
})
if diplazer_Enable_com==true then
for i=1,12,1 do
if i==11 and diplazer_Enable_com_mode11==false then i=i+1 end
if i==12 and diplazer_Enable_com_mode12==false then return end
for i=1,14,1 do
minetest.register_tool("diplazer:com" .. i, {
description = "Diplazer mode ".. i,
@ -1706,11 +1820,7 @@ end
end
end
for i=1,12,1 do
if i==11 and diplazer_Enable_mode11==false then i=i+1 end
if i==12 and diplazer_Enable_mode12==false then return end
for i=1,14,1 do
minetest.register_tool("diplazer:gun" .. i, {
description = "Diplazer mode ".. i,
@ -1837,7 +1947,7 @@ minetest.register_node("diplazer:lazer_" .. diplazer_lazer[i], {
walkable=false,
use_texture_alpha = true,
drawtype = "glasslike",
sunlight_propagates = false,
sunlight_propagates = true,
groups = {not_in_creative_inventory=1,liquid = 2, hot = 3,igniter = 1},
can_dig = function(pos, player)
return false
@ -1852,7 +1962,7 @@ minetest.register_node("diplazer:lazerblock_" .. diplazer_lazer[i], {
alpha = 30,
use_texture_alpha = true,
drawtype = "glasslike",
sunlight_propagates = false,
sunlight_propagates = true,
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds=default.node_sound_stone_defaults(),
})

BIN
craft.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 113 KiB

After

Width:  |  Height:  |  Size: 194 KiB

View File

@ -20,10 +20,6 @@ local function diplazer_Transferuse_count(to_do,pos,user,diplazer_amountT,nodes2
return false
end
print(diplazer_amountT)
if to_do=="check" then
pos.y=pos.y+1
end

View File

@ -54,19 +54,12 @@ end
have_1112access(user,1)
if mode>=13 and admin==-1 then mode=12 end
if mode>=15 and admin==-1 then mode=14 end
if mode<=0 and admin==-1 then mode=1 end
if mode==8 and admin==-1 and diplazer_Enable_mode8==false then mode=9 end
if mode>=13 then mode=12 end
if mode>=15 then mode=14 end
if mode<=0 then mode=1 end
if mode==11 and admin==-1 and diplazer_Enable_com_mode11==false then mode=1 minetest.chat_send_player(user,"Mode 11 is inactived for this tool") end
if mode==12 and admin==-1 and diplazer_Enable_com_mode12==false then mode=2 minetest.chat_send_player(user,"Mode 12 is inactived for this tool") end
if mode==11 and admin>=0 and diplazer_Enable_mode11==false then mode=1 minetest.chat_send_player(user,"Mode 11 is inactived for this tool") end
if mode==12 and admin>=0 and diplazer_Enable_mode12==false then mode=2 minetest.chat_send_player(user,"Mode 12 is inactived for this tool") end
meta["mode"]=mode
mode=(meta["mode"])
@ -90,10 +83,7 @@ end
diplazer_T(user,tellmode,user,admin)
minetest.sound_play("diplazer_mode" , {pos = pos, gain = 2.0, max_hear_distance = 5,})
return {access=true,item=item}
end
@ -175,7 +165,9 @@ fmeta:set_string("formspec",
"button[5,4; 1.5,1;dip_cm9;Mode 9]" ..
"button[6.5,4; 1.5,1;dip_cm10;Mode 10]" ..
"button[3.5,0; 1.5,1;dip_cm11;Mode 11]" ..
"button[3.5,1; 1.5,1;dip_cm12;Mode 12]")
"button[3.5,1; 1.5,1;dip_cm12;Mode 12]"..
"button[3.5,2; 1.5,1;dip_cm13;Mode 13]" ..
"button[3.5,3; 1.5,1;dip_cm14;Mode 14]")
fmeta:set_string("infotext", "Diplazer switcher (owned by: " .. placer:get_player_name() .. ")")
if tt==1 then
fmeta:set_string("infotext", "Diplazer switcher")
@ -183,13 +175,12 @@ end
end
minetest.register_node("diplazer:box", {
description = "Diplazer box",
tiles = {
"default_steel_block.png^diplazer_boxtop.png",
"default_steel_block.png",
"default_steel_block.png^diplazer_boxside.png",
"default_steel_block.png^diplazer_boxside2.png",
"default_steel_block.png^diplazer_boxside.png",
"default_steel_block.png^diplazer_boxside.png",
"default_steel_block.png^diplazer_boxpanel.png",},
@ -257,6 +248,8 @@ on_receive_fields = function(pos, formname, fields, sender)
if fields.dip_cm10 then meta:set_string("setmode", "10") minetest.env:get_node_timer(pos):start(1) diaplzer_loadbox=1 end
if fields.dip_cm11 then meta:set_string("setmode", "11") minetest.env:get_node_timer(pos):start(1) diaplzer_loadbox=1 end
if fields.dip_cm12 then meta:set_string("setmode", "12") minetest.env:get_node_timer(pos):start(1) diaplzer_loadbox=1 end
if fields.dip_cm13 then meta:set_string("setmode", "13") minetest.env:get_node_timer(pos):start(1) diaplzer_loadbox=1 end
if fields.dip_cm14 then meta:set_string("setmode", "14") minetest.env:get_node_timer(pos):start(1) diaplzer_loadbox=1 end
if fields.dip_hlp then

110
flashlight.lua Normal file
View File

@ -0,0 +1,110 @@
minetest.register_craft({
output = "diplazer:flashlight",
recipe = {
{"default:mese_crystal","",""},
{"","default:steel_ingot", ""},
{"","","default:steel_ingot"},
}
})
local diplazer_flashlight={users={},timer=0}
function flashlight(player,slot)
local name=player:get_player_name()
for i in pairs(diplazer_flashlight.users) do
if diplazer_flashlight.users[i].player==nil then
table.remove(diplazer_flashlight.users,i)
end
if diplazer_flashlight.users[i].player:get_player_name()==name then
table.remove(diplazer_flashlight.users,i)
return
end
end
table.insert(diplazer_flashlight.users,{player=player,slot=slot,inside=0})
end
minetest.register_globalstep(function(dtime)
diplazer_flashlight.timer=diplazer_flashlight.timer+dtime
if diplazer_flashlight.timer>1 then
diplazer_flashlight.timer=0
for i in pairs(diplazer_flashlight.users) do
if diplazer_flashlight.users[i].player==nil or diplazer_flashlight.users[i].player:get_inventory()==nil then
table.remove(diplazer_flashlight.users,i)
return
end
local name=diplazer_flashlight.users[i].player:get_inventory():get_stack("main", diplazer_flashlight.users[i].slot):get_name()
local pos=diplazer_flashlight.users[i].player:getpos()
pos.y=pos.y+1.5
local n=minetest.get_node(pos).name
if diplazer_flashlight.users[i].inside>10 or name==nil or name~="diplazer:flashlight" or minetest.get_node_light(pos)>12 then
table.remove(diplazer_flashlight.users,i)
elseif n=="air" or n=="diplazer:flht" then
minetest.set_node(pos, {name="diplazer:flht"})
elseif n=="default:water_source" or n=="diplazer:flhtw" then
minetest.set_node(pos, {name="diplazer:flhtw"})
else
diplazer_flashlight.users[i].inside=diplazer_flashlight.users[i].inside+1
end
end
end
end)
minetest.register_tool("diplazer:flashlight", {
description = "Flashlight",
--range = 4,
inventory_image = "diplazer_flashlight.png",
on_use = function(itemstack, user, pointed_thing)
flashlight(user,user:get_wield_index())
return itemstack
end,
})
minetest.register_node("diplazer:flht", {
description = "Flashlight source",
tiles = {"default_wood.png",},
light_source = 12,
paramtype = "light",
walkable=false,
drawtype = "airlike",
pointable=false,
buildable_to=true,
sunlight_propagates = true,
groups = {not_in_creative_inventory=1},
on_construct=function(pos)
minetest.env:get_node_timer(pos):start(1.5)
end,
on_timer = function (pos, elapsed)
minetest.set_node(pos, {name="air"})
end,
})
minetest.register_node("diplazer:flhtw", {
description = "Water light",
drawtype = "liquid",
tiles = {"default_water.png"},
alpha = 160,
light_source = 12,
paramtype = "light",
walkable = false,
pointable = false,
diggable = false,
drop = "",
liquid_viscosity = 1,
liquidtype = "source",
liquid_alternative_flowing="diplazer:flhtw",
liquid_alternative_source="diplazer:flhtw",
liquid_renewable = false,
liquid_range = 0,
drowning = 1,
sunlight_propagates = true,
post_effect_color = {a = 103, r = 30, g = 60, b = 90},
groups = {water = 3, liquid = 3, puts_out_fire = 1},
on_construct=function(pos)
minetest.env:get_node_timer(pos):start(1.5)
end,
on_timer = function (pos, elapsed)
minetest.set_node(pos, {name="air"})
end,
})

View File

@ -1,4 +1,4 @@
diplazer_vesrion=17
diplazer_vesrion=18
diplazer_Tele={}
diplazer_UserTele={}
@ -29,6 +29,9 @@ dofile(minetest.get_modpath("diplazer") .. "/base.lua")
dofile(minetest.get_modpath("diplazer") .. "/dipbox.lua")
dofile(minetest.get_modpath("diplazer") .. "/di3dt.lua")
dofile(minetest.get_modpath("diplazer") .. "/3d2shield.lua")
dofile(minetest.get_modpath("diplazer") .. "/pchest.lua")
dofile(minetest.get_modpath("diplazer") .. "/flashlight.lua")
dofile(minetest.get_modpath("diplazer") .. "/serbot.lua")
if diplazer_Enable_gravity==true then
dofile(minetest.get_modpath("diplazer") .. "/digrav.lua")
@ -36,6 +39,9 @@ end
minetest.register_alias("di_sb", "diplazer:serbotcon")
minetest.register_alias("di_chest", "diplazer:pchest")
minetest.register_alias("di_adpick", "diplazer:adpick")
minetest.register_alias("di_pick", "diplazer:pick")
minetest.register_alias("di_s", "diplazer:armholder")

126
pchest.lua Normal file
View File

@ -0,0 +1,126 @@
minetest.register_craft({
output = "diplazer:pchest",
recipe = {
{"default:stick","default:stick","default:stick"},
{"default:stick","default:chest_locked", "default:diamond"},
{"default:stick","default:stick","default:stick"},
}
})
local function diplazer_setpchest(pos,user)
local meta = minetest.get_meta(pos)
meta:set_string("owner", user:get_player_name())
meta:set_int("state", 0)
meta:get_inventory():set_size("main", 32)
meta:get_inventory():set_size("trans", 1)
meta:set_string("formspec",
"size[8,8]" ..
"list[context;main;0,0;8,4;]" ..
"list[context;trans;0,0;0,0;]" ..
"list[current_player;main;0,4.3;8,4;]" ..
"listring[current_player;main]" ..
"listring[current_name;main]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
default.get_hotbar_bg(0,4.3))
meta:set_string("infotext", "PChest by: " .. user:get_player_name())
end
minetest.register_tool("diplazer:pchest", {
description = "Portable locked chest",
inventory_image = minetest.inventorycube("diplazer_chest3.png"),
on_place = function(itemstack, user, pointed_thing)
if minetest.is_protected(pointed_thing.above,user:get_player_name()) or minetest.registered_nodes[minetest.get_node(pointed_thing.above).name].walkable then
return itemstack
end
local p=minetest.dir_to_facedir(user:get_look_dir())
local item=itemstack:to_table()
local meta=minetest.deserialize(item["metadata"])
minetest.set_node(pointed_thing.above, {name = "diplazer:pchest_node",param1="",param2=p})
diplazer_setpchest(pointed_thing.above,user)
minetest.sound_play("default_place_node_hard", {pos=pointed_thing.above, gain = 1.0, max_hear_distance = 5,})
if meta==nil then
itemstack:take_item()
return itemstack
end
local s=meta.stuff
local its=meta.stuff.split(meta.stuff,",",",")
local nmeta=minetest.get_meta(pointed_thing.above)
for i,it in pairs(its) do
if its~="" then
nmeta:get_inventory():set_stack("main",i, ItemStack(it))
end
end
itemstack:take_item()
return itemstack:take_item()
end,
})
minetest.register_node("diplazer:pchest_node", {
description = "Portable locked chest",
tiles = {"diplazer_chest2.png","diplazer_chest2.png","diplazer_chest1.png","diplazer_chest1.png","diplazer_chest1.png","diplazer_chest3.png"},
groups = {dig_immediate = 2, not_in_creative_inventory=1},
drop="diplazer:pchest",
paramtype2 = "facedir",
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local owner = minetest.get_meta(pos):get_string("owner")
if (stack:get_name()~="diplazer:pchest") and (owner==player:get_player_name() or owner=="") then
if minetest.deserialize(stack:get_metadata())~=nil then
minetest.chat_send_player(player:get_player_name(), "Warning: the meta (information that is saved in the item)")
minetest.chat_send_player(player:get_player_name(), "will be lost when pick up the chest")
end
return stack:get_count()
end
return 0
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local owner = minetest.get_meta(pos):get_string("owner")
if owner==player:get_player_name() or owner=="" then
return stack:get_count()
end
return 0
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local owner = minetest.get_meta(pos):get_string("owner")
if owner==player:get_player_name() or owner=="" then
return count
end
return 0
end,
can_dig = function(pos, player)
local owner = minetest.get_meta(pos):get_string("owner")
return (owner=="" and minetest.get_meta(pos):get_inventory():is_empty("main"))
end,
on_punch = function(pos, node, player, pointed_thing)
if minetest.is_protected(pos,player:get_player_name()) then
return false
end
local meta=minetest.get_meta(pos)
if meta:get_string("owner")==player:get_player_name() then
local inv=meta:get_inventory()
local items=""
for i=1,32,1 do
if inv:get_stack("main",i):get_name()~="" then
items=items .. inv:get_stack("main",i):get_name() .." " .. inv:get_stack("main",i):get_count() .. " " .. inv:get_stack("main",i):get_wear() ..","
else
items=items .. ","
end
end
inv:add_item("trans", ItemStack("diplazer:pchest"))
local item=inv:get_stack("trans",1):to_table()
local tmeta={stuff=items}
item.metadata=minetest.serialize(tmeta)
player:get_inventory():add_item("main", ItemStack(item))
minetest.set_node(pos, {name = "air"})
minetest.sound_play("default_dig_dig_immediate", {pos=pos, gain = 1.0, max_hear_distance = 5,})
end
end,
})

730
serbot.lua Normal file
View File

@ -0,0 +1,730 @@
diplazer_disb={}
diplazer_disb_tmp_user=""
diplazer_dis_pvp=minetest.setting_getbool("enable_pvp")
minetest.register_craft({
output = "diplazer:serbotcon",
recipe = {
{"", "diplazer:chip", ""},
{"default:steel_ingot", "default:steelblock", "default:steel_ingot"},
{"diplazer:pick", "", "default:sword_diamond"},
},
})
minetest.register_on_leaveplayer(function(player)
local name=player:get_player_name()
if diplazer_disb[name] and diplazer_disb[name].ob then
diplazer_disb[name].ob:set_hp(0)
diplazer_disb[name].ob:punch(diplazer_disb[name].ob, {full_punch_interval=1.0,damage_groups={fleshy=4}}, "default:bronze_pick", nil)
end
diplazer_disb[name]=nil
end)
minetest.register_tool("diplazer:serbotcon", {
description = "Diplazer servicebot (controller)",
range = 15,
inventory_image = "diplazer_sbc.png",
on_use=function(itemstack, user, pointed_thing)
diplazer_disbUese(itemstack, user, pointed_thing)
return itemstack
end,
on_place=function(itemstack, user, pointed_thing)
diplazer_disbSetMode(itemstack, user, pointed_thing)
return itemstack
end,
})
for i=1,8,1 do
minetest.register_tool("diplazer:serbotcon" .. i, {
description = "Diplazer servicebot (controller)",
range = 15,
inventory_image = "diplazer_sbc.png^diplazer_mode" .. i .. ".png",
wield_image = "diplazer_sbc.png^diplazer_Colmode"..i..".png",
groups = {not_in_creative_inventory=1},
on_use=function(itemstack, user, pointed_thing)
diplazer_disbUese(itemstack, user, pointed_thing)
return itemstack
end,
on_place=function(itemstack, user, pointed_thing)
diplazer_disbSetMode(itemstack, user, pointed_thing)
return itemstack
end,
})
end
local function diplazer_distance(self,o)
if o==nil or o.x==nil then return nil end
local p=self.object:getpos()
return math.sqrt((p.x-o.x)*(p.x-o.x) + (p.y-o.y)*(p.y-o.y)+(p.z-o.z)*(p.z-o.z))
end
function diplazer_visiable(pos,ob)
if ob==nil or ob:getpos()==nil or ob:getpos().y==nil then return false end
local ta=ob:getpos()
local v = {x = pos.x - ta.x, y = pos.y - ta.y-1, z = pos.z - ta.z}
v.y=v.y-1
local amount = (v.x ^ 2 + v.y ^ 2 + v.z ^ 2) ^ 0.5
local d=math.sqrt((pos.x-ta.x)*(pos.x-ta.x) + (pos.y-ta.y)*(pos.y-ta.y)+(pos.z-ta.z)*(pos.z-ta.z))
v.x = (v.x / amount)*-1
v.y = (v.y / amount)*-1
v.z = (v.z / amount)*-1
for i=1,d,1 do
local node=minetest.registered_nodes[minetest.get_node({x=pos.x+(v.x*i),y=pos.y+(v.y*i),z=pos.z+(v.z*i)}).name]
if node.walkable then
return false
end
end
return true
end
local function diplazer_serbot_walk(self)
local pos=self.object:getpos()
local yaw=self.object:getyaw()
if yaw ~= yaw then
self.status_curr=self.status_next
return true
end
local x =math.sin(yaw) * -1
local z =math.cos(yaw) * 1
self.move.x=x
self.move.z=z
self.object:setvelocity({
x = x*(self.move.speed+1),
y = self.object:getvelocity().y,
z = z*(self.move.speed+1)})
setanim(self,"walk")
return self
end
local function diplazer_serbot_lookat(self)
local folow
local pos=self.object:getpos()
if self.status_curr=="attack" then folow=self.status_target1:getpos() end
if self.status_curr=="goto" then folow=self.status_target2 end
if folow==nil or folow.x==nil then
return false
end
local vec = {x=pos.x-folow.x, y=pos.y-folow.y, z=pos.z-folow.z}
local yaw = math.atan(vec.z/vec.x)-math.pi/2
if pos.x > folow.x then yaw = yaw+math.pi end
self.object:setyaw(yaw)
if self.status_curr~="" then diplazer_serbot_walk(self) end
return self
end
local diplazer_serbot=function(self, dtime)
self.timer=self.timer+dtime
self.timer2=self.timer2+dtime
if self.timer2>=0.2 then
self.timer2=0
-- set status by controler
if diplazer_disb[self.uname].status~="" then
if diplazer_disb[self.uname].status=="walkto" then
self.status_target1={}
self.status_target2=diplazer_disb[self.uname].target2
self.status_curr="goto"
self.status_next="stay"
self.status_static="stay"
end
if diplazer_disb[self.uname].status=="attack" then
if not diplazer_disb[self.uname].target1.e then
self.status_target1=diplazer_disb[self.uname].target1
self.status_curr="attack"
else
self.status_target2=diplazer_disb[self.uname].target2
self.status_curr="goto"
end
self.status_static="stay"
self.status_next="stay"
end
if diplazer_disb[self.uname].status=="protect" then
self.status_target1={}
self.status_target2={}
self.status_target3=diplazer_disb[self.uname].target3
self.status_curr="protect"
self.status_next="protect"
self.status_static="protect"
end
if diplazer_disb[self.uname].status=="settarget" then
if not diplazer_disb[self.uname].target1.e then
self.status_target1=diplazer_disb[self.uname].target1
self.status_next=self.status_curr
self.status_curr="attack"
elseif not diplazer_disb[self.uname].target2.e then
self.status_target2=diplazer_disb[self.uname].target2
self.status_next=self.status_curr
self.status_curr="goto"
elseif not diplazer_disb[self.uname].target3.e then
self.status_target3=diplazer_disb[self.uname].target3
end
end
if diplazer_disb[self.uname].status=="place" or diplazer_disb[self.uname].status=="dig" then
self.status_target3=diplazer_disb[self.uname].target3
self.status_target2=diplazer_disb[self.uname].target3
self.status_target1={}
self.status_curr="goto"
self.status_node=diplazer_disb[self.uname].node
self.status_next=diplazer_disb[self.uname].status
self.status_static="stay"
end
if diplazer_disb[self.uname].status=="keepdigging" then
self.status_target3=diplazer_disb[self.uname].target3
self.status_target2=diplazer_disb[self.uname].target3
self.status_target1={}
self.status_curr="goto"
self.status_next="dig"
self.status_static="keepdigging"
self.status_node=diplazer_disb[self.uname].node
end
if diplazer_disb[self.uname].status=="folow" then
self.status_target3=diplazer_disb[self.uname].target3
self.status_target2=diplazer_disb[self.uname].target3
self.status_target1={}
self.status_curr="goto"
self.status_next="stay"
self.status_static="folow"
end
diplazer_disb[self.uname].status=""
diplazer_disb[self.uname].target1={e=1}
diplazer_disb[self.uname].target2={e=1}
diplazer_disb[self.uname].target3={e=1}
end
-- if attacking or goto
if self.status_curr=="attack" or self.status_curr=="goto" then
local tpos=0
diplazer_serbot_lookat(self)
if self.status_curr=="goto" then
tpos=diplazer_distance(self,self.status_target2)
if self.stuck_path>5 then
self.stuck_path=0
self.status_curr=self.status_next
end
if tpos==nil or tpos<=2 then
self.status_curr=self.status_next
if self.status_static~="keepdigging" then
self.status_next=self.status_static
end
self.status_target2={}
if self.status_curr=="stay" or self.status_curr=="place" or self.status_curr=="dig" then
setanim(self,"stand")
self.move.x=0
self.move.z=0
self.object:setvelocity({x = self.move.x, y = 0, z =self.move.z})
end
if self.status_target2_next.x then
self.status_target2=self.status_target2_next
self.status_target2_next={}
end
if self.status_curr=="goto" then
local yaw=self.object:getyaw()
if yaw ~= yaw then return true end
yaw = yaw+math.pi
self.object:setyaw(yaw)
diplazer_serbot_walk(self)
end
end
end
if self.status_curr=="attack" then
tpos=diplazer_distance(self,self.status_target1:getpos())
if tpos==nil or tpos>self.distance or self.status_target1:get_hp()<=0 or
diplazer_visiable(self.object:getpos(),self.status_target1)==false then
self.status_curr=self.status_next
setanim(self,"stand")
return self
end
--hurting
if tpos<=3 and math.random(3)==1 then
self.object:setvelocity({x=0, y=self.move.y, z=0})
if self.status_target1:get_luaentity() and self.status_target1:get_luaentity().itemstring and self.status_static~="protect" then
self.status_target1:punch(self.user, {full_punch_interval=1.0,damage_groups={fleshy=4}}, "default:bronze_pick", nil)
else
self.status_target1:set_hp(self.status_target1:get_hp()-self.dmg)
self.status_target1:punch(self.object, {full_punch_interval=1.0,damage_groups={fleshy=4}}, "default:bronze_pick", nil)
end
if self.axid then minetest.set_node(self.status_target1:getpos(), {name="diplazer:acid_fire"}) end
setanim(self,"mine")
if self.status_target1:get_hp()<=0 and self.status_target1:is_player()==false then
self.object:set_hp(self.object:get_hp()+5)
setanim(self,"stand")
end
end
end
end
--jump+falling
--after jump
if self.move.jump==1 then
self.move.jump_timer=self.move.jump_timer-1
if self.move.jump_timer<=0 then
self.move.jump=0
self.object:setacceleration({x =0, y = 0, z =0})
end
end
--front of a wall
if self.move.y==0 and self.move.jump==0 then
local ppos=self.object:getpos()
local nodes={}
for i=1,5,1 do --starts front of the object and y: -2 to +2
nodes[i]=minetest.registered_nodes[minetest.get_node({x=ppos.x+self.move.x,y=ppos.y+(i-3.5),z=ppos.z+self.move.z}).name].walkable
end
-- jump over 2
if (nodes[3]==true and nodes[5]==false) or (nodes[3]==false and nodes[4]==true and nodes[5]==false) then
local pos=self.object:getpos()
local pos3={x=pos.x,y=pos.y+1,z=pos.z}
self.move.jump=1
self.move.jump_timer=1
self.move.y=5
self.move.x=self.move.x*2
self.move.z=self.move.z*2
self.object:setvelocity({x = self.move.x, y = self.move.y, z =self.move.z})
self.object:setacceleration({x =0, y = self.move.y, z =0})
end
-- if sides passable
if nodes[3]==true and nodes[5]==true then
local ispp=self.object:getpos()
ispp={x=ispp.x+self.move.x,y=ispp.y,z=ispp.z+self.move.z}
local yaw=self.object:getyaw()
if yaw ~= yaw then return true end
local z=math.sin(yaw) * -1
local x=math.cos(yaw) * 1
local sidel1={}
local sidel2={}
local sidel3={}
local sider1={}
local sider2={}
local sider3={}
for i=0,10,1 do --starts front of the object and y: -2 to +2
sidel1[i]=minetest.registered_nodes[minetest.get_node({x=ispp.x+(x*i),y=ispp.y+1,z=ispp.z+(z*i)}).name].walkable
sidel2[i]=minetest.registered_nodes[minetest.get_node({x=ispp.x+(x*i),y=ispp.y, z=ispp.z+(z*i)}).name].walkable
sidel3[i]=minetest.registered_nodes[minetest.get_node({x=ispp.x+(x*i),y=ispp.y-1, z=ispp.z+(z*i)}).name].walkable
if (sidel1[i]==false and sidel2[i]==false) or (sidel2[i]==false and sidel3[i]==false) then
self.status_next=self.status_curr
self.status_curr="goto"
self.status_target2_next=self.status_target2
self.status_target2={x=ispp.x+(x*i),y=ispp.y+1,z=ispp.z+(z*i)}
diplazer_serbot_lookat(self)
break
end
sider1[i]=minetest.registered_nodes[minetest.get_node({x=ispp.x+(x*(i*-1)),y=ispp.y+1,z=ispp.z+(z*(i*-1))}).name].walkable
sider2[i]=minetest.registered_nodes[minetest.get_node({x=ispp.x+(x*(i*-1)),y=ispp.y, z=ispp.z+(z*(i*-1))}).name].walkable
sider3[i]=minetest.registered_nodes[minetest.get_node({x=ispp.x+(x*(i*-1)),y=ispp.y-1, z=ispp.z+(z*(i*-1))}).name].walkable
if (sider1[i]==false and sider2[i]==false) or (sider2[i]==false and sider3[i]==false) then
self.status_next=self.status_curr
self.status_curr="goto"
self.status_target2_next=self.status_target2
self.status_target2={x=ispp.x+(x*(i*-1)),y=ispp.y,z=ispp.z+(z*(i*-1))}
diplazer_serbot_lookat(self)
break
end
end
self.stuck_path=self.stuck_path+1
end
-- jump & attack
if nodes[1]==false and nodes[2]==false and self.status_curr=="attack" then
local pos=self.object:getpos()
if minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name].walkable==true then
self.move.x=self.move.x*2
self.move.z=self.move.z*2
self.move.jump=1
self.move.jump_timer=1
self.object:setvelocity({x = self.move.x, y = 1, z =self.move.z})
self.object:setacceleration({x =0, y = 1, z =0})
end
end
end
--falling
if self.move.jump==0 then
local pos=self.object:getpos()
local nnode=minetest.get_node({x=pos.x,y=pos.y-1.5,z=pos.z}).name
local node=minetest.registered_nodes[nnode]
if node and node.walkable==false then
self.move.y=-10
self.object:setacceleration({x =0, y = self.move.y, z =0})
end
if node and node.walkable==true and self.move.y~=0 then
self.move.y=0
end
end
end
if self.timer<0.6 then return true end
--Common==========================================
self.timer=0
if self.object==nil then return false end
local pos=self.object:getpos()
self.timer3=self.timer3+0.5
-- timer3
if self.timer3>1 then
self.timer3=0
-- teleport if too far away
if self.status_static~="protect" and self.status_static~="folow" and diplazer_distance(self,self.user:getpos())>17 then
self.object:moveto(self.user:getpos())
minetest.sound_play("diplazer_teleport", {pos = self.object:getpos(), gain = 1.1, max_hear_distance = 5,})
end
-- protect
if self.status_static=="protect" then
if self.status_curr~="attack" and self.status_target3~=nil and (self.status_target3:get_luaentity() or self.status_target3:is_player()) and diplazer_distance(self,self.status_target3:getpos())>5 then
self.status_target2=self.status_target3:getpos()
self.status_curr="goto"
self.status_next="stay"
if diplazer_distance(self,self.status_target3:getpos())>17 then
local p=self.status_target3:getpos()
p={x=p.x,y=p.y+1,z=p.z}
self.object:moveto(p)
minetest.sound_play("diplazer_teleport", {pos = self.object:getpos(), gain = 1.1, max_hear_distance = 5,})
end
elseif self.status_target3==nil or (self.status_target3:get_luaentity()==nil and self.status_target3:is_player()==false) then
self.status_curr="protect"
self.status_target3=self.user
elseif self.status_curr=="stay" then
self.status_curr="protect"
end
end
--place
if self.status_curr=="place" and minetest.is_protected(self.status_target3, self.uname)==false then
local stack=self.user:get_inventory():get_stack("main", self.user:get_wield_index()-1):get_name()
if stack~="" then
minetest.set_node(self.status_target3, {name=stack})
self.user:get_inventory():remove_item("main",stack)
minetest.sound_play("default_place_node_hard", {pos = self.object:getpos(), gain = 1.1, max_hear_distance = 5,})
self.status_curr="stay"
end
end
--dig
if self.status_curr=="dig" and minetest.is_protected(self.status_target3, self.uname)==false and diplazer_is_unbreakable(self.status_target3)==false then
minetest.node_dig(self.status_target3,{name=self.status_node},self.user)
minetest.sound_play("default_dig_dig_immediate", {pos = self.object:getpos(), gain = 1.1, max_hear_distance = 5,})
self.status_curr="stay"
end
--keepdigging
if self.status_static=="keepdigging" and (self.status_curr=="stay" or self.status_curr=="keepdigging") then --
np=minetest.find_node_near(self.object:getpos(), self.distance,self.status_node)
if np==nil then
self.status_curr="stay"
else
local p={x=np.x,y=np.y+1,z=np.z}
self.status_target3={x=np.x,y=np.y,z=np.z}
if minetest.get_node(p).name~="air" then np.y=np.y+1 end
self.status_target2=np
self.status_curr="goto"
self.status_nexr="dig"
end
end
--folow
if self.status_static=="folow" then
if self.status_target3~=nil and (self.status_target3:get_luaentity() or self.status_target3:is_player()) and diplazer_distance(self,self.status_target3:getpos())>5 then
self.status_target2=self.status_target3:getpos()
self.status_curr="goto"
self.status_next="stay"
if diplazer_distance(self,self.status_target3:getpos())>17 then
local p=self.status_target3:getpos()
p={x=p.x,y=p.y+1,z=p.z}
self.object:moveto(p)
minetest.sound_play("diplazer_teleport", {pos = self.object:getpos(), gain = 1.1, max_hear_distance = 5,})
end
elseif self.status_target3==nil or (self.status_target3:get_luaentity()==nil and self.status_target3:is_player()==false) then
self.status_curr="protect"
self.status_target3=self.user
end
if self.object:get_hp()<self.hp_max then self.object:set_hp(self.object:get_hp()+1) end
end
end-- end of timer3
if self.status_curr=="goto" then
diplazer_serbot_lookat(self)
end
if self.status_curr=="stay" then
self.stuck_path=0
setanim(self,"stand")
self.move.x=0
self.move.z=0
self.object:setvelocity({x = self.move.x, y = 0, z =self.move.z})
end
if self.status_curr~="protect" then return self end
--attack
local todmg=1
for i, ob in pairs(minetest.get_objects_inside_radius(pos, self.distance)) do
if ((ob:is_player() and ob:get_player_name()~=self.uname) or (ob:get_luaentity() and ob:get_luaentity().team~=self.team and ob:get_luaentity().uname~=self.uname)) and not (ob:get_attach()) then
if diplazer_visiable(pos,ob) and ((not ob:get_luaentity()) or (ob:get_luaentity() and (not(self.status_curr=="attack" and ob:get_luaentity().name=="__builtin:item")))) then
if self.status_static=="protect" then
local op=ob:getpos()
local tp=self.status_target3:getpos()
if not (op.x==tp.x and op.z==tp.z and ob:get_hp()==self.status_target3:get_hp()) then
self.status_target1=ob
self.status_curr="attack"
break
end
else
self.status_target1=ob
self.status_curr="attack"
break
end
end
end
end
diplazer_serbot_lookat(self)
end
function setanim(self,type)
local curr=self.anim_curr~=type
if type=="stand" and curr then self.object:set_animation({ x= 0, y= 79, },30,0)
elseif type=="lay" and curr then self.object:set_animation({ x=162, y=166, },30,0)
elseif type=="walk" and curr then self.object:set_animation({ x=168, y=187, },30,0)
elseif type=="mine" and curr then self.object:set_animation({ x=189, y=198, },30,0)
elseif type=="walk_mine" and curr then self.object:set_animation({ x=200, y=219, },30,0)
elseif type=="sit" and curr then self.object:set_animation({x= 81, y=160, },30,0)
else return self
end
self.anim_curr=type
return self
end
minetest.register_entity("diplazer:serbot",{
hp_max = 35,
physical = true,
weight = 5,
collisionbox = {-0.35,-1.0,-0.35,0.35,0.8,0.35},
visual = "mesh",
visual_size ={x=1,y=1},
mesh = "character.b3d",
textures = {"diplazer_sb.png"},
colors = {},
spritediv = {x=1, y=1},
initial_sprite_basepos = {x=0, y=0},
is_visible = true,
makes_footstep_sound = false,
automatic_rotate = false,
on_punch=function(self, puncher, time_from_last_punch, tool_capabilities, dir)
if dir~=nil then self.object:setvelocity({x = dir.x*3,y = self.object:getvelocity().y,z = dir.z*3}) end
if puncher:is_player() and (puncher:get_player_name()==self.uname or self.status_static=="folow") then return self end
local pos=self.object:getpos()
self.status_target1=puncher
self.status_curr="attack"
diplazer_serbot_lookat(self)
end,
on_activate=function(self, staticdata)
if diplazer_disb_tmp_user~="" then
self.user=diplazer_disb_tmp_user
diplazer_disb_tmp_user=""
else
self.object:remove()
return self
end
self.uname=self.user:get_player_name()
if diplazer_disb[self.uname].ob and
diplazer_disb[self.uname].ob:get_hp() and
diplazer_disb[self.uname].ob:get_hp()>0 then
self.object:remove()
return self
end
self.object:setvelocity({x=0,y=-1,z=0})
self.object:setacceleration({x=0,y=-1,z=0})
setanim(self,"stand")
end,
on_step=diplazer_serbot,
anim_curr="",
status_curr="stay",
status_static="stay",
status_next="",
status_target1={},
status_target2={},
status_target2_next={},
timer=0,
timer2=0,
timer3=0,
move={x=0,y=0,z=0,jump=0,jump_timer=0,speed=3},
dmg=5,
team="disb",
type = "npc",
distance=15,
stuck_path=0,
})
function diplazer_disbUese(itemstack, user, pointed_thing)
local item=itemstack:to_table()
local meta=minetest.deserialize(item["metadata"])
local mode=0
local name=user:get_player_name()
if meta==nil then
diplazer_disbSetMode(itemstack, user, pointed_thing)
return itemstack
end
mode=(meta.mode)
if (not diplazer_disb[name]) or diplazer_disb[name].ob:get_hp()<=1 then
local p=user:getpos()
p={x=p.x,y=p.y+1,z=p.z}
diplazer_disb_tmp_user=user
diplazer_disb[name]={}
diplazer_disb[name].status="stay"
diplazer_disb[name].target1={e=1} --object
diplazer_disb[name].target2={e=1} --pos
diplazer_disb[name].target3={e=1} --static object
if diplazer_disb[name].ob and diplazer_disb[name].ob:get_hp()<=1 then -- if has been removed in somehow
diplazer_disb[name].ob:set_hp(0)
diplazer_disb[name].ob:punch(diplazer_disb[name].ob, {full_punch_interval=1.0,damage_groups={fleshy=4}}, "default:bronze_pick", nil)
end
diplazer_disb[name].ob=minetest.env:add_entity({x=p.x,y=p.y+1,z=p.z}, "diplazer:serbot")
diplazer_disb[name].ob:set_properties({nametag = name .." (DiSB)", nametag_color = "#00CF80"})
end
if mode==1 then
if pointed_thing.type=="node" then
diplazer_disb[name].target2=pointed_thing.above
elseif pointed_thing.type=="object" then
diplazer_disb[name].target2=pointed_thing.ref:getpos()
else
return itemstack
end
diplazer_disb[name].status="walkto"
diplazer_disb[name].target1={e=1}
return itemstack
end
if mode==2 then
if pointed_thing.type=="node" then
diplazer_disb[name].target1={e=1}
diplazer_disb[name].target2=pointed_thing.above
elseif pointed_thing.type=="object" then
diplazer_disb[name].target2={e=1}
diplazer_disb[name].target1=pointed_thing.ref
else
return itemstack
end
diplazer_disb[name].status="settarget"
return itemstack
end
if mode==3 then
if pointed_thing.type=="object" then
diplazer_disb[name].target3=pointed_thing.ref
diplazer_disb[name].target2={e=1}
diplazer_disb[name].target1={e=1}
else
diplazer_disb[name].target3=user
diplazer_disb[name].target2={e=1}
diplazer_disb[name].target1={e=1}
end
diplazer_disb[name].status="protect"
return itemstack
end
if mode==4 then
if pointed_thing.type=="node" and minetest.is_protected(pointed_thing.above, user:get_player_name())==false then
diplazer_disb[name].target3=pointed_thing.above
diplazer_disb[name].target2={e=1}
diplazer_disb[name].target1={e=1}
diplazer_disb[name].status="place"
end
return itemstack
end
if mode==5 then
if pointed_thing.type=="node" and minetest.is_protected(pointed_thing.under, user:get_player_name())==false then
diplazer_disb[name].target3=pointed_thing.under
diplazer_disb[name].target2={e=1}
diplazer_disb[name].target1={e=1}
diplazer_disb[name].node=minetest.get_node(pointed_thing.under).name
diplazer_disb[name].status="dig"
end
return itemstack
end
if mode==6 then
if pointed_thing.type=="node" and minetest.is_protected(pointed_thing.under, user:get_player_name())==false then
diplazer_disb[name].target3=pointed_thing.under
diplazer_disb[name].target2=pointed_thing.above
diplazer_disb[name].target1={}
diplazer_disb[name].node=minetest.get_node(pointed_thing.under).name
diplazer_disb[name].status="keepdigging"
end
return itemstack
end
if mode==7 then
if pointed_thing.type=="object" then
diplazer_disb[name].target3=pointed_thing.ref
diplazer_disb[name].target2=pointed_thing.ref:getpos()
diplazer_disb[name].target1={e=1}
else
diplazer_disb[name].target3=user
diplazer_disb[name].target2=user:getpos()
diplazer_disb[name].target1={e=1}
end
diplazer_disb[name].status="folow"
return itemstack
end
if mode==8 then
diplazer_disb[name].ob:set_hp(0)
diplazer_disb[name].ob:punch(diplazer_disb[name].ob, {full_punch_interval=1.0,damage_groups={fleshy=4}}, "default:bronze_pick", nil)
diplazer_disb[name]=nil
return itemstack
end
return itemstack
end
function diplazer_disbSetMode(itemstack, user, pointed_thing)
local item=itemstack:to_table()
local meta=minetest.deserialize(item["metadata"])
local mode=0
if meta==nil then
meta={}
mode=1
else
mode=mode+1
end
if meta.mode==nil then
meta.mode=1
else
meta.mode=meta.mode+1
end
mode=(meta.mode)
if user:get_player_control().sneak then mode=mode-2 end
if mode<=0 then mode=8 end
local msg={}
msg[1]="walk to"
msg[2]="attack object"
msg[3]="protect (point a object, or something else to you)"
msg[4]="place block"
msg[5]="dig block"
msg[6]="keep digging"
msg[7]="folow (point a object, or something else to you)"
msg[8]="destroy"
if msg[mode]==nil then mode=1 meta.mode=1 end
meta.mode=mode
item.name="diplazer:serbotcon"..mode
item.metadata=minetest.serialize(meta)
itemstack:replace(item)
minetest.chat_send_player(user:get_player_name(),"Disb mode" .. mode .. ": " .. msg[mode] )
minetest.sound_play("diplazer_mode", {pos =user:getpos(), gain = 2.0, max_hear_distance = 3,})
return itemstack
end

View File

@ -1,18 +1,18 @@
--priv for moderator: diplazer_gun
--priv for admin: diplazer_admin
diplazer_Enable_di3Dt_for_all=true
diplazer_Enable_mode8=true --gravitygun takes little more when used, then its off again
diplazer_Enable_mode11=true -- place platfom, can make massive effects at 1 use
diplazer_Enable_mode12=true -- dig platfom, can make massive effects at 1 use
diplazer_mode1314_Max=20 --limetation for mode 13 & 14 20x20x20 as default
diplazer_mode11_max=30 --limetation for mode12 30x30 as default
diplazer_mode12_max=30
diplazer_Enable_di3Dt_for_all=true
diplazer_Enable_mode8=true --gravitygun takes little more when used, then its off again
diplazer_Enable_warning_mode11_12=true
diplazer_warning_mode11_12=11
diplazer_Enable_com_mode8=false
diplazer_Enable_com_mode11=true
diplazer_Enable_com_mode12=true --common players can dig up to 7x7 nodes at same time
diplazer_Enable_gravity=true
diplazer_gravity_to_use=0.5

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 B

After

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 247 B

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 773 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 B

After

Width:  |  Height:  |  Size: 252 B

BIN
textures/diplazer_sb.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 B

BIN
textures/diplazer_sbc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 993 B