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
3dcc9915
Commit
3dcc9915
authored
8 years ago
by
rnd1
Browse files
Options
Downloads
Patches
Plain Diff
bugfix - object sync
parent
852ce0ea
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
init.lua
+14
-12
14 additions, 12 deletions
init.lua
with
14 additions
and
12 deletions
init.lua
+
14
−
12
View file @
3dcc9915
...
...
@@ -3,7 +3,7 @@ basic_robot = {};
basic_robot
.
data
=
{};
--[[
[name] = {sandbox= .., bytecode = ..., ram = ..., obj = robot object}
[name] = {sandbox= .., bytecode = ..., ram = ..., obj = robot object
,spawnpos=...
}
robot object = object of entity, used to manipulate movements and more
--]]
...
...
@@ -14,7 +14,7 @@ dofile(minetest.get_modpath("basic_robot").."/commands.lua")
-- SANDBOX for running lua code isolated and safely
function
getSandboxEnv
(
name
)
local
obj
=
basic_robot
.
data
[
name
].
obj
;
local
obj
=
basic_robot
.
data
[
name
].
obj
;
-- bug: this doesnt refresh always??
local
commands
=
basic_robot
.
commands
;
return
{
...
...
@@ -209,6 +209,7 @@ minetest.register_entity("basic_robot:robot",{
-- how to make it remember owner when it reactivates ?? staticdata seems to be empty
self
.
object
:
set_armor_groups
({
fleshy
=
0
})
if
staticdata
~=
""
then
-- reactivate robot
self
.
owner
=
staticdata
;
-- remember its owner
...
...
@@ -218,15 +219,14 @@ minetest.register_entity("basic_robot:robot",{
return
;
end
if
self
.
code
==
""
then
self
.
object
:
remove
();
return
;
end
basic_robot
.
data
[
self
.
owner
].
obj
=
self
.
object
;
initSandbox
(
self
.
owner
)
self
.
running
=
1
;
local
pos
=
basic_robot
.
data
[
self
.
owner
].
spawnpos
;
local
meta
=
minetest
.
get_meta
(
pos
);
if
meta
then
self
.
code
=
meta
:
get_string
(
"code"
)
end
return
end
...
...
@@ -245,6 +245,7 @@ minetest.register_entity("basic_robot:robot",{
self
.
running
=
0
;
-- stop execution
self
.
object
:
remove
();
end
basic_robot
.
data
[
self
.
owner
].
spawnpos
=
{
x
=
self
.
spawnpos
.
x
,
y
=
self
.
spawnpos
.
y
,
z
=
self
.
spawnpos
.
z
};
self
.
running
=
1
end
...
...
@@ -337,17 +338,17 @@ local spawn_robot = function(pos,node,ttl)
local
owner
=
meta
:
get_string
(
"owner"
)
-- if robot already exists do nothing
if
basic_robot
.
data
[
owner
]
and
basic_robot
.
data
[
owner
].
obj
then
if
basic_robot
.
data
[
owner
].
obj
:
getpos
()
then
minetest
.
chat_send_player
(
owner
,
"#ROBOT ERROR : robot already active"
)
return
end
minetest
.
chat_send_player
(
owner
,
"#ROBOT ERROR : robot already active"
)
return
end
local
obj
=
minetest
.
add_entity
(
pos
,
"basic_robot:robot"
);
local
luaent
=
obj
:
get_luaentity
();
luaent
.
owner
=
meta
:
get_string
(
"owner"
);
luaent
.
code
=
meta
:
get_string
(
"code"
);
luaent
.
spawnpos
=
minetest
.
pos_to_string
({
x
=
pos
.
x
,
y
=
pos
.
y
-
1
,
z
=
pos
.
z
});
luaent
.
spawnpos
=
{
x
=
pos
.
x
,
y
=
pos
.
y
-
1
,
z
=
pos
.
z
};
-- note:
end
minetest
.
register_node
(
"basic_robot:spawner"
,
{
...
...
@@ -433,6 +434,7 @@ minetest.register_node("basic_robot:spawner", {
if
not
basic_robot
.
data
[
owner
]
then
return
end
if
basic_robot
.
data
[
owner
].
obj
then
basic_robot
.
data
[
owner
].
obj
:
remove
();
basic_robot
.
data
[
owner
].
obj
=
nil
;
end
return
end
...
...
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