Community

SCI Programming => SCI Syntax Help => Topic started by: Cloudee1 on November 25, 2015, 04:22:33 PM

Title: Removing a named Polygon
Post by: Cloudee1 on November 25, 2015, 04:22:33 PM
I have a named polygon created using scicompanion. As well as the other polygons which fall under the default name.

I am adding the polygons at init
Code: [Select]
  (method (init)
        AddPolygonsToRoom(@P_Default35)
        AddPolygonsToRoom(@P_SkimmerPoly)
  (super:init())

If the skimmer is gone, which corresponds to the skimmer poly, I have been unsuccessful at removing the polygon.

I tried the code from both eqoquest and kq6, which is pretty much identical. I am assuming that global2 maps to gRoom, which might be part of my problem if I am mistaken there.

Code: [Select]
(send ((send gRoom:obstacles)):delete(@P_SkimmerPoly))

I tried it with and without the @ symbol. Both ways compile fine, however the poly is ever present. Anyone have any ideas on how to accomplish the removal of the polygon generated by companion and housed in the shp file. I should be able to take it out of the shp file and actually code it to an instance of poly and try again, which I will probably do for testing, but that loses the ease of use that Troflip built into scicompanion for working with the polygons. So I would rather not make that plan a
Title: Re: Removing a named Polygon
Post by: troflip on November 25, 2015, 04:36:57 PM
obstacles deals with polygon objects, not buffers of polygon points. So you need to do something like:

Code: [Select]
(local
    shipPolygon
)


Code: [Select]
(method (init)
    // Stash it off so we can remove it later:
    (= shipPolygon CreateNewPolygon(@P_SkimmerPoly))
    // Add it:
    (send gRoom:addObstacle(shipPolygon))
)

Then when you want to remove it:

Code: [Select]
(send (send gRoom:obstacles):delete(shipPolygon))