Print Text and Values to Console(scripting): Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
 
Line 5: Line 5:
==Print to Console==
==Print to Console==


sys.print()
sys.print()
 
sys.println()
sys.println()


To send text or values or string or numeric variables to the console use:
To send text or values or string or numeric variables to the console use:
Line 29: Line 28:
  sys.print(3*4+x/2);
  sys.print(3*4+x/2);


sys.println appears to do the same as sys.print - even numeric calculations. Possibly intended for printer output but by default sent to the console?
sys.println does the same as sys.print but conveniently appends a line break at the end.
 
 


{{editorial}} {{scripting}}
{{editorial}} {{scripting}}

Latest revision as of 22:50, 28 December 2008

Print Text and Values to Console(scripting)

written by Fidcal

Print to Console

sys.print()
sys.println()

To send text or values or string or numeric variables to the console use:

sys.print(data1+data2+data3...);

...where 'data' is separated by plus signs and can be:

  • A string of characters within double quote marks
  • A numeric value
  • A string or numeric variable
  • Any legal calculation or expression such as 3*4+2
  • Any combination of the above, separated by plus signs (but numeric values will be added so 3+5 will display as 8 not 35)

Use \n within double quotes to force a linefeed, eg, "Line1\nLine2"

Examples:

sys.print("\n\nYour script is running");
sys.print("\n"+x+" green bottles");
sys.print(99);
sys.print(3*4+x/2);

sys.println does the same as sys.print but conveniently appends a line break at the end.

Template:Editorial