How would I setup a file to allow me to import different things from it rather than just the whole file at once?
I want to send the player a text line based on the number of a value, and search for that text line from a text file, something like this:
VAR __ LINE
1 Running
2 Jogging
3 Walking
4 Crawling
5 Limping
So that when a certain variable equals 3, it reads the file and returns "Walking"
ID:179784
Nov 7 2001, 9:03 am
|
|
In response to Alathon
|
|
Alathon wrote:
You could create a proc to take in a number and return a text string. Something like this mayby Well this is not really answering his question, since it seems like he wanted specifically to use a text file (though I'm not sure why). In any case, your above example would be a bit awkward with many entries. Better to just use an indexed list: var/action[10] action[1] = "Walking" action[2] = "Running" etc... |
In response to Skysaw
|
|
Ah, yes that slipped past me(I need to hang up a small stick-it or something that reminds me not to do code-related things when im tired)
Oh, I guess I missread it. Alathon |
In response to Skysaw
|
|
Something like that maybe, but how would I get that working from a text file?
And if you need to know I'm doing it this way so I don't have to hard code a whole lot of descriptions, since this is for room descriptions, I want them in text files so I can edit them at a whim and still use them in the game. |
In response to GateGuardian
|
|
Look up file2text(),and mayby some of the file commands(fcopy(), etc)
Alathon |
In response to Alathon
|
|
Is there any place where I can find a working example of that?
|
GateGuardian wrote:
How would I setup a file to allow me to import different things from it rather than just the whole file at once? You might want to work with savefiles. You can translate them to and from text by using the savefile.ImportText() and savefile.ExportText() procs, described in the reference. |
In response to Tom
|
|
You might want to work with savefiles. You can translate them to and from text by using the savefile.ImportText() and savefile.ExportText() procs, described in the reference. But beware... it's tough to get used to. And the currently released version hasn't fixed all of the problems with them yet. |
In response to Spuzzum
|
|
What problems?
|
In response to GateGuardian
|
|
GateGuardian wrote:
What problems? There's a few bugs with parsing the file, with newlines and other illegal characters in text strings. The new test version should be released sometime soon, though. If you aren't working with strings where there's any formatting, you don't need to worry. For example, "blah" will save and load just fine. "Asked the blah, "Blah?"" will not. |
proc/NumToText(number)
switch(number)
if(1) return "Walking"
etc
Alathon