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
270a4827
Commit
270a4827
authored
13 years ago
by
Perttu Ahola
Browse files
Options
Downloads
Patches
Plain Diff
Add InvRef:get_list() and InvRef:set_list() and fix some things (untested)
parent
e0b48907
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/scriptapi.cpp
+32
-0
32 additions, 0 deletions
src/scriptapi.cpp
with
32 additions
and
0 deletions
src/scriptapi.cpp
+
32
−
0
View file @
270a4827
...
...
@@ -1042,6 +1042,7 @@ class InvRef
Inventory
*
inv
=
getinv
(
L
,
ref
);
if
(
newsize
==
0
){
inv
->
deleteList
(
listname
);
reportInventoryChange
(
L
,
ref
);
return
0
;
}
InventoryList
*
list
=
inv
->
getList
(
listname
);
...
...
@@ -1050,6 +1051,7 @@ class InvRef
}
else
{
list
=
inv
->
addList
(
listname
,
newsize
);
}
reportInventoryChange
(
L
,
ref
);
return
0
;
}
...
...
@@ -1085,9 +1087,37 @@ class InvRef
bool
success
=
(
olditem
!=
newitem
);
delete
olditem
;
lua_pushboolean
(
L
,
success
);
reportInventoryChange
(
L
,
ref
);
return
1
;
}
// get_list(self, listname) -> list or nil
static
int
l_get_list
(
lua_State
*
L
)
{
InvRef
*
ref
=
checkobject
(
L
,
1
);
const
char
*
listname
=
luaL_checkstring
(
L
,
2
);
Inventory
*
inv
=
getinv
(
L
,
ref
);
inventory_get_list_to_lua
(
inv
,
listname
,
L
);
return
1
;
}
// set_list(self, listname, list)
static
int
l_set_list
(
lua_State
*
L
)
{
InvRef
*
ref
=
checkobject
(
L
,
1
);
const
char
*
listname
=
luaL_checkstring
(
L
,
2
);
Inventory
*
inv
=
getinv
(
L
,
ref
);
InventoryList
*
list
=
inv
->
getList
(
listname
);
if
(
list
)
inventory_set_list_from_lua
(
inv
,
listname
,
L
,
3
,
get_server
(
L
),
list
->
getSize
());
else
inventory_set_list_from_lua
(
inv
,
listname
,
L
,
3
,
get_server
(
L
));
reportInventoryChange
(
L
,
ref
);
return
0
;
}
public
:
InvRef
(
const
InventoryLocation
&
loc
)
:
m_loc
(
loc
)
...
...
@@ -1154,6 +1184,8 @@ const luaL_reg InvRef::methods[] = {
method
(
InvRef
,
set_size
),
method
(
InvRef
,
get_stack
),
method
(
InvRef
,
set_stack
),
method
(
InvRef
,
get_list
),
method
(
InvRef
,
set_list
),
{
0
,
0
}
};
...
...
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