Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna-minetest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
illuna-minetest
Commits
32001d1e
Commit
32001d1e
authored
11 years ago
by
sapier
Committed by
PilzAdam
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
merge mainmenu_helper.lua to misc_helpers.lua
parent
e3827fbc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
builtin/mainmenu_helper.lua
+0
-165
0 additions, 165 deletions
builtin/mainmenu_helper.lua
builtin/misc_helpers.lua
+142
-3
142 additions, 3 deletions
builtin/misc_helpers.lua
src/guiEngine.cpp
+1
-1
1 addition, 1 deletion
src/guiEngine.cpp
with
143 additions
and
169 deletions
builtin/mainmenu_helper.lua
deleted
100644 → 0
+
0
−
165
View file @
e3827fbc
--------------------------------------------------------------------------------
function
dump
(
o
,
dumped
)
dumped
=
dumped
or
{}
if
type
(
o
)
==
"number"
then
return
tostring
(
o
)
elseif
type
(
o
)
==
"string"
then
return
string.format
(
"%q"
,
o
)
elseif
type
(
o
)
==
"table"
then
if
dumped
[
o
]
then
return
"<circular reference>"
end
dumped
[
o
]
=
true
local
t
=
{}
for
k
,
v
in
pairs
(
o
)
do
t
[
#
t
+
1
]
=
""
..
k
..
" = "
..
dump
(
v
,
dumped
)
end
return
"{"
..
table.concat
(
t
,
", "
)
..
"}"
elseif
type
(
o
)
==
"boolean"
then
return
tostring
(
o
)
elseif
type
(
o
)
==
"function"
then
return
"<function>"
elseif
type
(
o
)
==
"userdata"
then
return
"<userdata>"
elseif
type
(
o
)
==
"nil"
then
return
"nil"
else
error
(
"cannot dump a "
..
type
(
o
))
return
nil
end
end
--------------------------------------------------------------------------------
function
string
:
split
(
sep
)
local
sep
,
fields
=
sep
or
","
,
{}
local
pattern
=
string.format
(
"([^%s]+)"
,
sep
)
self
:
gsub
(
pattern
,
function
(
c
)
fields
[
#
fields
+
1
]
=
c
end
)
return
fields
end
--------------------------------------------------------------------------------
function
string
:
trim
()
return
(
self
:
gsub
(
"^%s*
(
.-
)
%s*$"
,
"%1"
))
end
--------------------------------------------------------------------------------
engine
.
get_game
=
function
(
index
)
local
games
=
game
.
get_games
()
if
index
>
0
and
index
<=
#
games
then
return
games
[
index
]
end
return
nil
end
--------------------------------------------------------------------------------
function
fs_escape_string
(
text
)
if
text
~=
nil
then
while
(
text
:
find
(
"
\r\n
"
)
~=
nil
)
do
local
newtext
=
text
:
sub
(
1
,
text
:
find
(
"
\r\n
"
)
-
1
)
newtext
=
newtext
..
" "
..
text
:
sub
(
text
:
find
(
"
\r\n
"
)
+
3
)
text
=
newtext
end
while
(
text
:
find
(
"
\n
"
)
~=
nil
)
do
local
newtext
=
text
:
sub
(
1
,
text
:
find
(
"
\n
"
)
-
1
)
newtext
=
newtext
..
" "
..
text
:
sub
(
text
:
find
(
"
\n
"
)
+
1
)
text
=
newtext
end
while
(
text
:
find
(
"
\r
"
)
~=
nil
)
do
local
newtext
=
text
:
sub
(
1
,
text
:
find
(
"
\r
"
)
-
1
)
newtext
=
newtext
..
" "
..
text
:
sub
(
text
:
find
(
"
\r
"
)
+
1
)
text
=
newtext
end
text
=
string.gsub
(
text
,
"
\\
"
,
"
\\\\
"
)
text
=
string.gsub
(
text
,
"%]"
,
"
\\
]"
)
text
=
string.gsub
(
text
,
"%["
,
"
\\
["
)
text
=
string.gsub
(
text
,
";"
,
"
\\
;"
)
text
=
string.gsub
(
text
,
","
,
"
\\
,"
)
end
return
text
end
--------------------------------------------------------------------------------
function
explode_textlist_event
(
text
)
local
retval
=
{}
retval
.
typ
=
"INV"
local
parts
=
text
:
split
(
":"
)
if
#
parts
==
2
then
retval
.
typ
=
parts
[
1
]:
trim
()
retval
.
index
=
tonumber
(
parts
[
2
]:
trim
())
if
type
(
retval
.
index
)
~=
"number"
then
retval
.
typ
=
"INV"
end
end
return
retval
end
--------------------------------------------------------------------------------
function
get_last_folder
(
text
,
count
)
local
parts
=
text
:
split
(
DIR_DELIM
)
if
count
==
nil
then
return
parts
[
#
parts
]
end
local
retval
=
""
for
i
=
1
,
count
,
1
do
retval
=
retval
..
parts
[
#
parts
-
(
count
-
i
)]
..
DIR_DELIM
end
return
retval
end
--------------------------------------------------------------------------------
function
cleanup_path
(
temppath
)
local
parts
=
temppath
:
split
(
"-"
)
temppath
=
""
for
i
=
1
,
#
parts
,
1
do
if
temppath
~=
""
then
temppath
=
temppath
..
"_"
end
temppath
=
temppath
..
parts
[
i
]
end
parts
=
temppath
:
split
(
"."
)
temppath
=
""
for
i
=
1
,
#
parts
,
1
do
if
temppath
~=
""
then
temppath
=
temppath
..
"_"
end
temppath
=
temppath
..
parts
[
i
]
end
parts
=
temppath
:
split
(
"'"
)
temppath
=
""
for
i
=
1
,
#
parts
,
1
do
if
temppath
~=
""
then
temppath
=
temppath
..
""
end
temppath
=
temppath
..
parts
[
i
]
end
parts
=
temppath
:
split
(
" "
)
temppath
=
""
for
i
=
1
,
#
parts
,
1
do
if
temppath
~=
""
then
temppath
=
temppath
end
temppath
=
temppath
..
parts
[
i
]
end
return
temppath
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
builtin/misc_helpers.lua
+
142
−
3
View file @
32001d1e
-- Minetest: builtin/misc_helpers.lua
--------------------------------------------------------------------------------
function
basic_dump2
(
o
)
if
type
(
o
)
==
"number"
then
return
tostring
(
o
)
...
...
@@ -19,6 +20,7 @@ function basic_dump2(o)
end
end
--------------------------------------------------------------------------------
function
dump2
(
o
,
name
,
dumped
)
name
=
name
or
"_"
dumped
=
dumped
or
{}
...
...
@@ -44,6 +46,7 @@ function dump2(o, name, dumped)
end
end
--------------------------------------------------------------------------------
function
dump
(
o
,
dumped
)
dumped
=
dumped
or
{}
if
type
(
o
)
==
"number"
then
...
...
@@ -74,6 +77,7 @@ function dump(o, dumped)
end
end
--------------------------------------------------------------------------------
function
string
:
split
(
sep
)
local
sep
,
fields
=
sep
or
","
,
{}
local
pattern
=
string.format
(
"([^%s]+)"
,
sep
)
...
...
@@ -81,16 +85,16 @@ function string:split(sep)
return
fields
end
--------------------------------------------------------------------------------
function
string
:
trim
()
return
(
self
:
gsub
(
"^%s*
(
.-
)
%s*$"
,
"%1"
))
end
assert
(
string
.
trim
(
"
\n
\t\tfoo bar\t "
)
==
"foo bar"
)
function
minetest
.
pos_to_string
(
pos
)
return
"("
..
pos
.
x
..
","
..
pos
.
y
..
","
..
pos
.
z
..
")"
end
--------------------------------------------------------------------------------
function
math
.
hypot
(
x
,
y
)
local
t
x
=
math.abs
(
x
)
...
...
@@ -102,3 +106,138 @@ function math.hypot(x, y)
return
x
*
math.sqrt
(
1
+
t
*
t
)
end
--------------------------------------------------------------------------------
function
explode_textlist_event
(
text
)
local
retval
=
{}
retval
.
typ
=
"INV"
local
parts
=
text
:
split
(
":"
)
if
#
parts
==
2
then
retval
.
typ
=
parts
[
1
]:
trim
()
retval
.
index
=
tonumber
(
parts
[
2
]:
trim
())
if
type
(
retval
.
index
)
~=
"number"
then
retval
.
typ
=
"INV"
end
end
return
retval
end
--------------------------------------------------------------------------------
function
get_last_folder
(
text
,
count
)
local
parts
=
text
:
split
(
DIR_DELIM
)
if
count
==
nil
then
return
parts
[
#
parts
]
end
local
retval
=
""
for
i
=
1
,
count
,
1
do
retval
=
retval
..
parts
[
#
parts
-
(
count
-
i
)]
..
DIR_DELIM
end
return
retval
end
--------------------------------------------------------------------------------
function
cleanup_path
(
temppath
)
local
parts
=
temppath
:
split
(
"-"
)
temppath
=
""
for
i
=
1
,
#
parts
,
1
do
if
temppath
~=
""
then
temppath
=
temppath
..
"_"
end
temppath
=
temppath
..
parts
[
i
]
end
parts
=
temppath
:
split
(
"."
)
temppath
=
""
for
i
=
1
,
#
parts
,
1
do
if
temppath
~=
""
then
temppath
=
temppath
..
"_"
end
temppath
=
temppath
..
parts
[
i
]
end
parts
=
temppath
:
split
(
"'"
)
temppath
=
""
for
i
=
1
,
#
parts
,
1
do
if
temppath
~=
""
then
temppath
=
temppath
..
""
end
temppath
=
temppath
..
parts
[
i
]
end
parts
=
temppath
:
split
(
" "
)
temppath
=
""
for
i
=
1
,
#
parts
,
1
do
if
temppath
~=
""
then
temppath
=
temppath
end
temppath
=
temppath
..
parts
[
i
]
end
return
temppath
end
--------------------------------------------------------------------------------
-- mainmenu only functions
--------------------------------------------------------------------------------
if
engine
~=
nil
then
engine
.
get_game
=
function
(
index
)
local
games
=
game
.
get_games
()
if
index
>
0
and
index
<=
#
games
then
return
games
[
index
]
end
return
nil
end
--------------------------------------------------------------------------------
function
fs_escape_string
(
text
)
if
text
~=
nil
then
while
(
text
:
find
(
"
\r\n
"
)
~=
nil
)
do
local
newtext
=
text
:
sub
(
1
,
text
:
find
(
"
\r\n
"
)
-
1
)
newtext
=
newtext
..
" "
..
text
:
sub
(
text
:
find
(
"
\r\n
"
)
+
3
)
text
=
newtext
end
while
(
text
:
find
(
"
\n
"
)
~=
nil
)
do
local
newtext
=
text
:
sub
(
1
,
text
:
find
(
"
\n
"
)
-
1
)
newtext
=
newtext
..
" "
..
text
:
sub
(
text
:
find
(
"
\n
"
)
+
1
)
text
=
newtext
end
while
(
text
:
find
(
"
\r
"
)
~=
nil
)
do
local
newtext
=
text
:
sub
(
1
,
text
:
find
(
"
\r
"
)
-
1
)
newtext
=
newtext
..
" "
..
text
:
sub
(
text
:
find
(
"
\r
"
)
+
1
)
text
=
newtext
end
text
=
string.gsub
(
text
,
"
\\
"
,
"
\\\\
"
)
text
=
string.gsub
(
text
,
"%]"
,
"
\\
]"
)
text
=
string.gsub
(
text
,
"%["
,
"
\\
["
)
text
=
string.gsub
(
text
,
";"
,
"
\\
;"
)
text
=
string.gsub
(
text
,
","
,
"
\\
,"
)
end
return
text
end
end
--------------------------------------------------------------------------------
-- core only fct
--------------------------------------------------------------------------------
if
minetest
~=
nil
then
--------------------------------------------------------------------------------
function
minetest
.
pos_to_string
(
pos
)
return
"("
..
pos
.
x
..
","
..
pos
.
y
..
","
..
pos
.
z
..
")"
end
end
This diff is collapsed.
Click to expand it.
src/guiEngine.cpp
+
1
−
1
View file @
32001d1e
...
...
@@ -151,7 +151,7 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev,
std
::
string
builtin_helpers
=
porting
::
path_share
+
DIR_DELIM
+
"builtin"
+
DIR_DELIM
+
"m
ainmenu
_helper.lua"
;
+
DIR_DELIM
+
"m
isc
_helper
s
.lua"
;
if
(
!
runScript
(
builtin_helpers
))
{
errorstream
...
...
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