Notifications
Clear all

[Closed] CgTalk Maxscript Challenge 010: "BACK TO BASICS: Random Concept Creator"

CgTalk Maxscript Challenge 010: “BACK TO BASICS: Random Concept Creator”

DESCRIPTION: Create a tool that constructs a sentence from randomly picked words to inspire creations, in a similar vein to the 3CH program.
An example:
A tiny scientist attaches a building site machinery in a submarine.” is constructed from words picked randomly from lists of objects, actions and places.

                 INTERMEDIATE SCRIPTERS: Create a log of previously constructed sentences and display them below the most recent one.
   
           ADVANCED SCRIPTERS: Make the tool user-customisable so they can pick a folder of new lists to generate from.  Make a selectable list of stored themes.
       
                    RULES:  

[ul]
[li]Code from scratch. Try not to use pre-exisitng functions or plugins.[/li][li]Show your script references, if any (eg. Looking at another script to assist you).[/li][li]You are encouraged to ask for help where needed, but try to do it on your own. The maxscript reference is an invaluable resource.[/li][li]Post your final script inside [/li]“`
tags (located on your posting toolbar).
[li]Post all code into THIS thread.[/li][li]Post the max version you coded in, plus any maxscript extensions you used. (Thanks galagast!)[/li][li]Try to finish the challenge in a week. There is no definite time limit.[/li][/ul]NOTES: Sorry for the massive delay in getting a new challenge going. It’s been hectic! Have fun with this one! Although it’s weekly, please continue to work on these challenges once they’ve expired! This challenge is designed to be simple. I’ll post a more complex one when we’re back in the swing.

__________________

9 Replies

Here is my version… haven’t rigourously tested it.
Recognition must go to MV (m@) and hydropix who originally made the lists and to hydropix and vog from CA.org for the original 3CH program. Don’t want to steal their hard work by saying I thought all of this up myself!

TO INSTALL: Just unzip to your scripts folder and run the script.

Here’s the code:


 
 sentenceStructure = #() -- will be used to define the layout of the sentence
 wordLists = #() -- the vrious word files
 themeNames = #() -- theme names
 themeDirs = #()
 fileNum = 0
 
 fn loadTextFile file = 
 (
 	list = openFile(file)
 	lineNum = 0
 	fileArray = #()
 	while (eof list) == false do
 	(
 		lineNum += 1
 		fileArray[lineNum] = readLine(list)
 	)
 	close list 
 	return fileArray
 )
 
 
 
 rollout conceptCreator "Concept Creator - Inspired by 3CH" width:640 height:480
 (
 	dropdownList themeDrop "Concept Theme:"  pos:[21,9] width:248 height:40
 	button loadThemeBtn "..." pos:[276,27] width:36 height:21
 	edittext sentenceBox "" pos:[16,73] width:596 height:23
 	button generateBtn "Generate!" pos:[376,17] width:190 height:36
 	label conceptListLbl "" pos:[19,118] width:592 height:334
 	
 	--open the dialog and set up Defaults and dropdowns
 	on conceptCreator open  do
 	(
 		--load the first theme in the list
 		--
 		themeFolder = scriptsPath + "ConceptCreator\\Themes\\"
 		themeDirs = getDirectories (themeFolder+"*")
 		themeNum = themeDirs.count
 		
 		for i = 1 to themeNum do
 		(
 			themeNames[i] = substring themeDirs[i] (themeFolder.count +1 ) (themeDirs[i].count)  
 			
 		)
 		
 		--insert the theme names into the dropdown list
 		themeDrop.items = themeNames
 		sentenceStructure = loadTextFile (themeFolder + "Default\\" + "structure.txt")
 		fileNum = sentenceStructure.count
 		
 		for i = 1 to fileNum do
 		(
 			wordLists[i] = loadTextFile (themeFolder + "Default\\" + sentenceStructure[i] +".txt")
 		)
 		
 	)
 	
 	on themeDrop selected sel do
 	(
 		index = themeDrop.selection
 		
 		sentenceStructure = loadTextFile (themeDirs[index] + "structure.txt")
 		fileNum = sentenceStructure.count
 		
 		for i = 1 to fileNum do
 		(
 			wordLists[i] = loadTextFile (themeDirs[index] + sentenceStructure[i] +".txt")
 		)
 
 	)
 	
 	on loadThemeBtn pressed do
 	(
 		--do all that funky work
 		--do more
 	)
 	on generateBtn pressed do
 	(
 		sentence = ""
 		for wordPart = 1 to fileNum do
 		(
 			sentence = 	append sentence wordLists[wordPart][(random 1 wordLists[wordPart].count)]
 		)
 		sentence = 	append sentence "."
 		sentenceBox.text = sentence
 		conceptListLbl.text = sentence+ "
" + conceptListLbl.text 
 
 	)
 )
 
 createDialog conceptCreator 
 
 

Haha awesome idea Martin Installing it in a bit to test it

Yep, it be working fine Thanks Martin!

Just realised there’s some redundant code in there… but it still works!

Thanks for testing Urg!

Hey Martin,

Nice concept.

Light

Thanks guys.

Anyone else going to step up to the plate, or will these just be exercises for my own personal amusement?

Looks like there’s my answer.:shrug:

I’ll post up a new one soon guys. If I don’t get much participation next time I may have to consider stopping this.

I won’t be posting… but a really inspirational tool!!! Nice one.

This does sound like a really cool idea. If I had Max while I’m at work, you know I’d participate (I’m bored enough). Sorry!