diff options
Diffstat (limited to 'advtrains')
-rw-r--r-- | advtrains/api_doc.txt | 4 | ||||
-rw-r--r-- | advtrains/wagons.lua | 12 |
2 files changed, 10 insertions, 6 deletions
diff --git a/advtrains/api_doc.txt b/advtrains/api_doc.txt index d16a611..4413dce 100644 --- a/advtrains/api_doc.txt +++ b/advtrains/api_doc.txt @@ -98,11 +98,11 @@ advtrains.register_wagon(name, prototype, description, inventory_image) }, ^- List of assignments of type list_name=size. ^- For every entry, an inventory list is created with the specified size. - get_inventory_formspec = function(self, player_name) + get_inventory_formspec = function(self, player_name, inventory_name) return "<a formspec>" end, ^- Function that should return the formspec to be displayed when <player> requests to open the wagon's inventory - ^- Use "list[detached:advtrains_wgn_"..self.id..";<list_name>;<X>,<Y>;<W>,<H>;<Start>]" to display a wagon's inventory list. + ^- Use "list["..inventory_name..";<list_name>;<X>,<Y>;<W>,<H>;<Start>]" to display a wagon's inventory list. custom_on_step = function(self, dtime) end ^- optional: Execute custom code on every step diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua index 040400c..986cbac 100644 --- a/advtrains/wagons.lua +++ b/advtrains/wagons.lua @@ -28,6 +28,10 @@ function advtrains.create_wagon(wtype, owner) return new_id
end
+local function make_inv_name(self)
+ return "detached:advtrains_wgn_"..self.id
+end
+
local wagon={
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
@@ -576,7 +580,7 @@ function wagon:on_rightclick(clicker) if self.seat_groups then
if #self.seats==0 then
if self.has_inventory and self.get_inventory_formspec and advtrains.check_driving_couple_protection(pname, data.owner, data.whitelist) then
- minetest.show_formspec(pname, "advtrains_inv_"..self.id, self:get_inventory_formspec(pname))
+ minetest.show_formspec(pname, "advtrains_inv_"..self.id, self:get_inventory_formspec(pname, make_inv_name(self)))
end
return
end
@@ -710,7 +714,7 @@ function wagon:show_get_on_form(pname) local data = advtrains.wagons[self.id]
if #self.seats==0 then
if self.has_inventory and self.get_inventory_formspec and advtrains.check_driving_couple_protection(pname, data.owner, data.whitelist) then
- minetest.show_formspec(pname, "advtrains_inv_"..self.id, self:get_inventory_formspec(pname))
+ minetest.show_formspec(pname, "advtrains_inv_"..self.id, self:get_inventory_formspec(pname, make_inv_name(self)))
end
return
end
@@ -908,7 +912,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) local data = advtrains.wagons[wagon.id]
if fields.inv then
if wagon.has_inventory and wagon.get_inventory_formspec then
- minetest.show_formspec(player:get_player_name(), "advtrains_inv_"..uid, wagon:get_inventory_formspec(player:get_player_name()))
+ minetest.show_formspec(player:get_player_name(), "advtrains_inv_"..uid, wagon:get_inventory_formspec(player:get_player_name(), make_inv_name(self)))
end
elseif fields.seat then
local val=minetest.explode_textlist_event(fields.seat)
@@ -973,7 +977,7 @@ function wagon:seating_from_key_helper(pname, fields, no) end
end
if fields.inv and self.has_inventory and self.get_inventory_formspec then
- minetest.show_formspec(player:get_player_name(), "advtrains_inv_"..self.id, self:get_inventory_formspec(player:get_player_name()))
+ minetest.show_formspec(player:get_player_name(), "advtrains_inv_"..self.id, self:get_inventory_formspec(player:get_player_name(), make_inv_name(self)))
end
if fields.prop and data.owner==pname then
self:show_wagon_properties(pname)
|