maps png picture material



local _mapName = string.lower( game.GetMap() )
local _mapPicturePath = "maps/" .. _mapName .. ".png"

local _mapPNG = Material( "../maps/no_image.png", "noclamp smooth" )
if file.Exists( _mapPicturePath, "GAME" ) then
  _mapPicturePath = "../" .. _mapPicturePath
  _mapPNG = Material( _mapPicturePath, "noclamp smooth" )
  print( "Loaded " .. _mapPicturePath )
else
  print( _mapPicturePath .. " not found." )
end


This load the map image if i have it on my drive, but not when the png is in a workshop file.
is it possible to copy from the workshop file to the maps folder?

with file.Read and file.Write
or have someone other ideas?

The only directory that can be written to is the /data/ folder.



  local _mapName = string.lower( game.GetMap() )
  local _mapPicturePath = "maps/" .. _mapName .. ".png"

  local _mapPNG = Material( "../maps/no_image.png", "noclamp smooth" )
  if file.Exists( _mapPicturePath, "GAME" ) then //look for original png
    file.Write( _mapPicturePath, file.Read( _mapPicturePath, "GAME" ) ) //Write original file to data/maps/   //file.Write to data/maps/mapname.png
    if file.Exists( _mapPicturePath, "DATA" ) then //look if it was successfull
  		_mapPNG = Material( "../data/" .. _mapPicturePath, "noclamp smooth" )  //use the new png file
  		print( "Loaded " .. _mapPicturePath )
    else
      print("Loading failed")
    end
  else
    print( _mapPicturePath .. " not found." )
  end


this failed:



 file.Write( _mapPicturePath, file.Read( _mapPicturePath, "GAME" ) )


did i something wrong or is it not working? (file exists, i can read the file, but writing is not working)

Moku already said you can only write to “DATA”.

i am writing to DATA:



_mapPicturePath = "maps/" .. _mapName .. ".png"
file.Write( _mapPicturePath, ... //file.Write -> "data/maps/" .. _mapName .. ".png"


i read in “GAME”
and I am writing in “DATA”
but the writing is not working

found the problem! :smiley: the subdirectories wasn’t there in data folder … :smiley: