dugasz1 Posted May 23, 2015 Posted May 23, 2015 Hello! How can i use an image from another resource? So for example i have 2 resource called 'res1' and 'res2'. I write in an image to the meta in res1. And how can i use it in res2? Sorry for lot of questions and thanks for the answers!
tosfera Posted May 23, 2015 Posted May 23, 2015 You can either use :resname/image.png or you can create an entire media system. That's what I'm always doing, the system will keep track of all your images and also draw them by using an exported function. Therefore you don't have to search for images in every resource if you want 2 different images. All you have to do, is call the exported function and... magic happens. If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]
dugasz1 Posted May 23, 2015 Author Posted May 23, 2015 Thanks both of you. Sorry for lot of questions and thanks for the answers!
Moderators IIYAMA Posted May 23, 2015 Moderators Posted May 23, 2015 Another way of requesting images from other resources: (not tested but should be working) <export function="requestImage" type="client"/> local requestDatabase = {} function requestImage (filePath,buffer) if requestDatabase[filePath] then return requestDatabase[filePath]["texture"] elseif fileExists (filePath) then local texture = dxCreateTexture(filePath) if texture then if buffer then requestDatabase[filePath] = {["texture"]= texture,["creationTime"]=getRealTime().timestamp} end return texture end end return false end local image = call ( getResourceFromName ( "**********" ), "requestImage",filePath,true) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
tosfera Posted May 23, 2015 Posted May 23, 2015 That's the thing I was saying, iiyama. Just create an exported function to retrieve all your images. (: If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]
Walid Posted May 23, 2015 Posted May 23, 2015 That's the thing I was saying, iiyama. Just create an exported function to retrieve all your images. (: A common resource for the image will save memory. but Make sure the other resources it. Do not yield your back to your enemy, might feel something strange in your ass. Two things are infinite the universe and human stupidity and i'm not sure about the universe. UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators
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