[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34957] trunk/blender/source/gameengine/ Expressions: BGE Expressions: convert "\n" to real \n

Dalai Felinto dfelinto at gmail.com
Fri Feb 18 11:10:49 CET 2011


Revision: 34957
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34957
Author:   dfelinto
Date:     2011-02-18 10:10:48 +0000 (Fri, 18 Feb 2011)
Log Message:
-----------
BGE Expressions: convert "\n" to real \n
example of usage:

0) Game Properties: text (String) and log (Boolean=True)
1) Keyboard Sensor set to AllKeys with log as logging and text as Target
2) Expression Controller: text=="quit\n"
3) Game Actuator: Quit Game

[1] <-> [2] <-> [3] .:. this will quit the game when you write quit + Enter

4) Keyboard Sensor: set to Return
5) And Controller
6) Property Actuator: Assign text property to "" 

[4] <-> [5] <-> [6] .:. this will reset the string everytime you press Enter

# # # # # # # # # # # # # # # # # # # # # # # 
Since the change is in the InputParser.cpp it actually affects all the text
input fields in the Logic Editor. So for instance you can use it in the
assign Property Actuator.
# # # # # # # # # # # # # # # # # # # # # # #
Connect an expression controller: text="idclip\n" with an actuator to disable
the Collision of your walls and you can re-create Doom with only Logic Bricks (:

Modified Paths:
--------------
    trunk/blender/source/gameengine/Expressions/InputParser.cpp
    trunk/blender/source/gameengine/Expressions/InputParser.h

Modified: trunk/blender/source/gameengine/Expressions/InputParser.cpp
===================================================================
--- trunk/blender/source/gameengine/Expressions/InputParser.cpp	2011-02-18 09:39:15 UTC (rev 34956)
+++ trunk/blender/source/gameengine/Expressions/InputParser.cpp	2011-02-18 10:10:48 UTC (rev 34957)
@@ -151,6 +151,28 @@
 
 
 
+void CParser::GrabRealString(int start)
+{
+	// works like GrabString but converting \\n to \n
+	// puts part of the input string into the global variable
+	// const_as_string, from position start, to position chchount
+
+	int i;
+	char tmpch;
+
+	const_as_string = STR_String();
+	for (i=start;i<chcount;i++) {
+		tmpch= text[i];
+		if ((tmpch =='\\') && (text[i+1] == 'n')){
+			tmpch = '\n';
+			i++;
+		}
+		const_as_string += tmpch;
+	}
+}
+
+
+
 void CParser::NextSym()
 {
 	// sets the global variable sym to the next symbol, and
@@ -244,7 +266,7 @@
 		start = chcount;
 		while ((ch != '\"') && (ch != 0x0))
 			NextCh();
-		GrabString(start);
+		GrabRealString(start);
 		TermChar('\"');	// check for eol before '\"'
 		break;
 				}

Modified: trunk/blender/source/gameengine/Expressions/InputParser.h
===================================================================
--- trunk/blender/source/gameengine/Expressions/InputParser.h	2011-02-18 09:39:15 UTC (rev 34956)
+++ trunk/blender/source/gameengine/Expressions/InputParser.h	2011-02-18 10:10:48 UTC (rev 34957)
@@ -93,6 +93,7 @@
 	void DigRep();
 	void CharRep();
 	void GrabString(int start);
+	void GrabRealString(int start);
 	void NextSym();
 #if 0	/* not used yet */
 	int MakeInt();




More information about the Bf-blender-cvs mailing list