Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
basic_robot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
basic_robot
Commits
779f0ab4
Commit
779f0ab4
authored
8 years ago
by
rnd1
Browse files
Options
Downloads
Patches
Plain Diff
robot: digcount increases even with dig attempt
pickup: picks up entities around robot table of items it wont pickup
parent
905d7025
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
commands.lua
+43
-5
43 additions, 5 deletions
commands.lua
init.lua
+17
-3
17 additions, 3 deletions
init.lua
with
60 additions
and
8 deletions
commands.lua
+
43
−
5
View file @
779f0ab4
...
...
@@ -82,7 +82,9 @@ basic_robot.commands.dig = function(name,dir)
local
digcount
=
0
;
if
basic_robot
.
maxdig
~=
0
then
digcount
=
basic_robot
.
data
[
name
].
digcount
;
if
digcount
>
basic_robot
.
maxdig
then
return
false
end
if
digcount
>
basic_robot
.
maxdig
then
basic_robot
.
data
[
name
].
digcount
=
digcount
+
1
;
return
false
end
end
local
obj
=
basic_robot
.
data
[
name
].
obj
;
...
...
@@ -100,7 +102,7 @@ basic_robot.commands.dig = function(name,dir)
basic_robot
.
give_drops
(
nodename
,
inv
);
minetest
.
set_node
(
pos
,{
name
=
"air"
})
basic_robot
.
data
[
name
].
digcount
=
digcount
+
1
;
--DS: sounds
local
sounds
=
minetest
.
registered_nodes
[
nodename
].
sounds
...
...
@@ -111,7 +113,7 @@ basic_robot.commands.dig = function(name,dir)
end
end
basic_robot
.
data
[
name
].
digcount
=
digcount
+
1
;
return
true
end
...
...
@@ -176,6 +178,42 @@ basic_robot.commands.take_item = function(name,item, inventory,dir)
end
basic_robot
.
no_teleport_table
=
{
[
"itemframes:item"
]
=
true
,
[
"signs:text"
]
=
true
,
[
"basic_robot:robot"
]
=
true
}
basic_robot
.
commands
.
pickup
=
function
(
r
,
name
)
if
r
>
8
then
return
false
end
local
pos
=
basic_robot
.
data
[
name
].
obj
:
getpos
();
local
spos
=
basic_robot
.
data
[
name
].
spawnpos
;
-- position of spawner block
local
meta
=
minetest
.
get_meta
(
spos
);
local
inv
=
minetest
.
get_meta
(
spos
):
get_inventory
();
for
_
,
obj
in
pairs
(
minetest
.
get_objects_inside_radius
({
x
=
pos
.
x
,
y
=
pos
.
y
,
z
=
pos
.
z
},
r
))
do
local
lua_entity
=
obj
:
get_luaentity
()
if
not
obj
:
is_player
()
and
lua_entity
and
lua_entity
.
itemstring
~=
""
then
local
detected_obj
=
lua_entity
.
name
or
""
if
not
basic_robot
.
no_teleport_table
[
detected_obj
]
then
-- object on no teleport list
-- put item in chest
local
stack
=
ItemStack
(
lua_entity
.
itemstring
)
if
inv
:
room_for_item
(
"main"
,
stack
)
then
inv
:
add_item
(
"main"
,
stack
);
end
obj
:
remove
();
end
end
end
return
true
end
basic_robot
.
commands
.
read_node
=
function
(
name
,
dir
)
local
obj
=
basic_robot
.
data
[
name
].
obj
;
...
...
@@ -203,7 +241,7 @@ basic_robot.commands.place = function(name,nodename, dir)
local
meta
=
minetest
.
get_meta
(
spos
);
local
inv
=
meta
:
get_inventory
();
if
not
inv
then
return
false
end
if
not
inv
:
contains_item
(
"main"
,
ItemStack
(
nodename
))
and
meta
:
get_int
(
"admin"
)
~=
1
then
return
end
if
not
inv
:
contains_item
(
"main"
,
ItemStack
(
nodename
))
and
meta
:
get_int
(
"admin"
)
~=
1
then
return
false
end
inv
:
remove_item
(
"main"
,
ItemStack
(
nodename
));
--DS
...
...
@@ -215,7 +253,7 @@ basic_robot.commands.place = function(name,nodename, dir)
end
end
placename
=
basic_robot
.
plant_table
[
nodename
];
local
placename
=
basic_robot
.
plant_table
[
nodename
];
if
placename
then
minetest
.
set_node
(
pos
,{
name
=
placename
})
tick
(
pos
);
-- needed for seeds to grow
...
...
This diff is collapsed.
Click to expand it.
init.lua
+
17
−
3
View file @
779f0ab4
...
...
@@ -84,8 +84,13 @@ function getSandboxEnv (name)
down
=
function
(
item
,
inventory
)
commands
.
take_item
(
name
,
item
,
inventory
,
6
)
end
,
up
=
function
(
item
,
inventory
)
commands
.
take_item
(
name
,
item
,
inventory
,
5
)
end
,
},
-- take item from inventory TODO
},
pickup
=
function
(
r
)
-- pick up items around robot
commands
.
pickup
(
r
,
name
);
end
,
self
=
{
pos
=
function
()
return
basic_robot
.
data
[
name
].
obj
:
getpos
()
end
,
spawnpos
=
function
()
return
basic_robot
.
data
[
name
].
spawnpos
end
,
...
...
@@ -168,6 +173,11 @@ function getSandboxEnv (name)
basic_robot
.
data
[
name
].
fire_pos
=
nil
;
return
fire_pos
end
,
label
=
function
(
text
)
local
obj
=
basic_robot
.
data
[
name
].
obj
;
obj
:
set_properties
({
nametag
=
"["
..
name
..
"] "
..
text
});
end
,
},
find_nodes
=
...
...
@@ -367,6 +377,8 @@ local function is_inside_string(pos,script)
i2
=
string.find
(
script
,
"
\"
"
,
i1
+
1
);
if
i2
then
par
=
1
-
par
;
else
return
false
end
if
par
==
0
then
if
i1
<
pos
and
pos
<
i2
then
...
...
@@ -547,7 +559,7 @@ local function init_robot(self)
basic_robot
.
data
[
self
.
owner
].
quiet_mode
=
false
;
self
.
object
:
set_properties
({
infotext
=
"robot "
..
self
.
owner
});
self
.
object
:
set_properties
({
nametag
=
"
robot
"
..
self
.
owner
,
nametag_color
=
"LawnGreen"
});
self
.
object
:
set_properties
({
nametag
=
"
[
"
..
self
.
owner
..
"]"
,
nametag_color
=
"LawnGreen"
});
self
.
object
:
set_armor_groups
({
fleshy
=
0
})
initSandbox
(
self
.
owner
)
...
...
@@ -768,6 +780,7 @@ local on_receive_robot_form = function(pos, formname, fields, sender)
"turn.left(), turn.right(), turn.angle(45)\n"
..
"dig.direction()\n place.direction(\"
default
:
dirt
\
")\nread_node.direction() tells you names of nodes\n"
..
"insert.direction(item, inventory) inserts item from robot inventory to target inventory\n"
..
"pickup(r) picks up all items around robot in radius r<8\n"
..
"take.direction(item, inventory) takes item from target inventory into robot inventory\n"
..
"read_text.direction(stringname) reads text of signs, chests and other blocks, optional stringname for other meta\n"
..
"**BOOKS/CODE\nbook.read(i) returns contents of book at i-th position in library \nbook.write(i,text) writes book at i-th position\n"
..
...
...
@@ -790,7 +803,8 @@ local on_receive_robot_form = function(pos, formname, fields, sender)
"self.spawnpos() returns position of spawner block\n"
..
"self.viewdir() returns vector of view for robot\n"
..
"self.fire(speed, pitch,gravity) fires a projectile from robot\n"
..
"self.fire_pos() returns last hit position\n "
;
"self.fire_pos() returns last hit position\n "
..
"self.label(text) changes robot label"
;
text
=
minetest
.
formspec_escape
(
text
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment