HU/createColPolygon: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Shared function hu}} {{Note_box|For this function to work correctly, get/set your bound points in an anti-clockwise fashion.}} This function creates a collision p...")
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Shared function hu}}
{{Shared function hu}}
{{Note_box|For this function to work correctly, get/set your bound points in an anti-clockwise fashion.}}
{{Note_box_hu|A function megfelelő működése érdekében, állítsa be a kötött pontokat az óramutató járásával ellentétes irányba.}}
This function creates a collision polygon. See [http://en.wikipedia.org/wiki/Polygon Wikipedia] for a definition of a polygon. The first set of X Y of this shape is not part of the colshape bounds, so can set anywhere in the game world, however for performance, place it as close to the centre of the polygon as you can. It should be noted this shape is '''2D'''. There should be at least 3 bound points set.  
Ez a function létrehoz egy collision sokszöget. Lásd [http://en.wikipedia.org/wiki/Polygon Wikipedia] a sokszög meghatározásához. The first set of X Y of this shape is not part of the colshape bounds, so can set anywhere in the game world, however for performance, place it as close to the centre of the polygon as you can. It should be noted this shape is '''2D'''. There should be at least 3 bound points set.  
{{VisualizeColshape hu}}
{{VisualizeColshape hu}}
==Szintaxis==  
==Szintaxis==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
colshape createColPolygon ( float fX, float fY, float fX1, float fY1, float fX2, float fY2, float fX3, float fY3, ... )
colshape createColPolygon ( float fCenterX, float fCenterY, float fX1, float fY1, float fX2, float fY2, float fX3, float fY3, ... )
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP| |ColShape.Polygon||}}
{{OOP| |ColShape.Polygon||}}
===Kötelező paraméterek===  
===Kötelező paraméterek===  
*'''fX:''' The X position of the collision polygon's position - the position that will be returned from [[getElementPosition]].
*'''fX:''' Az collision sokszög pozíciójának X pozíciója - the position that will be returned from [[getElementPosition]].
*'''fY:''' The Y position of the collision polygon's position - the position that will be returned from [[getElementPosition]].
*'''fY:''' Az collision sokszög pozíciójának Y pozíciója - the position that will be returned from [[getElementPosition]].
*'''fX1:''' The 1st X position of the collision polygon's bound point
*'''fX1:''' The 1st X position of the collision polygon's bound point
*'''fY1:''' The 1st Y position of the collision polygon's bound point
*'''fY1:''' The 1st Y position of the collision polygon's bound point
Line 18: Line 18:
*'''fX3:''' The 3rd X position of the collision polygon's bound point
*'''fX3:''' The 3rd X position of the collision polygon's bound point
*'''fY3:''' The 3rd Y position of the collision polygon's bound point
*'''fY3:''' The 3rd Y position of the collision polygon's bound point
*'''...''' From the 3rd position you can have as many points as you require to create the colshape.
*'''...''' A 3. pozíciótól annyi pontot használhat, amennyit csak szeretne, hogy létrehozza a colshape-t.


===Visszatérési érték===
===Visszatérési érték===
Returns a [[colshape]] element if successful, ''false'' if invalid arguments were passed to the function.
Visszaad egy [[colshape]] elemet, ha sikeres, false, ha érvénytelen paraméterek lettek megadva a funkcióhoz.


==Példa==  
==Példa==  
Line 148: Line 148:


[[en:createColPolygon]]
[[en:createColPolygon]]
==Fordította==
* '''''[https://wiki.multitheftauto.com/wiki/User:Surge Surge]'''''

Latest revision as of 10:58, 16 May 2019

Megjegyzés: A function megfelelő működése érdekében, állítsa be a kötött pontokat az óramutató járásával ellentétes irányba.

Ez a function létrehoz egy collision sokszöget. Lásd Wikipedia a sokszög meghatározásához. The first set of X Y of this shape is not part of the colshape bounds, so can set anywhere in the game world, however for performance, place it as close to the centre of the polygon as you can. It should be noted this shape is 2D. There should be at least 3 bound points set.

[[{{{image}}}|link=|]] Tipp: A szkriptek írása közben egy colshape megjelenítéséhez használja a showcol parancsot

Szintaxis

colshape createColPolygon ( float fCenterX, float fCenterY, float fX1, float fY1, float fX2, float fY2, float fX3, float fY3, ... )

OOP Syntax Help! I don't understand this!

Method: ColShape.Polygon(...)


Kötelező paraméterek

  • fX: Az collision sokszög pozíciójának X pozíciója - the position that will be returned from getElementPosition.
  • fY: Az collision sokszög pozíciójának Y pozíciója - the position that will be returned from getElementPosition.
  • fX1: The 1st X position of the collision polygon's bound point
  • fY1: The 1st Y position of the collision polygon's bound point
  • fX2: The 2nd X position of the collision polygon's bound point
  • fY2: The 2nd Y position of the collision polygon's bound point
  • fX3: The 3rd X position of the collision polygon's bound point
  • fY3: The 3rd Y position of the collision polygon's bound point
  • ... A 3. pozíciótól annyi pontot használhat, amennyit csak szeretne, hogy létrehozza a colshape-t.

Visszatérési érték

Visszaad egy colshape elemet, ha sikeres, false, ha érvénytelen paraméterek lettek megadva a funkcióhoz.

Példa

Click to collapse [-]
Server

This example displays a chat message when any element hits the colshape and allows the colshape to be created using a console function set_zone.

local theZone = false

function shapeHit( element )
    local descriptor = "undefined"

    if getElementType( element ) == "player" then
        -- Use the player's name
        descriptor = getPlayerName( element )
    elseif getElementType( element ) == "vehicle" then
        -- Use the vehicle's model name
        descriptor = getVehicleName( element ) or descriptor
    end

    -- Output a message in the chat box for everyone on the server
    outputChatBox( descriptor .. " is in the zone!" )
end

function createZoneCommandHandler( playerSource, commandName, fX, fY, fX1, fY1, fX2, fY2, fX3, fY3, ... )
    -- Verify the player has given us the minimum amount of bound points
    if not ( fY and fX and fX1 and fY1 and fX2 and fX3 and fY3 ) then
        return outputChatBox( "Syntax: set_zone <X> <Y> <X1> <Y1> <X2> <Y2> <X3> <Y3> [<Xn> <Yn> ...]", playerSource, 255, 100, 100 )
    end

    -- Create the collision shape with the numbers from the arguments
    local tempCol = createColPolygon( fX, fY, fX1, fY1, fX2, fY2, fX3, fY3, ... )

    if not tempCol then
        return outputChatBox( "Error: Couldn't create collision polygon", playerSource, 255, 100, 100 )
    end

    -- Destroy the previous collision polygon shape in case we already have one
    if isElement( theZone ) then
        destroyElement( theZone )
    end

    -- Use a variable out-of-scope to keep track of the most recently created collision shape element
    theZone = tempCol

    -- Attach an event handler to the element to get notified whenever an element hits our collision shape
    addEventHandler( "onColShapeHit", tempCol, shapeHit, false )

    outputChatBox( "Success: Collision shape has been created!", playerSource, 100, 255, 100 )
end
addCommandHandler( "set_zone", createZoneCommandHandler )
Click to expand [+]
Server

Issues

Issue ID Description
#9742 [Fixed in 1.5.5-3.12343] Passing this function Vector2s are not fully supported

Lásd még

Fordította