HU/createColSphere: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Shared function hu}} | {{Shared function hu}} | ||
Ez function létrehoz collision gömböt. | Ez function létrehoz collision gömböt. Ez egy olyan forma, amelynek van egy pozicíója és egy sugara. Lásd [http://en.wikipedia.org/wiki/Sphere Wikipedia] a gömb meghatározásához. | ||
{{VisualizeColshape hu}} | {{VisualizeColshape hu}} | ||
==Szintaxis== | ==Szintaxis== | ||
Line 9: | Line 9: | ||
{{OOP| |ColShape.Sphere||}} | {{OOP| |ColShape.Sphere||}} | ||
===Kötelező paraméterek=== | ===Kötelező paraméterek=== | ||
*'''fX:''' | *'''fX:''' A collision gömb középpontjának X tengelye | ||
*'''fY:''' | *'''fY:''' A collision gömb középpontjának Y tengelye | ||
*'''fZ:''' | *'''fZ:''' A collision gömb középpontjának Z tengelye | ||
*'''fRadius:''' | *'''fRadius:''' A collision gömb sugara | ||
===Visszatérési érték=== | ===Visszatérési érték=== | ||
Visszaad egy [[colshape]] elemet, ha sikeres, ''false'', ha érvénytelen paraméterek lettek megadva a funkcióhoz. | |||
==Példa== | ==Példa== |
Revision as of 17:36, 9 October 2018
Ez function létrehoz collision gömböt. Ez egy olyan forma, amelynek van egy pozicíója és egy sugara. Lásd Wikipedia a gömb meghatározásához.
Tipp: A szkriptek írása közben egy colshape megjelenítéséhez használja a showcol parancsot |
Szintaxis
colshape createColSphere ( float fX, float fY, float fZ, float fRadius )
OOP Syntax Help! I don't understand this!
- Method: ColShape.Sphere(...)
Kötelező paraméterek
- fX: A collision gömb középpontjának X tengelye
- fY: A collision gömb középpontjának Y tengelye
- fZ: A collision gömb középpontjának Z tengelye
- fRadius: A collision gömb sugara
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 [-]
ServerExample 1: This example displays a chat message when a player enters the colshape and allows the colshape to be created using a console function set_zone.
theZone = false function shapeHit ( thePlayer ) outputChatBox ( getPlayerName ( thePlayer ) .. " is in the zone!" ) -- display a message in everyone's chat box end function setZone ( playerSource, commandName, fX, fY, fZ ) if ( fZ and fY and fX ) then -- check we've got all 3 args we need local tempCol = createColSphere ( fX, fY, fZ, 10.0 ) -- create a col if ( tempCol == false ) then -- did the col get created successfully? outputConsole ( "Syntax is: set_zone <X> <Y> <Z>" ) -- inform the user what the valid syntax is else if ( theZone ~= false ) then -- did we already have a zone? destroyElement ( theZone ) -- if so, destroy it else addEventHandler ( "onColShapeHit", theZone, shapeHit ) -- add a handler for the onColShapeHit event end theZone = tempCol -- and store the new zone we've made outputChatBox ( "Zone has moved!" ) -- and tell everyone end end end addCommandHandler ( "set_zone", setZone ) -- add a console function called set_zone that will trigger the function setZone
Example 2: This example allows creation of claymores, which trigger and explode.
function createClaymore ( x,y,z, creator ) local x,y,z = getElementPosition ( creator ) local claymoreObject = createObject ( 1945, x, y, z - 1, 0, 0, 90 ) --create an object which looks like a claymore local claymoreCol = createColSphere ( x, y, z, 1 ) --create a col sphere with radius 1 setElementData ( claymoreCol , "type", "claymore" ) --store the type of colshape so it can be retrieved setElementData ( claymoreCol, "object", claymoreObject ) --store the object of the claymore setElementData ( claymoreCol, "creatorPlayer", creator ) --store the person who created it end function claymoreHit ( player, matchingDimension ) if getElementData ( source, "type" ) == "claymore" then --ensure its a claymore --retrieve the object associated to the claymore, and who created it local claymoreObject = getElementData ( source, "object" ) local claymoreCreator = getElementData ( source, "creatorPlayer" ) --get the position of the claymore local x,y,z = getElementPosition ( source ) createExplosion ( x,y,z, 12, claymoreCreator ) --create an explosion, associated to the creator, of a small size at the col's position --destroy the claymore object, and the col shape so it doesnt trigger again. destroyElement ( claymoreObject ) destroyElement ( source ) end end addEventHandler ( "onColShapeHit", getRootElement(), claymoreHit )
Lásd még
- addColPolygonPoint
- createColCircle
- createColCuboid
- createColPolygon
- createColRectangle
- createColSphere
- createColTube
- getColPolygonHeight
- getColPolygonPoints
- getColPolygonPointPosition
- getColShapeType
- getColShapeRadius
- getColShapeSize
- getElementColShape
- getElementsWithinColShape
- isElementWithinColShape
- isInsideColShape
- removeColPolygonPoint
- setColPolygonHeight
- setColPolygonPointPosition
- setColShapeRadius
- setColShapeSize