Store Buffer Error

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By OrlanJRod

I’m not sure why i’m getting this error. It only appears on the exported game prompt.

“ERROR: store_buffer ‘!f’ is true”

Here is the code. The relevant portion is in ‘loadType == 2’ condition

func _on_HTTPRequest_request_completed(result, response_code, headers, body):

if result==HTTPRequest.RESULT_SUCCESS:
	if response_code==200:
		if (loadType == 1):
			var res
			res = parse_json(body.get_string_from_ascii())
			print("1")
			renderMap(res)
		elif (loadType == 2):
			var file = File.new()
			if loadIndex == 0:
				if !file.file_exists("res://Assets/basic-haircut.png"):
					file.open("res://Assets/basic-haircut.png",file.WRITE)
					file.store_buffer(body)
					file.close()
				txtre = load("res://Assets/basic-haircut.png")
			print("2")
			renderBody()

Have you tried to write into the user directory instead?

file.open("user://Assets/basic-haircut.png",file.WRITE) # notice user://
file.store_buffer(body)
file.close()

The reason for the error you’re getting is probably due to the fact that the system doesn’t have access to project folder by default.

I’m having the same issue when trying to write files in project’s directory on export. Seems like it’s ether not possible or is actually a bug.

Related issues:

Mono: Image.Load() doesn't recognize res:// outside of editor · Issue #20972 · godotengine/godot · GitHub

Cannot import any resource from any folder other than res:// · Issue #17848 · godotengine/godot · GitHub

Xrayez | 2018-09-14 14:35

Yeah, it seems to be a bug from the looks of it. I tried changing it to user and it didn’t work.

What i did is put in the absolute path to the file on my HDD, but that wont work on mobile devices right? Hmmm.

OrlanJRod | 2018-09-14 16:58

Yeah it’s better to deal with relative paths for sure… different platforms have various ways of accessing file system. Especially on Android and HTML5, though can’t tell for sure because I’ve never tried to export to these platforms.

If you really need to workaround this, I think you could try using feature tags to determine which platform you’re on, something like that:

if OS.has_feature("Android"):
    # path on mobile device
elif OS.has_feature("HTML5"):
    # path in browser

See the docs on feature tags.

Xrayez | 2018-09-14 17:11