Jump to content

Not-Walkable box


Animal

Recommended Posts

Hey there I am trying to make a new box with different capacity(a bigger one), and for now I am able to use option "place on floor" - My problem is that i can walk through them and that they not glue to exact square(randomly moves a little like a dropped item)

The problem looks like in screenshot

 

I got file structure like this:

 
│   mod.info
│   poster.png
│
└───media
    ├───lua
    │   └───server
    │       └───BuildingObjects
    │               ISSneakyBox.lua
    │
    ├───models_X
    │       SneakyBOX.FBX
    │
    ├───scripts
    │       SneakyBOX.txt
    │
    └───textures
            item_SneakyBOX.png

 

 

scripts/SneakyBOX.txt

 
module Sneaky
{
    imports
    {
        Base
    }
    
       recipe Make SneakyBOX
    {
        SheetMetal = 4,
        Screws = 5,
        keep Crowbar,
        keep Hammer,
        keep Screwdriver,
           Result:SneakyBOX,
        Category:Container,
        Sound:PZ_Hammer,
        SkillRequired:Woodwork=6,
        CanBeDoneFromFloor:true,
        Time:500.0,
    }
    
    item SneakyBOX
    {
        DisplayCategory = Container,
        WeightReduction = 95,
        Weight = 5,
        Type = Container,
        Capacity = 2000,
        DisplayName = SneakyBOX,
        Icon = SneakyBOX,
        WorldStaticModel = Sneaky.SneakyBOXmodel,
    }
    
    model SneakyBOXmodel
    {
        mesh = SneakyBOX,
        texture = SneakyBOX,
    }
    
}

 

 

and lua file ISSneakyBox.lua which is test copy of ProjectZomboid\media\lua\server\BuildingObjects\ISWoodenContainer

 

 
--***********************************************************
--**                    ROBERT JOHNSON                     **
--***********************************************************

ISSneakyBox = ISBuildingObject:derive("ISWoodenContainer");

--************************************************************************--
--** ISSneakyBox:new
--**
--************************************************************************--
function ISSneakyBox:create(x, y, z, north, sprite)
    local cell = getWorld():getCell();
    self.sq = cell:getGridSquare(x, y, z);
    self.javaObject = IsoThumpable.new(cell, self.sq, sprite, north, self);
    buildUtil.setInfo(self.javaObject, self);
    buildUtil.consumeMaterial(self);
    -- the wooden wall have 200 base health + 100 per carpentry lvl
    self.javaObject:setMaxHealth(self:getHealth());
    self.javaObject:setHealth(self.javaObject:getMaxHealth());
    -- the sound that will be played when our door frame will be broken
    self.javaObject:setBreakSound("BreakObject");

    local sharedSprite = getSprite(self:getSprite())
    if self.sq and sharedSprite and sharedSprite:getProperties():Is("IsStackable") then
        local props = ISMoveableSpriteProps.new(sharedSprite)
        self.javaObject:setRenderYOffset(props:getTotalTableHeight(self.sq))
    end

    -- add the item to the ground
    self.sq:AddSpecialObject(self.javaObject);
    self.javaObject:transmitCompleteItemToServer();
end

function ISSneakyBox:new(sprite, northSprite)
    local o = {};
    setmetatable(o, self);
    self.__index = self;
    o:init();
    o:setSprite(sprite);
    o:setNorthSprite(northSprite);
    o.isContainer = true;
    o.blockAllTheSquare = true;
    o.name = "Sneaky Box";
    o.dismantable = true;
    o.canBeAlwaysPlaced = true;
    o.canBeLockedByPadlock = true;
    o.buildLow = true;
    return o;
end

-- return the health of the new container, it's 200 + 100 per carpentry lvl
function ISSneakyBox:getHealth()
    return 200 + buildUtil.getWoodHealth(self);
end

function ISSneakyBox:isValid(square)
    if buildUtil.stairIsBlockingPlacement( square, true ) then return false; end
    if not self:haveMaterial(square) then return false end
    local sharedSprite = getSprite(self:getSprite())
    if square and sharedSprite and sharedSprite:getProperties():Is("IsStackable") then
        local props = ISMoveableSpriteProps.new(sharedSprite)
        return props:canPlaceMoveable("bogus", square, nil)
    end
    return ISBuildingObject.isValid(self, square);
end

function ISSneakyBox:render(x, y, z, square)
    ISBuildingObject.render(self, x, y, z, square)
end

 

Did i miss something? - Please any advice or help I am stuck on this.

 

box.png

Edited by Animal
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...