Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to add custom data files to Roblox DataModel?

Asked by
doomiiii 112
7 years ago

I also asked this question in this StackOverflow post (where I am more likely to actually see an answer, because I am not checking this site or my related e-mail very often):

I don't seem to be able to add textual data (e.g. in CSV, JSON or XML files) to the Roblox DataModel, Workspace, ServerStorage or anywhere really?

Any hints on how to do this efficiently? Ideally, Roblox should just give me the contents of the file as a table. But if there is a way to get a raw string from a file that I have to parse manually, I could cope, too.

0
you will have to decode it sorry EssentialRoll 30 — 7y
0
@EssentialRoll, that's fine with me - But how do I actually add text to my project? Is there any text file format, other than scripts? Can I somehow import raw text data into my project that I can then access with Lua? doomiiii 112 — 7y
0
A StringValue can let you store text in it, and then access it later. Just keep in mind that it has a limited data size. shayner32 478 — 7y

1 answer

Log in to vote
0
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
7 years ago

Unfortunately, there is no file format other than scripts for text. However, Lua has a nice way to create multiline literals:

[[Hello World!
This is a multiline string literal
Neat eh?]]

So you could just copy paste the text file directly into a Roblox script. I suggest using a Module script as you could do something like this to conveniently retrieve the string:

Module Script:

return function() return [[

This is where 
the text would go

]] end

Requiring Script:

-- Given the module is named ModuleScript and is parented to workspace
local text = require(game.Workspace.ModuleScript)()
Ad

Answer this question