diff --git a/entity/turtle.lua b/entity/turtle.lua index 16948fd..4e6f370 100644 --- a/entity/turtle.lua +++ b/entity/turtle.lua @@ -206,10 +206,10 @@ function TurtleEntity:build(nodeLocation, turtleslot) if node.name~="air" then return false end --Build and consume item - local stack = self:getTurtleslot("main", turtleslot) + local stack = self:getTurtleslot(turtleslot) if stack:is_empty() then return false end - local newstack, position_placed = minetest.item_place_node(stack, nil, { type="node", under=nodeLocation, above=self:get_pos()}) - self.inv:set_stack("main", turtleslot,newstack) + local newstack, position_placed = minetest.item_place_node(stack, nil, { type="node", under=nodeLocation, above=self.object:get_pos()}) + self.inv:set_stack("main", turtleslot, newstack) if position_placed == nil then self:yield("Building") @@ -363,8 +363,13 @@ function TurtleEntity:on_activate(staticdata, dtime_s) local data = minetest.deserialize(staticdata) if type(data) ~= "table" or not data.complete then data = {} end --Give ID - computertest.num_turtles = computertest.num_turtles+1 - self.id = computertest.num_turtles + if data.id then + self.id = data.id + else + computertest.num_turtles = computertest.num_turtles+1 + self.id = computertest.num_turtles + end + self.name = data.name or "Unnamed #"..self.id --self.owner = minetest.get_meta(pos):get_string("owner") self.heading = data.heading or 0