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
905d7025
Commit
905d7025
authored
8 years ago
by
rnd1
Browse files
Options
Downloads
Patches
Plain Diff
fixes
parent
e75ba494
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
+3
-2
3 additions, 2 deletions
commands.lua
init.lua
+25
-23
25 additions, 23 deletions
init.lua
with
28 additions
and
25 deletions
commands.lua
+
3
−
2
View file @
905d7025
...
...
@@ -164,14 +164,15 @@ basic_robot.commands.take_item = function(name,item, inventory,dir)
if
not
inventory
then
inventory
=
"main"
;
end
--if not inv then return end
local
stack
=
ItemStack
(
item
);
if
(
not
tinv
:
contains_item
(
inventory
,
stack
)
or
not
inv
:
room_for_item
(
"main"
,
stack
))
and
meta
:
get_int
(
"admin"
)
~=
1
then
local
contains
=
tinv
:
contains_item
(
inventory
,
stack
);
if
(
not
contains
or
not
inv
:
room_for_item
(
"main"
,
stack
))
and
meta
:
get_int
(
"admin"
)
~=
1
then
return
false
end
inv
:
add_item
(
"main"
,
stack
);
tinv
:
remove_item
(
inventory
,
stack
);
return
true
return
contains
end
...
...
This diff is collapsed.
Click to expand it.
init.lua
+
25
−
23
View file @
905d7025
...
...
@@ -341,7 +341,7 @@ end
local
function
check_code
(
code
)
--"while ", "for ", "do ","goto ",
local
bad_code
=
{
"repeat "
,
"until "
,
"_ccounter"
,
"_G"
,
"while%("
,
"while{"
,
"pcall"
}
local
bad_code
=
{
"repeat "
,
"until "
,
"_ccounter"
,
"_G"
,
"while%("
,
"while{"
,
"pcall"
,
"
\\\"
"
}
for
_
,
v
in
pairs
(
bad_code
)
do
if
string.find
(
code
,
v
)
then
...
...
@@ -392,54 +392,64 @@ local function CompileCode ( script )
local
i1
-- process script to insert call counter in every function
local
insert_code
=
" increase_ccounter(); "
;
local
i1
=
0
;
local
i2
=
0
;
local
i1
=
0
;
local
i2
=
0
;
local
found
=
true
;
while
(
i2
)
do
-- PROCESS SCRIPT AND INSERT COUNTER AT PROBLEMATIC SPOTS
i2
=
nil
;
i2
=
string.find
(
script
,
"function"
,
i1
)
-- fix functions
while
(
found
)
do
-- PROCESS SCRIPT AND INSERT COUNTER AT PROBLEMATIC SPOTS
found
=
false
;
i2
=
nil
;
i2
=
string.find
(
script
,
"while "
,
i1
)
-- fix while OK
if
i2
then
--minetest.chat_send_all("while0");
if
not
is_inside_string
(
i2
,
script
)
then
i2
=
string.find
(
script
,
")"
,
i2
);
local
i21
=
i2
;
i2
=
string.find
(
script
,
"do "
,
i2
);
if
i2
then
script
=
script
.
sub
(
script
,
1
,
i2
)
..
insert_code
..
script
.
sub
(
script
,
i2
+
1
);
i1
=
i2
+
string.len
(
insert_code
);
script
=
script
.
sub
(
script
,
1
,
i2
+
1
)
..
insert_code
..
script
.
sub
(
script
,
i2
+
2
);
i1
=
i21
+
6
;
-- after while
found
=
true
;
end
end
end
i2
=
string.find
(
script
,
"f
or
"
,
i1
)
-- fix f
or OK
i2
=
string.find
(
script
,
"f
unction
"
,
i1
)
-- fix f
unctions
if
i2
then
--minetest.chat_send_all("func0")
if
not
is_inside_string
(
i2
,
script
)
then
i2
=
string.find
(
script
,
"
do
"
,
i2
);
i2
=
string.find
(
script
,
"
)
"
,
i2
);
if
i2
then
script
=
script
.
sub
(
script
,
1
,
i2
+
1
)
..
insert_code
..
script
.
sub
(
script
,
i2
+
2
);
script
=
script
.
sub
(
script
,
1
,
i2
)
..
insert_code
..
script
.
sub
(
script
,
i2
+
1
);
i1
=
i2
+
string.len
(
insert_code
);
found
=
true
;
end
end
end
i2
=
string.find
(
script
,
"
while
"
,
i1
)
-- fix
while
OK
i2
=
string.find
(
script
,
"
for
"
,
i1
)
-- fix
for
OK
if
i2
then
if
not
is_inside_string
(
i2
,
script
)
then
i2
=
string.find
(
script
,
"do "
,
i2
);
if
i2
then
script
=
script
.
sub
(
script
,
1
,
i2
+
1
)
..
insert_code
..
script
.
sub
(
script
,
i2
+
2
);
i1
=
i2
+
string.len
(
insert_code
);
found
=
true
;
end
end
end
i2
=
string.find
(
script
,
"goto "
,
i1
)
-- fix goto OK
if
i2
then
if
not
is_inside_string
(
i2
,
script
)
then
script
=
script
.
sub
(
script
,
1
,
i2
-
1
)
..
insert_code
..
script
.
sub
(
script
,
i2
);
i1
=
i2
+
string.len
(
insert_code
)
+
5
;
-- insert + skip goto
found
=
true
;
end
end
--minetest.chat_send_all("code rem " .. string.sub(script,i1))
end
...
...
@@ -490,15 +500,7 @@ local function runSandbox( name)
return
nil
end
-- note: to see memory used by lua in kbytes: collectgarbage("count")
-- /spawnentity basic_robot:robot
-- TODO.. display form when right click robot
local
function
update_formspec_robot
(
self
)
end
local
robot_spawner_update_form
=
function
(
pos
,
mode
)
...
...
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