Maris Posted February 24, 2020 Share Posted February 24, 2020 How to find out the world coordinates of the rear left window? Now it seems that world coordinates (getX, getY) of all parts are the same. ATPHHe 1 Link to comment Share on other sites More sharing options...
ATPHHe Posted March 5, 2020 Share Posted March 5, 2020 (edited) I took a look into the code. Seems that getX() and getY() for VehicleParts seem to only return the vehicle's X and Y positions now. I looked around for another function and found two of them that might be helpful: getArea(), getAreaCenter(). local part = vehicle:getPartById("GasTank") local areaCenter = vehicle:getAreaCenter(part:getArea()) local square = getCell():getGridSquare(areaCenter:getX(), areaCenter:getY(), vehicle:getZ()) local areaCenter = vehicle:getAreaCenter( part:getArea() ) areaCenter:getX() areaCenter:getY() I found this code in one of Project Zomboid's files, which uses the location of the "GasTank" to find the nearest Fuel Pump. The file's name is "ISVehiclePartMenu.lua" "..\steamapps\common\ProjectZomboid\media\lua\client\Vehicles\ISUI\ISVehiclePartMenu.lua" function ISVehiclePartMenu.getNearbyFuelPump(vehicle) local part = vehicle:getPartById("GasTank") if not part then return nil end local areaCenter = vehicle:getAreaCenter(part:getArea()) if not areaCenter then return nil end local square = getCell():getGridSquare(areaCenter:getX(), areaCenter:getY(), vehicle:getZ()) if not square then return nil end for dy=-2,2 do for dx=-2,2 do -- TODO: check line-of-sight between 2 squares local square2 = getCell():getGridSquare(square:getX() + dx, square:getY() + dy, square:getZ()) if square2 and square2:getProperties():Is("fuelAmount") and tonumber(square2:getProperties():Val("fuelAmount")) > 0 then return square2 end end end end Edited March 18, 2020 by ATPHHe Maris 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now