File Reader Object

About Truespace Archives

These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.

They are retained here for archive purposes only.

File Reader Object // The Garage

1  |  

Post by ProfessorKhaos // Jul 21, 2007, 5:15pm

ProfessorKhaos
Total Posts: 622
pic
Hi all,


As part of another script I'm working on I found it useful to create a "file reader object".


This is based on a script Norm had created not too long ago at the following thread: http://forums1.caligari.com/truespace/showthread.php?t=235


The file reader is meant for text files only. Output is a single string containing all the lines in the file. You can break out the lines again using a split command against '\n' in subsequent stages. Likewise, once the contents have been broken into lines, you could further break them into fields.


I plan to provide some utility scripts for generic breakout of data in the near future.


P.K.

Post by 3dvisuals dude // Jul 21, 2007, 6:09pm

3dvisuals dude
Total Posts: 1703
pic
Hi P.K., thanks for sharing this!

Right off the bat I can think of dozens of possible uses for this script but there's one in particular I'd like to bounce off of you to see what you think of it's potential/practicality in online shared space or offline First Person Navigation.

Délé, as I'm sure you already know, created a very cool little looping elevator script a while ago and posted it here at the forums. After actually riding on the platform in that script as it ran in trueSpace while I was an Avatar in F.P.N., it occurred to me that there was a great deal of potential in using such an "Avatar raising platform" in a much different way than simple looping up and down elevator use.

With the script you have just provided us above, for instance, I suppose it would be possible to have text files containing sequential X-Y-Z Coordinates of a predefined path... (imagine a "flying Carpet" platform here with an Avatar on it:D ) and then after activating a new "Take me up through the Atrium to the 3rd floor window and then out onto the balcony!!!" script via a related button trigger in that scene you could utilize that external textfile of coordinates as matrix input for the relocation of the platform along that predefined path.

Does this make any sense to you? :confused:

- 3dvisuals dude

Post by ProfessorKhaos // Jul 21, 2007, 6:58pm

ProfessorKhaos
Total Posts: 622
pic
Yep! Should be very possible. Not sure how it'd work on truePlace though. Depends if file has to be on server or on everyone's machine. I'd hope for the server.


Actually, wouldn't need the file to do this as long as you had a script to farm out the string of x,y,z coords but a file would allow you to change the path without editing the scene (maybe safer in some cases to do that).

Post by 3dvisuals dude // Jul 21, 2007, 8:14pm

3dvisuals dude
Total Posts: 1703
pic
Yep! Should be very possible. Not sure how it'd work on truePlace though. Depends if file has to be on server or on everyone's machine. I'd hope for the server.

Actually, wouldn't need the file to do this as long as you had a script to farm out the string of x,y,z coords but a file would allow you to change the path without editing the scene (maybe safer in some cases to do that).

EXCELLENT!!!! :banana:

Thanks P.K., I was beginning to think the Magic Carpet idea might get grounded before it ever took off! :D

Now I just have to learn how to use the Link Editor better... http://bestsmileys.com/handicap/2.gif

When I can (and I shudder to think how far away that day may actually be) I plan to purchase Norm's two Turorials so that I can make some of these ideas actually amount to something in shared space for all of us. I'd also like to get that Elevator I designed earlier hooked up (and I understand what to do but not precisely how to do it on that one) and especially that "truePlaces trueRoller" Shared Space Avatar Transport in the Rube Goldberg thread... both these things would be a blast for everybody in a shared space setting. Until I get these Tutorials though, ALL these things will be on hold.:(

...And then there's the Shared Space Submarine I'm building.... but that's definitely a story for another day.;)

Thanks again for the script above, and thanks for inspiring us newbie LE and Script users to hang in there!

- 3dvisuals dude

Post by ProfessorKhaos // Jul 21, 2007, 8:18pm

ProfessorKhaos
Total Posts: 622
pic
Scripting tutorials are a really good way to get your feet wet. Start with Norm's clock tutorial, then try out the procedural animation one by Matthew J. Collins. At the very least, you'll get comfortable with the environment and it's great for controlling objects within your scene.

Post by 3dvisuals dude // Jul 21, 2007, 8:25pm

3dvisuals dude
Total Posts: 1703
pic
Scripting tutorials are a really good way to get your feet wet. You'll at least be comfortable with the environment and it's great for controlling objects within your scene.

Thanks P.K.,

Yeah I definitely plan to get them. Without understanding how to specifically control all the little scene elements of my elaborate imaginative shared space projects I feel like Leonardo Davinci in handcuffs!

I can't wait to actually create what my mind can already imagine.

Soon, I hope!

- 3dvisuals dude

Post by ProfessorKhaos // Jul 22, 2007, 7:23am

ProfessorKhaos
Total Posts: 622
pic
A couple of items:


Updated file reader brick (catches errors for files user can't open)


Comments and blank line dropper brick


The latter allows the user to create data files with comments and blank lines in them for readability. The brick output will boil it down to the data used just by the script (i.e. tables of numbers and such)


Multiple characters can be used to signal a comment line. Comments can be indented with white space and they will still be detected.


As wired below, the act of loading a file will automatically run the comment dropper.

Post by ProfessorKhaos // Jul 22, 2007, 8:19am

ProfessorKhaos
Total Posts: 622
pic
Added a 'tokenize input' feature to the comment droppper brick.


Replaces all white space between words with a single white space character. Leading spaces on the line are ignored.
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn