12p Posted November 11, 2011 Share Posted November 11, 2011 (edited) 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 November 12, 2011 by Guest Link to comment
CapY Posted November 12, 2011 Share Posted November 12, 2011 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
12p Posted November 12, 2011 Share Posted November 12, 2011 It's txt = dxText:create("Area:\n"..playerZoneName1..", "..playerZoneName, 0.7805, 0.2266, true) txt:scale(1.20) txt:font("arial") Link to comment
Orange Posted November 12, 2011 Share Posted November 12, 2011 And this is handled with onClientRender, so what's the problem of that massive lag ? 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
12p Posted November 12, 2011 Share Posted November 12, 2011 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
Wojak Posted November 12, 2011 Share Posted November 12, 2011 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
12p Posted November 12, 2011 Share Posted November 12, 2011 "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
CapY Posted November 12, 2011 Share Posted November 12, 2011 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
karlis Posted November 13, 2011 Share Posted November 13, 2011 HOW THE HECK IT IS SUPPOSED TO UPDATE THE TEXT? do you even have slight knowledge about any scripting at all? obviously it first makes the string, then calls the function. Link to comment
CapY Posted November 13, 2011 Share Posted November 13, 2011 HOW THE HECK IT IS SUPPOSED TO UPDATE THE TEXT?do you even have slight knowledge about any scripting at all? obviously it first makes the string, then calls the function. What, i don't get you. Link to comment
karlis Posted November 13, 2011 Share Posted November 13, 2011 you create a string and hope it to get updated. that's like you would write something on paper with pen and wait for it to update as data goes outdated. Link to comment
CapY Posted November 13, 2011 Share Posted November 13, 2011 you create a string and hope it to get updated.that's like you would write something on paper with pen and wait for it to update as data goes outdated. So dxText:create is not like onClientRender ? Link to comment
karlis Posted November 13, 2011 Share Posted November 13, 2011 /facepalm x2 it does trigger it on client render, but theres no way it can know when to update, use dxtext:text(text) Link to comment
CapY Posted November 13, 2011 Share Posted November 13, 2011 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
karlis Posted November 13, 2011 Share Posted November 13, 2011 you need to change it when you want it to update, you dont get it do you? on client render is too soon to be needed, but timer each sec would be fine. this is 3rd facepalm from me. Link to comment
CapY Posted November 13, 2011 Share Posted November 13, 2011 you need to change it when you want it to update, you dont get it do you?on client render is too soon to be needed, but timer each sec would be fine. I already tried it with setTimer and it didn't worked, text was just messed up. Link to comment
karlis Posted November 13, 2011 Share Posted November 13, 2011 are you re-getting the playerzones too? Link to comment
12p Posted November 13, 2011 Share Posted November 13, 2011 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. Link to comment
CapY Posted November 13, 2011 Share Posted November 13, 2011 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
12p Posted November 13, 2011 Share Posted November 13, 2011 (edited) 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 November 13, 2011 by Guest Link to comment
CapY Posted November 13, 2011 Share Posted November 13, 2011 (edited) - Edited April 6, 2012 by Guest Link to comment
12p Posted November 13, 2011 Share Posted November 13, 2011 How do you update that text? Link to comment
karlis Posted November 13, 2011 Share Posted November 13, 2011 im feeling more facepalms incoming. anyway, txt:text() doesnt return another text element, it just updates the exsisting one. Link to comment
CapY Posted November 13, 2011 Share Posted November 13, 2011 (edited) - Edited April 6, 2012 by Guest Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now