IsOOPEnabled: Difference between revisions
Jump to navigation
Jump to search
m (→Example) |
m (Added some links) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | {{Server client function}} | ||
{{New | {{New feature/item|3.0141|1.4.1|6855|This function checks whether ''[[OOP]]'' (Object Oriented Programming) is enabled in the current [[resource]] or not.}} | ||
==Syntax== | ==Syntax== | ||
Line 10: | Line 10: | ||
==Example== | ==Example== | ||
<section name="Example" class="both" show="true">This shared (clientside and serverside) example outputs if ''[[OOP]]'' is enabled when the resource which contains it starts, and teleports a random player 10 units left if so.<syntaxhighlight lang="lua">local function checkOOPStatus() | <section name="Example" class="both" show="true">This shared (clientside and serverside) example outputs if ''[[OOP]]'' is enabled when the [[resource]] which contains it starts, and teleports a random player 10 units left if so.<syntaxhighlight lang="lua">local function checkOOPStatus() | ||
if isOOPEnabled() then | if isOOPEnabled() then | ||
outputChatBox("* OOP is enabled! Welcome to matrices' paradise.", root, 0, 255, 0) | outputChatBox("* OOP is enabled! Welcome to matrices' paradise.", getRandomPlayer and root or 0, getRandomPlayer and 0 or 255, getRandomPlayer and 255 or 0, getRandomPlayer and 0 or nil) | ||
local player | local player | ||
if getRandomPlayer then -- Are we executed serverside? | if getRandomPlayer then -- Are we executed serverside? | ||
Line 26: | Line 26: | ||
end | end | ||
player.position = player.position + player.matrix.left * 10 -- Move him 10 units left, taking into account rotation | player.position = player.position + player.matrix.left * 10 -- Move him 10 units left, taking into account rotation | ||
outputChatBox(player.name .. " was moved 10 meters left as a demostration of OOP capabilities!", 180, 180, 255) | outputChatBox(player.name .. " was moved 10 meters left as a demostration of OOP capabilities!", getRandomPlayer and root or 180, 180, getRandomPlayer and 180 or 255, getRandomPlayer and 255 or nil) | ||
else | else | ||
outputChatBox("* OOP is disabled! You should like the good ol' tables.", root, 255, 140, 0) | outputChatBox("* OOP is disabled! You should like the good ol' tables.", getRandomPlayer and root or 255, getRandomPlayer and 255 or 140, getRandomPlayer and 140 or 0, getRandomPlayer and 0 or nil) | ||
end | end | ||
end | end |
Latest revision as of 10:22, 11 October 2014
This function checks whether OOP (Object Oriented Programming) is enabled in the current resource or not.
Syntax
bool isOOPEnabled ( )
Returns
Returns true or false if OOP is enabled or not. Returns nil if an error arised.
Example
Click to collapse [-]
ExampleThis shared (clientside and serverside) example outputs if OOP is enabled when the resource which contains it starts, and teleports a random player 10 units left if so.
local function checkOOPStatus() if isOOPEnabled() then outputChatBox("* OOP is enabled! Welcome to matrices' paradise.", getRandomPlayer and root or 0, getRandomPlayer and 0 or 255, getRandomPlayer and 255 or 0, getRandomPlayer and 0 or nil) local player if getRandomPlayer then -- Are we executed serverside? player = Player.getRandom() -- Make it easy, use OOP to get a random player else local players = getElementsByType("player") if #players > 0 then -- Is the server empty? player = players[math.random(1, #players)] -- Get a random player using player elements table end end if not player then return -- We don't have a player. Cancel further execution of this function. end player.position = player.position + player.matrix.left * 10 -- Move him 10 units left, taking into account rotation outputChatBox(player.name .. " was moved 10 meters left as a demostration of OOP capabilities!", getRandomPlayer and root or 180, 180, getRandomPlayer and 180 or 255, getRandomPlayer and 255 or nil) else outputChatBox("* OOP is disabled! You should like the good ol' tables.", getRandomPlayer and root or 255, getRandomPlayer and 255 or 140, getRandomPlayer and 140 or 0, getRandomPlayer and 0 or nil) end end checkOOPStatus() -- Execute this at resource start
See also
- addDebugHook
- base64Decode
- base64Encode
- debugSleep
- decodeString
- encodeString
- fromJSON
- generateKeyPair
- getColorFromString
- getDevelopmentMode
- getDistanceBetweenPoints2D
- getDistanceBetweenPoints3D
- getEasingValue
- getNetworkStats
- getNetworkUsageData
- getPerformanceStats
- getRealTime
- getTickCount
- getTimerDetails
- getTimers
- getFPSLimit
- getUserdataType
- getVersion
- gettok
- isTransferBoxVisible
- setTransferBoxVisible
- hash
- inspect
- interpolateBetween
- iprint
- isOOPEnabled
- isTimer
- killTimer
- md5
- passwordHash
- passwordVerify
- pregFind
- pregMatch
- pregReplace
- removeDebugHook
- resetTimer
- setDevelopmentMode
- setFPSLimit
- setTimer
- ref
- deref
- sha256
- split
- teaDecode
- teaEncode
- toJSON
- tocolor
- getProcessMemoryStats
- utfChar
- utfCode
- utfLen
- utfSeek
- utfSub
- bitAnd
- bitNot
- bitOr
- bitXor
- bitTest
- bitLRotate
- bitRRotate
- bitLShift
- bitRShift
- bitArShift
- bitExtract
- bitReplace