You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
---Lua BitOp is free software, released under the MIT license (same license as the Lua core).
5
+
---Lua BitOp is compatible with the built-in bitwise operations in LuaJIT 2.0 and is used
6
+
---on platforms where Defold runs without LuaJIT.
7
+
---For clarity the examples assume the definition of a helper function printx().
8
+
---This prints its argument as an unsigned 32 bit hexadecimal number on all platforms:
9
+
---function printx(x)
10
+
--- print("0x"..bit.tohex(x))
11
+
---end
12
+
13
+
---@classbit
14
+
bit= {}
15
+
---Returns the bitwise arithmetic right-shift of its first argument by the number of bits given by the second argument.
16
+
---Arithmetic right-shift treats the most-significant bit as a sign bit and replicates it.
17
+
---Only the lower 5 bits of the shift count are used (reduces to the range [0..31]).
18
+
---@paramxnumber # number
19
+
---@paramnnumber # number of bits
20
+
---@returnnumber # bitwise arithmetic right-shifted number
21
+
functionbit.arshift(x, n) end
22
+
23
+
---Returns the bitwise and of all of its arguments. Note that more than two arguments are allowed.
24
+
---@paramx1number # number
25
+
--- ... number? # number(s)
26
+
---@returnnumber # bitwise and of the provided arguments
27
+
functionbit.band(x1, ...) end
28
+
29
+
---Returns the bitwise not of its argument.
30
+
---@paramxnumber # number
31
+
---@returnnumber # bitwise not of number x
32
+
functionbit.bnot(x) end
33
+
34
+
---Returns the bitwise or of all of its arguments. Note that more than two arguments are allowed.
35
+
---@paramx1number # number
36
+
--- ... number? # number(s)
37
+
---@returnnumber # bitwise or of the provided arguments
38
+
functionbit.bor(x1, ...) end
39
+
40
+
---Swaps the bytes of its argument and returns it. This can be used to convert little-endian 32 bit numbers to big-endian 32 bit numbers or vice versa.
41
+
---@paramxnumber # number
42
+
---@returnnumber # bitwise swapped number
43
+
functionbit.bswap(x) end
44
+
45
+
---Returns the bitwise xor of all of its arguments. Note that more than two arguments are allowed.
46
+
---@paramx1number # number
47
+
--- ... number? # number(s)
48
+
---@returnnumber # bitwise xor of the provided arguments
49
+
functionbit.bxor(x1, ...) end
50
+
51
+
---Returns the bitwise logical left-shift of its first argument by the number of bits given by the second argument.
52
+
---Logical shifts treat the first argument as an unsigned number and shift in 0-bits.
53
+
---Only the lower 5 bits of the shift count are used (reduces to the range [0..31]).
54
+
---@paramxnumber # number
55
+
---@paramnnumber # number of bits
56
+
---@returnnumber # bitwise logical left-shifted number
57
+
functionbit.lshift(x, n) end
58
+
59
+
---Returns the bitwise left rotation of its first argument by the number of bits given by the second argument. Bits shifted out on one side are shifted back in on the other side.
60
+
---Only the lower 5 bits of the rotate count are used (reduces to the range [0..31]).
61
+
---@paramxnumber # number
62
+
---@paramnnumber # number of bits
63
+
---@returnnumber # bitwise left-rotated number
64
+
functionbit.rol(x, n) end
65
+
66
+
---Returns the bitwise right rotation of its first argument by the number of bits given by the second argument. Bits shifted out on one side are shifted back in on the other side.
67
+
---Only the lower 5 bits of the rotate count are used (reduces to the range [0..31]).
68
+
---@paramxnumber # number
69
+
---@paramnnumber # number of bits
70
+
---@returnnumber # bitwise right-rotated number
71
+
functionbit.ror(x, n) end
72
+
73
+
---Returns the bitwise logical right-shift of its first argument by the number of bits given by the second argument.
74
+
---Logical shifts treat the first argument as an unsigned number and shift in 0-bits.
75
+
---Only the lower 5 bits of the shift count are used (reduces to the range [0..31]).
76
+
---@paramxnumber # number
77
+
---@paramnnumber # number of bits
78
+
---@returnnumber # bitwise logical right-shifted number
79
+
functionbit.rshift(x, n) end
80
+
81
+
---Normalizes a number to the numeric range for bit operations and returns it. This function is usually not needed since all bit operations already normalize all of their input arguments.
82
+
---@paramxnumber # number to normalize
83
+
---@returnnumber # normalized number
84
+
functionbit.tobit(x) end
85
+
86
+
---Converts its first argument to a hex string. The number of hex digits is given by the absolute value of the optional second argument. Positive numbers between 1 and 8 generate lowercase hex digits. Negative numbers generate uppercase hex digits. Only the least-significant 4*|n| bits are used. The default is to generate 8 lowercase hex digits.
---Functions for controlling collection factory components which are
3
+
---used to dynamically spawn collections into the runtime.
4
+
---@classcollectionfactory
5
+
collectionfactory= {}
6
+
---loaded
7
+
collectionfactory.STATUS_LOADED=nil
8
+
---loading
9
+
collectionfactory.STATUS_LOADING=nil
10
+
---unloaded
11
+
collectionfactory.STATUS_UNLOADED=nil
12
+
---The URL identifies the collectionfactory component that should do the spawning.
13
+
---Spawning is instant, but spawned game objects get their first update calls the following frame. The supplied parameters for position, rotation and scale
14
+
---will be applied to the whole collection when spawned.
15
+
---Script properties in the created game objects can be overridden through
16
+
---a properties-parameter table. The table should contain game object ids
17
+
---(hash) as keys and property tables as values to be used when initiating each
18
+
---spawned game object.
19
+
---See go.property for more information on script properties.
20
+
---The function returns a table that contains a key for each game object
21
+
---id (hash), as addressed if the collection file was top level, and the
22
+
---corresponding spawned instance id (hash) as value with a unique path
23
+
---prefix added to each instance.
24
+
--- Calling collectionfactory.create <> create on a collection factory that is marked as dynamic without having loaded resources
25
+
---using collectionfactory.load <> will synchronously load and create resources which may affect application performance.
26
+
---@paramurlstring|hash|url # the collection factory component to be used
27
+
---@parampositionvector3? # position to assign to the newly spawned collection
28
+
---@paramrotationquaternion? # rotation to assign to the newly spawned collection
29
+
---@parampropertiestable? # table of script properties to propagate to any new game object instances
30
+
---@paramscalenumber? # uniform scaling to apply to the newly spawned collection (must be greater than 0).
31
+
---@returntable # a table mapping the id:s from the collection to the new instance id:s
32
+
functioncollectionfactory.create(url, position, rotation, properties, scale) end
33
+
34
+
---This returns status of the collection factory.
35
+
---Calling this function when the factory is not marked as dynamic loading always returns COMP_COLLECTION_FACTORY_STATUS_LOADED.
36
+
---@paramurlstring|hash|url? # the collection factory component to get status from
37
+
---@returnconstant # status of the collection factory component
38
+
functioncollectionfactory.get_status(url) end
39
+
40
+
---Resources loaded are referenced by the collection factory component until the existing (parent) collection is destroyed or collectionfactory.unload is called.
41
+
---Calling this function when the factory is not marked as dynamic loading does nothing.
42
+
---@paramurlstring|hash|url? # the collection factory component to load
43
+
---@paramcomplete_function (fun(self: object, url: url, result: boolean))? # function to call when resources are loaded.
44
+
functioncollectionfactory.load(url, complete_function) end
45
+
46
+
---This decreases the reference count for each resource loaded with collectionfactory.load. If reference is zero, the resource is destroyed.
47
+
---Calling this function when the factory is not marked as dynamic loading does nothing.
48
+
---@paramurlstring|hash|url? # the collection factory component to unload
0 commit comments