description |
---|
Distance 3D text |
Rcore provides two methods for creating 3D texts, one easier to use, but not that advanced and one harder to use, but with many advanced functions. The older one can be found in common functions.
The newer method for creating 3D texts is object-oriented, same as marker V2 method, so we will show you examples of how to use it.
{% code title="client_side.lua" %}
rcore = exports.rcore
function create3DText()
text = rcore:create3DText()
text.setText("Hi!")
text.setPosition(vector3(1729.89,3313.33,40.22))
text.setRed(red)
text.setGreen(green)
text.render()
text.on('enter',function()
dbg.info('On enter')
end)
text.on('leave', function()
dbg.info('on leave')
end)
text.setKeys({
keys['E'],
})
text.on('key', function(pressed)
dbg.info('on key press %s',pressed)
end)
Wait(10000)
text.destroy()
end
{% endcode %}
A simple function that creates empty 3D text for you.
Sets the text which you want to display using 3D text. / Gets text which is being displayed (default is an empty string).
Using vector3 as a parameter to setup position of 3D text.
Starts rendering the 3D text.
Stops rendering the 3D text.
Text on is a function that will provide you simple API to create 3 callbacks that you need and that is
- enter - on player enter the 3D text
- leave - on player leave the 3D text
- key - on player press any setup key when is in 3D text
{% hint style="warning" %} On key is calling only if you setup which keys it should be monitoring, look at example, its using function setKeys {% endhint %}
{% tabs %} {% tab title="Enter" %} {% code title="client_side.lua" %}
text.on('enter',function()
print('On enter')
end)
{% endcode %} {% endtab %}
{% tab title="Leave" %} {% code title="client_side.lua" %}
marker.on('leave',function()
print('On leave')
end)
{% endcode %} {% endtab %}
{% tab title="Key" %} {% code title="client_side.lua" %}
rcore = exports.rcore
keys = rcore:getKeys()
marker.setKeys({
keys['E'],
})
marker.on('key', function(pressed)
print('on key press %s',pressed)
end)
{% endcode %} {% endtab %} {% endtabs %}
Returns all the keys you has set for your 3D text (default: empty table)
Returns your 3D text id.
Set/Get scale of 3D text (default: 0.1).
Sets/gets size of the 3D text (default: 0.8).
you can set color with RGBA table {r = 0, g= 0, b=255,a=255} or you can set every color by self
- setAlpha(alpha)
- getAlpha()
- setRed(red)
- getRed()
- setGreen(green)
- getGreen()
- setBlue(blue)
- getBlue()
Sets/gets distance from which 3D text renders (default: 20)
Sets/gets font which 3D text is using.
Set/Get radius for calling enter/leave function (default: 1.5)
Destroys the 3D text.
Returns true/false whether is text being rendered.