Jump to content

Image between resources


dugasz1

Recommended Posts

Posted

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?

Posted

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.

  • Moderators
Posted

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) 

Posted
That's the thing I was saying, iiyama. :P 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.

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...