Elohim Posted April 21, 2016 Posted April 21, 2016 Hello, i want to do an function that triggers other dx function, like this: local sw,sh = guiGetScreenSize() function draw(splashpath,name,text) if (splashpath) and (name) and (text) then dg = dxDrawImage(sw*.1,sh*.65,sw*.900,sh*.600,"tt.png") nm = dxDrawText(name,sw*.3,sh*.85) spl = dxDrawImage(sw*.12,sh*.72,sw*.200,sh*.400,splashpath) txt = dxDrawText(text,sw*.29,sh*.90) else outputDebugScript("Incorrect Syntaxis: drawDialogue(splashartpath,name,text)") end end --This triggers the function in top function drawDialogue(splashpath,name,text) addEventHandler("onClientRender",getLocalPlayer(),draw) end i dont know how to add the arguments splashpath,name, and text into the eventHandler
Bonsai Posted April 21, 2016 Posted April 21, 2016 Just make them global variables I guess. Then the drawDialogue function would not just start the rendering but also do the checks and set the values.
Elohim Posted April 21, 2016 Author Posted April 21, 2016 Oh, ok, and what is the best way to render that? "onClientRender"? Edit: sorry, i cant get it to work, how can i do correctly the global variables? only add the _ ?
Bonsai Posted April 21, 2016 Posted April 21, 2016 They best way would probably be to put them the same way as you put the "local sw,sh" variables. They are available in the whole script file, as long as they are outside of a function. Without the "local" they would be available in every script file e.g. all client-side scripts, of the resource. http://lua-users.org/wiki/ScopeTutorial
Elohim Posted April 21, 2016 Author Posted April 21, 2016 I did this local sw,sh = guiGetScreenSize() local spacer = dxGetFontHeight(1.2,"default") local nm = nm local spl = spl local txt = txt function draw(splashpath,name,text) if (splashpath) and (name) and (text) then dg = dxDrawImage(sw*.1,sh*.65,sw*.900,sh*.600,"tt.png") nm = dxDrawText(name,sw*.3,sh*.85) spl = dxDrawImage(sw*.12,sh*.72,sw*.200,sh*.400,splashpath) txt = dxDrawText(text,sw*.29,sh*.90+spacer) else outputDebugScript("Incorrect Syntaxis: drawDialogue(splashartpath,name,text)") end end function drawDialogue(splashpath,name,text) local nm = "bartender" local spl = "bartender.png" local txt = "test" addEventHandler("onClientRender",getLocalPlayer(),draw) end didnt work, i think i did a mistake anywhere, or everywhere u.u
Anubhav Posted April 21, 2016 Posted April 21, 2016 21 line replace getLocalPlayer() with root. Also 13 line replace outputDebugScript with outputDebugString
Bonsai Posted April 21, 2016 Posted April 21, 2016 You might need to go through the basics again. Those dx functions don't return anything useful. local nm = nm That seems kinda wrong too. And the rest.. remove the if else from the render function and put that in the other one for the start.
Elohim Posted April 21, 2016 Author Posted April 21, 2016 local sw,sh = guiGetScreenSize() local spacer = dxGetFontHeight(1.2,"default") function draw(splashpath,name,text) local dg = dxDrawImage(sw*.1,sh*.65,sw*.900,sh*.600,"tt.png") local nm = dxDrawText(name,sw*.3,sh*.85) local spl = dxDrawImage(sw*.12,sh*.72,sw*.200,sh*.400,splashpath) local txt = dxDrawText(text,sw*.29,sh*.90+spacer) end function drawDialogue(splashpath,name,text) local nm = "bartender" local spl = "bartender.png" local txt = "test" addEventHandler("onClientRender",root,draw) end drawDialogue("bartender.png","bartender","testing the shoots") i removed the locals on top, and repaired the errors that anubhav wrote, but i still cant add the variables to the event
Anubhav Posted April 22, 2016 Posted April 22, 2016 local sw,sh = guiGetScreenSize() local spacer = dxGetFontHeight(1.2,"default") local name = "" local splashpath = "" local text = "" function draw(splashpath,text) local dg = dxDrawImage(sw*.1,sh*.65,sw*.900,sh*.600,"tt.png") local nm = dxDrawText(name,sw*.3,sh*.85) local spl = dxDrawImage(sw*.12,sh*.72,sw*.200,sh*.400,splashpath) local txt = dxDrawText(text,sw*.29,sh*.90+spacer) end function drawDialogue(splashpath,name,text) name = "bartender" splashpath = "bartender.png" text = "test" addEventHandler("onClientRender",root,draw) end drawDialogue("bartender.png","bartender","testing the shoots")
Elohim Posted April 22, 2016 Author Posted April 22, 2016 dont work, "Expected string at argument 1" "Expected material at argument 6 " and "Expected string at argument 1"
Anubhav Posted April 22, 2016 Posted April 22, 2016 local sw,sh = guiGetScreenSize() local spacer = dxGetFontHeight(1.2,"default") local name = "" local splashpath = "" local text = "" function draw() local dg = dxDrawImage(sw*.1,sh*.65,sw*.900,sh*.600,"tt.png") local nm = dxDrawText(name,sw*.3,sh*.85) local spl = dxDrawImage(sw*.12,sh*.72,sw*.200,sh*.400,splashpath) local txt = dxDrawText(text,sw*.29,sh*.90+spacer) end function drawDialogue(splashpath,name,text) name = "bartender" splashpath = "bartender.png" text = "test" addEventHandler("onClientRender",root,draw) end drawDialogue("bartender.png","bartender","testing the shoots")
Elohim Posted April 22, 2016 Author Posted April 22, 2016 Returns error loading dxDrawImage on line 10. sorry if i cause troubles.
Gravestone Posted April 22, 2016 Posted April 22, 2016 Line 10: local nm = dxDrawText(name,sw*.3,sh*.85) I don't see any image path or function which should draw the image. Send us a screenshot of your debug script mode 3, that'll be helpful I guess.
Anubhav Posted April 22, 2016 Posted April 22, 2016 First of all Add 0 before every . (In the dxDraw functions)
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