Jump to content

[REL] Textlib: Create dxText easily


Recommended Posts

I know this is epic bump, but I need to ask to anyone who's still using this library: how to use any animation?

I tried this code but seems like I'm wrong.

Animation.presets.dxTextMove ( text, sw*0.9, sh*0.7, 500 ) 

text is a text object, it works yeah, but that dxTextMove stress me.

sw and sh represents guiGetScreenSize, and work too, of course.

Edited by Guest
Link to comment

Why my PC starts to lagg like a hell when i just write this

    dxText:create("Area:\n"..playerZoneName1..", "..playerZoneName, 0.7805, 0.2266, true) 
    dxText:scale(1.20) 
    dxText:font("arial") 

"playerZoneName1" and "playerZoneName" are defined earlier in the code.

And this is handled with onClientRender, so what's the problem of that massive lag ?

Link to comment
And this is handled with onClientRender, so what's the problem of that massive lag ?

sisko-facepalm.jpg%3Fw%3D300%26h%3D242

dxText already does that onClientRender thing. It looks that you create a new handler which draws text every time after frame, so in 1s you will have 45 handlers while running @ 45 fps. COOL. Use dxText:Create() once ;p

Link to comment

I must repeat. CAN ANYONE HELP ME IN THIS FUNCTION SYNTAX, please?

"text" is defined.

"sw, sh" = guiGetScreenSize.

text:Animation.presets.dxTextMove ( sw*0.9, sh*0.7, 500 ) 

I cannot understand the code of that function, that's why I ask for help D:

Link to comment

i don't see the how this function could work at all...

"Animation" is not defined as a table nowhere, so you should be geting the error:

"attempt to index global 'Animation' (a nil value)" ("Animation.presets" should also be a table, but its nil)

i'm not even sure if this is finished, but it only make sens if you use it like this:

dxTextMove (textelement, somevalue, {endX=sw*0.9,endY=sh*0.7}) 

function dxTextMove(endX, endY, time, loop, startX, startY, speedUpSlowDown) 
    --NB: ABSOLUTE POSITION 
    -- dxTextMove(endX, endY, [ time = 1000, loop = false, startX = current X, startY = current Y, speedUpSlowDown = false ]) 
    if type(endX) ~= 'table' then 
        return { from = speedUpSlowDown and -math.pi/2 or 0, to = speedUpSlowDown and math.pi/2 or 1, 
                 time = time or 1000, repeats = loop and 0 or 1, fn = Animation.presets.dxTextMove, 
                 startX = startX, startY = startY, endX = endX, endY = endY, speedUpSlowDown = speedUpSlowDown } 
    else 
        local elem, value, phase = endX, endY, time 
        if phase.speedUpSlowDown then 
            value = (value + 1)/2 
        end 
        if not phase.startX then 
            phase.startX, phase.startY = elem:position() 
            if elem.bRelativePosition then 
                phase.startX, phase.startY = phase.startX*screenX, phase.startY*screenY 
            end 
        end 
        local x = (phase.startX + (phase.endX - phase.startX)*value)/screenX 
        local y = (phase.startY + (phase.endY - phase.startY)*value)/screenY 
        elem:position(x,y) 
    end 
end 

but this should only move the text with no animation...

Link to comment
"Animation" is not defined as a table nowhere, so you should be geting the error:

"attempt to index global 'Animation' (a nil value)" ("Animation.presets" should also be a table, but its nil)

It is. You need arc's "client_anim" library script before getting this one.

Btw I think I just understood how this work, I'll try the way. If it works, I'll tell here how to use animations.

EDIT: YEA!!!

To use any animation you must take in account that this works pretty different from other things. First of all, it uses arc client_anim library, so you NEED TO HAVE that script (find it on race gamemode).

In textlib_anim there are some animation presets you can use, like Animation.presets.dxTextMove.

You can find the functions use at arc's library.

For example, to move any dxText to position SCREEN_WIDTH * 0.9, SCREEN_HEIGHT * 0.7 in 1/4 seconds, use this code:

local sw, sh = guiGetScreenSize ( ) 
Animation.createAndPlay ( yourDXText, Animation.presets.dxTextMove ( sw*0.9, sh*0.7, 250 ) ) 

Link to comment

This lib is a bit buggy.

function createText1 ( ) 
    local playerX, playerY, playerZ = getElementPosition( getLocalPlayer() )  -- Get player's coordinates. 
    local playerZoneName =  getZoneName( playerX, playerY, playerZ, false )          -- Get name of the player's zone. 
    local playerZoneName1 =  getZoneName( playerX, playerY, playerZ, true )          -- Get name of the player's zone. 
  
    txt = dxText:create("Area:\n"..playerZoneName1..", "..playerZoneName, 0.8205, 0.2266, true) 
    txt:scale(1.20) 
    txt:font("arial") 
    txt1:postGUI(true) 
    txt1 = dxText:create("Area:\n"..playerZoneName1..", "..playerZoneName, 0.8205, 0.2266, true) 
    txt1:scale(1.22) 
    txt1:color(0,0,0,255) 
    txt1:font("arial") 
end 

It doesn't updates the dxText(txt), while with "dxDrawText" worked perfectly!

Link to comment

I did it and still nothing.. -.-

    txt = dxText:create("", 0.8205, 0.2266, true) 
    txt:text("Area:\n"..playerZoneName1..", "..playerZoneName ) 

Neither this.

    txt = dxText:create("", 0.8205, 0.2266, true) 
    txt2 = txt:text("Area:\n"..playerZoneName1..", "..playerZoneName ) 

Link to comment
Show me your code. I'll tell you what's wrong.

This library doesn't lag, it's just that you are using it wrong or something. I have a bad PC (1 GB RAM DDR1 166 MHz + Intel Pentium 4, 1 Core, 2.0 GHz) and doesn't reduce my FPS.

    txt = dxText:create("", 0.8205, 0.2266, true) 
    txt2 = txt:text("Area:\n"..playerZoneName1..", "..playerZoneName ) 
    txt:scale(1.20) 
    txt:font("arial") 
    txt1:postGUI(true) 

Link to comment
    txt = dxText:create("", 0.8205, 0.2266, true) 
    txt:text("Area:\n"..playerZoneName1..", "..playerZoneName ) 
    txt:scale(1.20) 
    txt:font("arial") 
    txt:postGUI(true) 

What is playerZoneName1 and playerZoneName

Edited by Guest
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...