Discord
Login
Community
DARK THEME

How can we override Files?

I want to rewrite the context of a file.

system.project.deleteFile( "source/generated/drawing")
system.project.writeFile( "source/generated/drawing", string, 0, function(result, error) print(result) end )

not working reliable

  string = "Test "+system.time()
  system.project.writeFile( "source/generated/drawing", string, object replace = "true" ext = "ms" end, function(result, error) print(result) end )

You don't need to delete the file.

That is not working for me Can you show me ur example programm? Once the file was written, it is not getting updated in real time.

init = function()
  nextTime = system.time() + 1000
end

update = function()
  if nextTime < system.time() then 
    nextTime += 1000
    string = "local Test ="+system.time()
    system.project.writeFile( "source/generated/drawing", string, object replace = "true" ext = "ms" end, function(result, error) print(result) end )
  end
end

draw = function()
end

The code is changed every one second. Only the editor does not show changes.

Do it this way

  • run this code so that the file appears,
  • remember the last 3 digits
  • run the code again
  • no changes visible
  • refresh the page
  • look at the last 3 digits, I always have different ones.

ah yeah, you have to reload the page. is there a way to automate this with js? I tried location.reload(); but doesnt work properly

init = function()
  nextTime = system.time() + 1000
end

update = function()
  if nextTime < system.time() then 

    local status = system.project.deleteFile( "source/generated/drawing")
    while not status.ready end 
    print("Delete file")
    string = "local Test = "+system.time()
    status = system.project.writeFile( "source/generated/drawing", string, object replace = "true" ext = "ms" end, function(result, error) print(result) end )
    while not status.ready end 
    nextTime += 5000
  end
end

draw = function()
end

Be careful with this code, because I managed to damage the project so that adding new folders and files did not work. After adding a file or folder, closing the project and re-creating it, there were no added items. After cloning the project, adding files and folders also did not work in the cloned project.

After some time it went away - but I don't know why.

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community