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
73bb3bc5
Commit
73bb3bc5
authored
13 years ago
by
Perttu Ahola
Browse files
Options
Downloads
Patches
Plain Diff
Scripting WIP: Add global environment step function on_step
parent
1320d070
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
data/scripts/default.lua
+4
-1
4 additions, 1 deletion
data/scripts/default.lua
src/environment.cpp
+5
-0
5 additions, 0 deletions
src/environment.cpp
src/scriptapi.cpp
+22
-1
22 additions, 1 deletion
src/scriptapi.cpp
src/scriptapi.h
+4
-0
4 additions, 0 deletions
src/scriptapi.h
with
35 additions
and
2 deletions
data/scripts/default.lua
+
4
−
1
View file @
73bb3bc5
...
@@ -138,7 +138,10 @@ end
...
@@ -138,7 +138,10 @@ end
print
(
"omg lol"
)
print
(
"omg lol"
)
print
(
"minetest dump: "
..
dump
(
minetest
))
print
(
"minetest dump: "
..
dump
(
minetest
))
--local TNT = minetest.new_entity {
-- Global environment step function
function
on_step
(
dtime
)
end
local
TNT
=
{
local
TNT
=
{
-- Maybe handle gravity and collision this way? dunno
-- Maybe handle gravity and collision this way? dunno
physical
=
true
,
physical
=
true
,
...
...
This diff is collapsed.
Click to expand it.
src/environment.cpp
+
5
−
0
View file @
73bb3bc5
...
@@ -1141,6 +1141,11 @@ void ServerEnvironment::step(float dtime)
...
@@ -1141,6 +1141,11 @@ void ServerEnvironment::step(float dtime)
}
}
}
}
/*
Step script environment (run global on_step())
*/
scriptapi_environment_step
(
m_lua
,
dtime
);
/*
/*
Step active objects
Step active objects
*/
*/
...
...
This diff is collapsed.
Click to expand it.
src/scriptapi.cpp
+
22
−
1
View file @
73bb3bc5
...
@@ -40,7 +40,9 @@ extern "C" {
...
@@ -40,7 +40,9 @@ extern "C" {
TODO:
TODO:
- Global environment step function
- Global environment step function
- Random node triggers
- Random node triggers
- Object network and client-side stuff
- Object visual client-side stuff
- Blink effect
- Spritesheets and animation
- Named node types and dynamic id allocation
- Named node types and dynamic id allocation
- LuaNodeMetadata
- LuaNodeMetadata
blockdef.has_metadata = true/false
blockdef.has_metadata = true/false
...
@@ -669,6 +671,25 @@ void scriptapi_rm_object_reference(lua_State *L, ServerActiveObject *cobj)
...
@@ -669,6 +671,25 @@ void scriptapi_rm_object_reference(lua_State *L, ServerActiveObject *cobj)
lua_settable
(
L
,
objectstable
);
lua_settable
(
L
,
objectstable
);
}
}
/*
environment
*/
void
scriptapi_environment_step
(
lua_State
*
L
,
float
dtime
)
{
realitycheck
(
L
);
assert
(
lua_checkstack
(
L
,
20
));
//infostream<<"scriptapi_luaentity_step: id="<<id<<std::endl;
StackUnroller
stack_unroller
(
L
);
lua_getglobal
(
L
,
"on_step"
);
if
(
lua_type
(
L
,
-
1
)
!=
LUA_TFUNCTION
)
return
;
// If no on_step function exist, do nothing
lua_pushnumber
(
L
,
dtime
);
if
(
lua_pcall
(
L
,
1
,
0
,
0
))
script_error
(
L
,
"error: %s
\n
"
,
lua_tostring
(
L
,
-
1
));
}
/*
/*
luaentity
luaentity
*/
*/
...
...
This diff is collapsed.
Click to expand it.
src/scriptapi.h
+
4
−
0
View file @
73bb3bc5
...
@@ -35,6 +35,10 @@ void scriptapi_add_environment(lua_State *L, ServerEnvironment *env);
...
@@ -35,6 +35,10 @@ void scriptapi_add_environment(lua_State *L, ServerEnvironment *env);
void
scriptapi_add_object_reference
(
lua_State
*
L
,
ServerActiveObject
*
cobj
);
void
scriptapi_add_object_reference
(
lua_State
*
L
,
ServerActiveObject
*
cobj
);
void
scriptapi_rm_object_reference
(
lua_State
*
L
,
ServerActiveObject
*
cobj
);
void
scriptapi_rm_object_reference
(
lua_State
*
L
,
ServerActiveObject
*
cobj
);
/* environment */
void
scriptapi_environment_step
(
lua_State
*
L
,
float
dtime
);
/* luaentity */
void
scriptapi_luaentity_add
(
lua_State
*
L
,
u16
id
,
const
char
*
name
,
void
scriptapi_luaentity_add
(
lua_State
*
L
,
u16
id
,
const
char
*
name
,
const
char
*
init_state
);
const
char
*
init_state
);
void
scriptapi_luaentity_rm
(
lua_State
*
L
,
u16
id
);
void
scriptapi_luaentity_rm
(
lua_State
*
L
,
u16
id
);
...
...
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