- Home /
Reading data from text can't get new line
hey so ime trying to read data from some text specificly ive got a plan for a house it looks like this
w= wood
c = carpet
t = tile
[Floor]
, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w,L
, c, c, c, c, c, w, w, c, c, c, c, c, t, t, t,L
, c, c, c, c, c, w, w, c, c, c, c, c, t, t, t,L
, c, c, c, c, c, w, w, c, c, c, c, c, t, t, t,L
, c, c, c, c, c, w, w, c, c, c, c, c, t, t, t,L
, c, c, c, c, c, w, w, c, c, c, c, c, t, t, t,L
, c, c, c, c, c, w, w, c, c, c, c, c, t, t, t,L
, c, c, c, c, c, w, w, c, c, c, c, c, t, t, t,L
, c, c, c, c, c, w, w, c, c, c, c, c, t, t, t,L
, c, c, c, c, c, w, w, c, c, c, c, c, t, t, t,L
but currently when i tell my code to loop back round if it ends a line so basically where theirs an L
it doesn't i think its possibly the enter after the L but ive tried compensating for it and its just not working so hears my code (its near the bottom)
public class BuildHouse : MonoBehaviour {
public int StartX = 0;
public int StartZ = 0;
public int StartY = 0;
public Chunk ChunkData;
public TextAsset HouseFile;
public string Curent = "floor";
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void Build (){
int X = StartX;
int Z = StartZ;
int Y = StartY;
string[] data = HouseFile.text.Split(',');
//print(data.Length);
foreach (string symbol in data){
print(symbol);
if (symbol == "[Objects]"){Curent = "Objects";}
if (symbol == "[Walls]"){Curent = "Walls";}
if (symbol == "[Floor]"){Curent = "Floor";}
if (Curent == "floor"){
if (symbol == " w"){ ChunkData.map[X,Y,Z].FloorID = 1;
print ("XYZ");}
if (symbol == " c"){ ChunkData.map[X,Y,Z].FloorID = 2;}
if (symbol == " t"){ ChunkData.map[X,Y,Z].FloorID = 3;}
ChunkData.UpdateTile(X,Y,Z);
}
X += 1;
if (symbol == "L/n"){ //<-----this is tell it to start a new line
print ("123");
Z += 1;
X = StartX;
}
if (symbol == "[NewLevel]"){Y += 1;}
}
}
}
any help much aprechiated
@Jojo, it's not wise to complain if you don't get an immediate response from people that are helping the community out of the goodness of their heart. It comes across as entitled.
Answer by Julien-Lynge · Apr 13, 2014 at 07:59 PM
@Jojo, I have a little trouble understanding what you're trying to say. You say "it's just not working" - what, exactly, is happening, and what do you expect to happen?
Looking at your code, what jumps out at me immediately is '/n' - this is not a newline character, '\\n' is. '\\' is the escape character.
ye i hive put /n but it doseent seam to register it when it goes through the if statment
Your answer
Follow this Question
Related Questions
Gui text script - help 1 Answer
Reading & Writing to text file After building for iPhone. 2 Answers
House rendering problems? 0 Answers
I need help with my GUI text for my Real Time Strategy Game 0 Answers
How to read the format "Key: Value" 1 Answer