XetaQuake Posted May 24, 2008 Share Posted May 24, 2008 Hi, i creates a GUI with the GUI Editor, and now i want that the text in a label moves from right to left, but not the label itself! Is that possibly? I think it is anything with this math. stuff in lua, but i absolutely don´t know how i can make that. Here is the label: label = guiCreateLabel(0.019390568137169,0.39655232429504,0.9570637345314,0.34482741355896,xmlInfoData,true,GUIEditor_Window[1]) You can see the script read the text for the label out from a xml file, and that´s works perfect! but i want to let it move I hope you understand me Link to comment
XetaQuake Posted May 24, 2008 Author Share Posted May 24, 2008 Hi, i creates a GUI with the GUI Editor, and now i want that the text in a label moves from right to left, but not the label itself! Is that possibly? I think it is anything with this math. stuff in lua, but i absolutely don´t know how i can make that. Here is the label: label = guiCreateLabel(0.019390568137169,0.39655232429504,0.9570637345314,0.34482741355896,xmlInfoData,true,GUIEditor_Window[1]) You can see the script read the text for the label out from a xml file, and that´s works perfect! but i want to let it move I hope you understand me Link to comment
Remp Posted May 24, 2008 Share Posted May 24, 2008 do you mean align it to the left\right (see here) or do you mean constanlty move it back and forth? Link to comment
Remp Posted May 24, 2008 Share Posted May 24, 2008 do you mean align it to the left\right (see here) or do you mean constanlty move it back and forth? Link to comment
XetaQuake Posted May 24, 2008 Author Share Posted May 24, 2008 Hi, no i mean scrolling text, so it moves from right -> left, like here: http://www.ukauctionhelp.co.uk/marquee.php Link to comment
XetaQuake Posted May 24, 2008 Author Share Posted May 24, 2008 Hi, no i mean scrolling text, so it moves from right -> left, like here: http://www.ukauctionhelp.co.uk/marquee.php Link to comment
50p Posted May 24, 2008 Share Posted May 24, 2008 You need to use onClientRender (this event is triggered on every frame) or a timer. Then on every frame get the label's position and set new position by taking away some pixels from X coord. Eg.: addEventHandler( "onClientRender", getResourceRootElement( getThisResource( ) ), function( ) local x,y = guiGetPosition( label, false ) guiSetPosition( label, x-10, y, false ) end ) You'd have to remake this code a little bit, because this will keep moving the label even if it goes out of screen. Link to comment
50p Posted May 24, 2008 Share Posted May 24, 2008 You need to use onClientRender (this event is triggered on every frame) or a timer. Then on every frame get the label's position and set new position by taking away some pixels from X coord. Eg.: addEventHandler( "onClientRender", getResourceRootElement( getThisResource( ) ), function( ) local x,y = guiGetPosition( label, false ) guiSetPosition( label, x-10, y, false ) end) You'd have to remake this code a little bit, because this will keep moving the label even if it goes out of screen. Link to comment
XetaQuake Posted May 24, 2008 Author Share Posted May 24, 2008 I thank it works absolutely perfect =) Now i have a other question ^^ First the code: ... ... xmlInfo = xmlLoadFile("random_test.xml") xmlInfoNode = xmlFindSubNode(xmlInfo, math.random(stuff1, stuff3), 0) xmlInfoData = xmlNodeGetValue(xmlInfoNode) ... ... label = guiCreateLabel(0.019390568137169,0.39655232429504,0.9570637345314,0.34482741355896,xmlInfoData,true,GUIEditor_Window[1]) ... ... The label gets the text from an xml file, now i tries to use a math.random to find different nodes in the xml file (line 6 in the code). I don´t know why but it don´t works, any ideas? Link to comment
XetaQuake Posted May 24, 2008 Author Share Posted May 24, 2008 I thank it works absolutely perfect =) Now i have a other question ^^ First the code: ......xmlInfo = xmlLoadFile("random_test.xml") xmlInfoNode = xmlFindSubNode(xmlInfo, math.random(stuff1, stuff3), 0)xmlInfoData = xmlNodeGetValue(xmlInfoNode)......label = guiCreateLabel(0.019390568137169,0.39655232429504,0.9570637345314,0.34482741355896,xmlInfoData,true,GUIEditor_Window[1])...... The label gets the text from an xml file, now i tries to use a math.random to find different nodes in the xml file (line 6 in the code). I don´t know why but it don´t works, any ideas? Link to comment
Remp Posted May 24, 2008 Share Posted May 24, 2008 the second argument of xmlFindSubNode should be a string, math.random returns an integer in your case it should be xmlInfoNode = xmlFindSubNode(xmlInfo, "name of subnode", math.random(stuff1, stuff3)) Link to comment
Remp Posted May 24, 2008 Share Posted May 24, 2008 the second argument of xmlFindSubNode should be a string, math.random returns an integer in your case it should be xmlInfoNode = xmlFindSubNode(xmlInfo, "name of subnode", math.random(stuff1, stuff3)) Link to comment
XetaQuake Posted May 24, 2008 Author Share Posted May 24, 2008 What's the meaning of this? "stuff", math.random(stuff1, stuff3) Waht the script makes then? searching for a node called "stuff stuff2" for example in the xml file? I don´t think that this works. Link to comment
XetaQuake Posted May 24, 2008 Author Share Posted May 24, 2008 What's the meaning of this? "stuff", math.random(stuff1, stuff3) Waht the script makes then? searching for a node called "stuff stuff2" for example in the xml file? I don´t think that this works. Link to comment
Remp Posted May 24, 2008 Share Posted May 24, 2008 look at the wiki page for xmlFindSubNode xmlFindSubNode ( xmlnode parent, string subnode, int index ) so, based on that, this will search for a subnode of xmlInfo called "name" at a random index xmlInfoNode = xmlFindSubNode(xmlInfo, "name", math.random(min, max)) Link to comment
Remp Posted May 24, 2008 Share Posted May 24, 2008 look at the wiki page for xmlFindSubNode xmlFindSubNode ( xmlnode parent, string subnode, int index ) so, based on that, this will search for a subnode of xmlInfo called "name" at a random index xmlInfoNode = xmlFindSubNode(xmlInfo, "name", math.random(min, max)) Link to comment
XetaQuake Posted May 24, 2008 Author Share Posted May 24, 2008 i tested it now: Here is the lua code: xmlInfoNode = xmlFindSubNode(xmlInfo, "stuff", math.random(1, 3)) And the xml: <root> <stuff 1> read out from xml file, stuff1 </stuff 1> <stuff 2> read out from xml file, stuff2, YEA!! </stuff 2> <stuff 3> and FINALY: read out from xml file, stuff3 </stuff 3> </root> I also tried it with stuff1, not stuff 1, but don´t works. I already was thinking about that for my eyes the lua code looks wrong. but i don´t get it working Link to comment
XetaQuake Posted May 24, 2008 Author Share Posted May 24, 2008 i tested it now: Here is the lua code: xmlInfoNode = xmlFindSubNode(xmlInfo, "stuff", math.random(1, 3)) And the xml: read out from xml file, stuff11>read out from xml file, stuff2, YEA!!2>and FINALY: read out from xml file, stuff33> I also tried it with stuff1, not stuff 1, but don´t works. I already was thinking about that for my eyes the lua code looks wrong. but i don´t get it working Link to comment
Remp Posted May 24, 2008 Share Posted May 24, 2008 they dont need to have different names, call them all "stuff" and the index will indicate which one to read also, the index starts at 0 not 1 xmlInfoNode = xmlFindSubNode(xmlInfo, "stuff", math.random(0, 2)) ... <root> <stuff>read out from xml file, stuff1</stuff> <stuff>read out from xml file, stuff2, YEA!!</stuff> <stuff>and FINALY: read out from xml file, stuff3</stuff> </root> Link to comment
Remp Posted May 24, 2008 Share Posted May 24, 2008 they dont need to have different names, call them all "stuff" and the index will indicate which one to read also, the index starts at 0 not 1 xmlInfoNode = xmlFindSubNode(xmlInfo, "stuff", math.random(0, 2)) ... read out from xml file, stuff1read out from xml file, stuff2, YEA!!and FINALY: read out from xml file, stuff3 Link to comment
[UVA]Bart Posted May 24, 2008 Share Posted May 24, 2008 save is like this in the xml then loop through the node stuff to find the one your after or do it the way you want. the main node is called "stuff" and the subnode is called "1" or "2" or "3" Link to comment
[UVA]Bart Posted May 24, 2008 Share Posted May 24, 2008 save is like this in the xml then loop through the node stuff to find the one your after or do it the way you want. the main node is called "stuff" and the subnode is called "1" or "2" or "3" Link to comment
XetaQuake Posted May 24, 2008 Author Share Posted May 24, 2008 PERFECT! thanks you two! Works realy fanstastic, and thanks 50p for the scrolling text! Link to comment
XetaQuake Posted May 24, 2008 Author Share Posted May 24, 2008 PERFECT! thanks you two! Works realy fanstastic, and thanks 50p for the scrolling text! Link to comment
eAi Posted May 24, 2008 Share Posted May 24, 2008 How about making this into a resource? It could be quite useful for server admins in general 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