How to Systematically Generate a .txt file ?

  • (2 Pages)
  • +
  • 1
  • 2

22 Replies - 970 Views - Last Post: 25 November 2015 - 01:33 PM Rate Topic: -----

#1 MOUVAL   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 25-November 15

How to Systematically Generate a .txt file ?

Posted 25 November 2015 - 07:24 AM

Im an 3D Artist Programming in Unity (C#). It would be awesome if someone could help me:
I need an script that basicly is an list, that would take for ever writing by hand.

How can I create a List like this:
        Part_0000 = GameObject.Find("part_0000");
        Part_0001 = GameObject.Find("part_0001");
        Part_0002 = GameObject.Find("part_0002");
        Part_0003 = GameObject.Find("part_0003");
        Part_0004 = GameObject.Find("part_0004");
        ...
        part_8459 = GameObject.Find("part_8459");



Once I have that, i need to create this (i guess this will be created the same way as the first list):
        Part_0000.SetActive(bool);
        Part_0001.SetActive(bool);
        Part_0002.SetActive(bool);
        Part_0003.SetActive(bool);
        ...
        Part_8459 .SetActive(bool);



Now the tricky part, i have to change every "bool" to true, if it is in this list that i have, else to false:
Part_0000
Part_0002
Part_0004
Part_0005
Part_0008
Part_0009
...


I hope someone could help me out! I have an Mac as well as Windows in case it is done over terminal or such. I am looking forward on hearing from you guys !
Greetings from Germany!

Is This A Good Question/Topic? 0
  • +

Replies To: How to Systematically Generate a .txt file ?

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15272
  • View blog
  • Posts: 61,237
  • Joined: 12-June 08

Re: How to Systematically Generate a .txt file ?

Posted 25 November 2015 - 07:44 AM

I am confused - do you want a list of game objects, some sort of event log, or what?
Was This Post Helpful? 0
  • +
  • -

#3 MOUVAL   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 25-November 15

Re: How to Systematically Generate a .txt file ?

Posted 25 November 2015 - 07:50 AM

View Postmodi123_1, on 25 November 2015 - 07:44 AM, said:

I am confused - do you want a list of game objects, some sort of event log, or what?


I want an list1.txt file that looks like this:
Part_0000 = GameObject.Find("part_0000");
Part_0001 = GameObject.Find("part_0001");
...
part_8459 = GameObject.Find("part_8459");

list2.txt:
Part_0000.SetActive(false);
Part_0001.SetActive(true);
...
Part_8459 .SetActive(false);

*The "true" and "false" are set by an list that i have already that looks like this (everything in the list = true, else = false):
Part_0000
Part_0002
Part_0004
Part_0005
Part_0008
Part_0009


Thanks for the quick answer, i hope you can understand what i need better now !
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15272
  • View blog
  • Posts: 61,237
  • Joined: 12-June 08

Re: How to Systematically Generate a .txt file ?

Posted 25 November 2015 - 07:56 AM

No, that is not clear.

You want your code in a text file? To what end?
Was This Post Helpful? 0
  • +
  • -

#5 MOUVAL   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 25-November 15

Re: How to Systematically Generate a .txt file ?

Posted 25 November 2015 - 08:05 AM

View Postmodi123_1, on 25 November 2015 - 07:56 AM, said:

No, that is not clear.

You want your code in a text file? To what end?


Yes, my code should be an text file, or what ever, because i will copy paste the two lists i need into my c# script.
the functionality doesnt matter, i only want to know for example how to create an list that counts up. instead of writing it by hand:
part1
part2
part3
part4
i want my computer to create that list by me saying: "part" + int++ or what ever.
That would be the first list. But know how, in what language, or by using the terminal, or hpow ever you would create such thing.

the second list i want to create the same way, but this time it must check the .txt file i have, on what to set true or false. the list i have is this:
Part_0000
Part_0002
Part_0004
Part_0005
Part_0008
Part_0009
...and goes on till about Part_8352


is it more clear now ? :/
Was This Post Helpful? 0
  • +
  • -

#6 no2pencil   User is online

  • Professor Snuggly Pants
  • member icon

Reputation: 6821
  • View blog
  • Posts: 31,445
  • Joined: 10-May 07

Re: How to Systematically Generate a .txt file ?

Posted 25 November 2015 - 08:08 AM

Why couldn't the list be created with C#?
Was This Post Helpful? 0
  • +
  • -

#7 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15272
  • View blog
  • Posts: 61,237
  • Joined: 12-June 08

Re: How to Systematically Generate a .txt file ?

Posted 25 November 2015 - 08:10 AM

That's the confusing part - in the Unity project are the C# files.
Was This Post Helpful? 0
  • +
  • -

#8 MOUVAL   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 25-November 15

Re: How to Systematically Generate a .txt file ?

Posted 25 November 2015 - 08:11 AM

View Postno2pencil, on 25 November 2015 - 08:08 AM, said:

Why couldn't the list be created with C#?

Maybe creating it in c# would also work, i dont know. My basic knowledge of programming reminded me of someone using the mac terminal to change all unappropriate words to "****" for example. So i thought that could create my lists and check other lists to create the list i need ....
Was This Post Helpful? 0
  • +
  • -

#9 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15272
  • View blog
  • Posts: 61,237
  • Joined: 12-June 08

Re: How to Systematically Generate a .txt file ?

Posted 25 November 2015 - 08:13 AM

Quote

i only want to know for example how to create an list that counts up. instead of writing it by hand:
part1
part2
part3
part4
i want my computer to create that list by me saying: "part" + int++ or what ever.

At the end of the day the project won't write all the code for you. Typically if you find yourself doing things like "partXXX = whatever()" and XXX is some number 000-900 then you are probably doing things wrong.

If you feel like trudging through then you can either create a small console app to output what you want or just use Excel to do basic string concatenation.
Was This Post Helpful? 0
  • +
  • -

#10 MOUVAL   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 25-November 15

Re: How to Systematically Generate a .txt file ?

Posted 25 November 2015 - 08:14 AM

View Postmodi123_1, on 25 November 2015 - 08:10 AM, said:

That's the confusing part - in the Unity project are the C# files.

Yes, if evereything stays with in unity, that would be great. but i thought that an c# unity script cant check an .txt file on what is in the list or not, to decide on setting true or false. And the c# script would have to create the 8k lines of code and save the new script.
Was This Post Helpful? 0
  • +
  • -

#11 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15272
  • View blog
  • Posts: 61,237
  • Joined: 12-June 08

Re: How to Systematically Generate a .txt file ?

Posted 25 November 2015 - 08:22 AM

I am not sure how to parse what you said there.
Was This Post Helpful? 0
  • +
  • -

#12 MOUVAL   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 25-November 15

Re: How to Systematically Generate a .txt file ?

Posted 25 November 2015 - 08:54 AM

View Postmodi123_1, on 25 November 2015 - 08:22 AM, said:

I am not sure how to parse what you said there.

An console app sounds good! So yes basicly i want an console app to produce an .txt:
"Part_XXXX = GameObject.Find("part_XXXX");"
Where the XXXX is = to the line number. If you could tell me how to do so that would be great!

Once i know how to do that, i want an console app to check the list i have (with parts that should get set to true).
If the for example part0845 existst, change the word "bool" to "true",else change "bool" to "false".

Does that make sence?
Was This Post Helpful? 0
  • +
  • -

#13 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15272
  • View blog
  • Posts: 61,237
  • Joined: 12-June 08

Re: How to Systematically Generate a .txt file ?

Posted 25 November 2015 - 08:55 AM

No.. that makes no sense with respects to *how* you think that is supposed to interact with your Unity project or even _why_.
Was This Post Helpful? 0
  • +
  • -

#14 no2pencil   User is online

  • Professor Snuggly Pants
  • member icon

Reputation: 6821
  • View blog
  • Posts: 31,445
  • Joined: 10-May 07

Re: How to Systematically Generate a .txt file ?

Posted 25 November 2015 - 09:02 AM

50 thousand lines of debugging


Was This Post Helpful? 0
  • +
  • -

#15 MOUVAL   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 25-November 15

Re: How to Systematically Generate a .txt file ?

Posted 25 November 2015 - 09:06 AM

View Postmodi123_1, on 25 November 2015 - 08:55 AM, said:

No.. that makes no sense with respects to *how* you think that is supposed to interact with your Unity project or even _why_.

Okay haha sorry.
To clear one thing up, this has nothing to do with unity, i only need that list as .txt
I need a way to create that list, thats all i need. Those two lists. The one list with all 8000 parts, and the one that tells me what parts should be on or off.
List 1:
Part_0000= GameObject.Find("part_0000");
Part_0001= GameObject.Find("part_0001");
Part_0002= GameObject.Find("part_0002");
a long simple list that just goes on till 8000 for example.

the second one should also just create that list, but decide on setting true or false by checking the long list i have that looks like this:
Part_0000
Part_0001
Part_0002
an very long .txt file.

i just want to know how to create those two lists
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2