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
769b2d7c
Commit
769b2d7c
authored
11 years ago
by
kwolekr
Browse files
Options
Downloads
Patches
Plain Diff
LuaVoxelManip: Add get_light_data() and set_light_data()
parent
5be786c8
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
doc/lua_api.txt
+7
-0
7 additions, 0 deletions
doc/lua_api.txt
src/script/lua_api/l_vmanip.cpp
+44
-0
44 additions, 0 deletions
src/script/lua_api/l_vmanip.cpp
src/script/lua_api/l_vmanip.h
+3
-0
3 additions, 0 deletions
src/script/lua_api/l_vmanip.h
with
54 additions
and
0 deletions
doc/lua_api.txt
+
7
−
0
View file @
769b2d7c
...
@@ -1818,6 +1818,13 @@ methods:
...
@@ -1818,6 +1818,13 @@ methods:
- set_lighting(light): Set the lighting within the VoxelManip
- set_lighting(light): Set the lighting within the VoxelManip
^ light is a table, {day=<0...15>, night=<0...15>}
^ light is a table, {day=<0...15>, night=<0...15>}
^ To be used only by a VoxelManip object from minetest.get_mapgen_object
^ To be used only by a VoxelManip object from minetest.get_mapgen_object
- get_light_data(): Gets the light data read into the VoxelManip object
^ Returns an array (indicies 1 to volume) of integers ranging from 0 to 255
^ Each value is the bitwise combination of day and night light values (0..15 each)
^ light = day + (night * 16)
- set_light_data(light_data): Sets the param1 (light) contents of each node in the VoxelManip
^ expects lighting data in the same format that get_light_data() returns
- calc_lighting(): Calculate lighting within the VoxelManip
- calc_lighting(): Calculate lighting within the VoxelManip
^ To be used only by a VoxelManip object from minetest.get_mapgen_object
^ To be used only by a VoxelManip object from minetest.get_mapgen_object
- update_liquids(): Update liquid flow
- update_liquids(): Update liquid flow
...
...
This diff is collapsed.
Click to expand it.
src/script/lua_api/l_vmanip.cpp
+
44
−
0
View file @
769b2d7c
...
@@ -178,6 +178,48 @@ int LuaVoxelManip::l_set_lighting(lua_State *L)
...
@@ -178,6 +178,48 @@ int LuaVoxelManip::l_set_lighting(lua_State *L)
return
0
;
return
0
;
}
}
int
LuaVoxelManip
::
l_get_light_data
(
lua_State
*
L
)
{
NO_MAP_LOCK_REQUIRED
;
LuaVoxelManip
*
o
=
checkobject
(
L
,
1
);
ManualMapVoxelManipulator
*
vm
=
o
->
vm
;
int
volume
=
vm
->
m_area
.
getVolume
();
lua_newtable
(
L
);
for
(
int
i
=
0
;
i
!=
volume
;
i
++
)
{
lua_Integer
light
=
vm
->
m_data
[
i
].
param1
;
lua_pushinteger
(
L
,
light
);
lua_rawseti
(
L
,
-
2
,
i
+
1
);
}
return
1
;
}
int
LuaVoxelManip
::
l_set_light_data
(
lua_State
*
L
)
{
NO_MAP_LOCK_REQUIRED
;
LuaVoxelManip
*
o
=
checkobject
(
L
,
1
);
ManualMapVoxelManipulator
*
vm
=
o
->
vm
;
if
(
!
lua_istable
(
L
,
2
))
return
0
;
int
volume
=
vm
->
m_area
.
getVolume
();
for
(
int
i
=
0
;
i
!=
volume
;
i
++
)
{
lua_rawgeti
(
L
,
2
,
i
+
1
);
u8
light
=
lua_tointeger
(
L
,
-
1
);
vm
->
m_data
[
i
].
param1
=
light
;
lua_pop
(
L
,
1
);
}
return
0
;
}
int
LuaVoxelManip
::
l_update_map
(
lua_State
*
L
)
int
LuaVoxelManip
::
l_update_map
(
lua_State
*
L
)
{
{
LuaVoxelManip
*
o
=
checkobject
(
L
,
1
);
LuaVoxelManip
*
o
=
checkobject
(
L
,
1
);
...
@@ -299,5 +341,7 @@ const luaL_reg LuaVoxelManip::methods[] = {
...
@@ -299,5 +341,7 @@ const luaL_reg LuaVoxelManip::methods[] = {
luamethod
(
LuaVoxelManip
,
update_liquids
),
luamethod
(
LuaVoxelManip
,
update_liquids
),
luamethod
(
LuaVoxelManip
,
calc_lighting
),
luamethod
(
LuaVoxelManip
,
calc_lighting
),
luamethod
(
LuaVoxelManip
,
set_lighting
),
luamethod
(
LuaVoxelManip
,
set_lighting
),
luamethod
(
LuaVoxelManip
,
get_light_data
),
luamethod
(
LuaVoxelManip
,
set_light_data
),
{
0
,
0
}
{
0
,
0
}
};
};
This diff is collapsed.
Click to expand it.
src/script/lua_api/l_vmanip.h
+
3
−
0
View file @
769b2d7c
...
@@ -49,8 +49,11 @@ class LuaVoxelManip : public ModApiBase {
...
@@ -49,8 +49,11 @@ class LuaVoxelManip : public ModApiBase {
static
int
l_update_map
(
lua_State
*
L
);
static
int
l_update_map
(
lua_State
*
L
);
static
int
l_update_liquids
(
lua_State
*
L
);
static
int
l_update_liquids
(
lua_State
*
L
);
static
int
l_calc_lighting
(
lua_State
*
L
);
static
int
l_calc_lighting
(
lua_State
*
L
);
static
int
l_set_lighting
(
lua_State
*
L
);
static
int
l_set_lighting
(
lua_State
*
L
);
static
int
l_get_light_data
(
lua_State
*
L
);
static
int
l_set_light_data
(
lua_State
*
L
);
public:
public:
LuaVoxelManip
(
ManualMapVoxelManipulator
*
mmvm
,
bool
is_mapgen_vm
);
LuaVoxelManip
(
ManualMapVoxelManipulator
*
mmvm
,
bool
is_mapgen_vm
);
...
...
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