Coder Social home page Coder Social logo

[not an issue] help about polyzone HOT 6 CLOSED

mkafrin avatar mkafrin commented on June 15, 2024
[not an issue] help

from polyzone.

Comments (6)

Maxamax1 avatar Maxamax1 commented on June 15, 2024 1

thanks

from polyzone.

mkafrin avatar mkafrin commented on June 15, 2024

Well EntityZones already have offset and scale options, since it inherits from BoxZone (BoxZone options), but honestly if you're using qtarget anyways, why not just target the object or model? Feel like creating a polyzone to target is just an extra step and will be less accurate as well compared to targeting the object or model directly.

from polyzone.

Maxamax1 avatar Maxamax1 commented on June 15, 2024

well qtarget relies on PolyZone
test1 = GetClosestObjectOfType(482.2, -999.4, 30.8, 1.0, 165994623, false, false, false)
iam getting the HashID from the door and with

exports.qtarget:AddEntityZone("test", test1, {
		debugPoly=true,
		useZ = true
		}, {
	options = {
		{
			icon = 'fas fa-shopping-basket',
			
			label = "test",
			action = function()
		
			end
		},
	},distance = 2.5
})

i add a zone to the entity (it moves when i open the door) so iam telling qtarget to add a zone.

local function AddEntityZone(name, entity, options, targetoptions)
	Zones[name] = EntityZone:Create(entity, options)
	Zones[name].targetoptions = targetoptions
end
exports('AddEntityZone', AddEntityZone)

is from qtarget and tells PolyZone to create a EntityZone

function EntityZone:Create(entity, options)
  local zone = EntityZone:new(entity, options)
  _initDebug(zone, options)
  return zone
end

then

function EntityZone:new(entity, options)
  assert(DoesEntityExist(entity), "Entity does not exist")

  local min, max = GetModelDimensions(GetEntityModel(entity))
  local dimensions = {min, max}

  local length = max.y - min.y
  local width = max.x - min.x
  local pos = GetEntityCoords(entity)

  local zone = BoxZone:new(pos, length, width, options)
  if options.useZ == true then
    options.minZ, options.maxZ = _calculateMinAndMaxZ(entity, dimensions, zone.scaleZ, zone.offsetZ, pos)
  else
    options.minZ = nil
    options.maxZ = nil
  end
  zone.entity = entity
  zone.dimensions = dimensions
  zone.useZ = options.useZ
  zone.damageEventHandlers = {}
  zone.isEntityZone = true
  setmetatable(zone, self)
  self.__index = self
  return zone
end

so in the code above line with "local pos = GetEntityCoords(entity)" i think there should the offset happen

from polyzone.

mkafrin avatar mkafrin commented on June 15, 2024

I'm pretty sure qtarget only relies on PolyZone if you are registering BoxZone, CircleZone, or EntityZone targets. You can also use it with entities and models, seen in the docs here:

https://overextended.github.io/qtarget/entity
https://overextended.github.io/qtarget/model

These seem like they'd work better for your use case. But regardless of whether you use them, as I already said, EntityZones and BoxZones already support offset and scale options.

from polyzone.

Maxamax1 avatar Maxamax1 commented on June 15, 2024

i was just confused because here: https://github.com/mkafrin/PolyZone/wiki/EntityZone these not listed as options.

from polyzone.

mkafrin avatar mkafrin commented on June 15, 2024

If you read right above EntityZone options, it states that EntityZone inherits all but a couple of BoxZone's options.
image

from polyzone.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.