{"id":723,"date":"2015-12-29T01:40:27","date_gmt":"2015-12-28T17:40:27","guid":{"rendered":"http:\/\/konsolscript.sourceforge.net\/web\/?p=723"},"modified":"2015-12-29T01:46:24","modified_gmt":"2015-12-28T17:46:24","slug":"exploring-konsolscript","status":"publish","type":"post","link":"http:\/\/konsolscript.sourceforge.net\/web\/2015\/12\/29\/exploring-konsolscript\/","title":{"rendered":"Tutorial 5: Exploring KonsolScript"},"content":{"rendered":"<p>From the <a href=\"http:\/\/konsolscript.sourceforge.net\/web\/2015\/11\/08\/understanding-konsolscript\/\">previous tutorial<\/a>, we&#8217;ve already tried understanding what&#8217;s written inside the sample code.  In this tutorial, we will try to understand the files created along side our sample code &#8220;<strong>helloworld.ks<\/strong>&#8221; &#8212; namely, <strong><em>helloworld.konsl<\/em><\/strong> and <strong><em>ks.log<\/em><\/strong> files.<\/p>\n<p>What are they for?<\/p>\n<h2>helloworld.konsl<\/h2>\n<p>The <strong>.KONSL<\/strong> file is basically the processed file which stores the codes you have written in the <em>KS<\/em> file.  Once the KonsolScript runtime is done reading your codes from your KS file, the KonsolScript runtime starts to dump all the information it read to a new file that ends with <em>.KONSL<\/em>.<\/p>\n<p>Ideally, this KONSL file is what you, as the creator of a KonsolScript-written game, should give to your friends, because the mechanics of your game is hidden inside the KONSL file &#8212; any non-technical friend of yours will find it hard to edit your game!<\/p>\n<p>But if you are working with a friend to create your game, it&#8217;s better to share the KS file so he\/she might be able to help finishing\/fixing the game. \ud83d\ude09<\/p>\n<h2>ks.log<\/h2>\n<p>KS.LOG is basically a log file which logs all necessary information.  It is also helpful for you to log whatever is happening to your game in the log file by using  the <strong><code>Konsol:Log<\/code><\/strong> command &#8212; example: <strong><\/p>\n<pre>function main() {\r\n  Konsol:Log(\"logging this command\")\r\n}<\/pre>\n<p><\/strong><\/p>\n<p>When you run your code with the addition showed above, you can start looking for the line &#8220;<em>logging this command<\/em>&#8221; written on KS.LOG.<\/p>\n<p>Also, to let you in on a little secret, check what&#8217;s written in the log file just below the line: <em>Implementing Table Look-Up<\/em><\/p>\n<p>You will see something like:<\/p>\n<pre>Implementing Numbers\r\n\tWarning: ... is unused.\r\n\t...\r\nImplementing Strings\r\n\tWarning: ... is unused.\r\nImplementing Booleans\r\n\tWarning: ... is unused.\r\n\t...<\/pre>\n<p>Basically, these are variables that KonsolScript runtime is aware of but is not currently used in your code.  Let&#8217;s try using the Number variables <strong>mouseX<\/strong> and <strong>mouseY<\/strong>.<\/p>\n<p><strong><\/p>\n<pre>function cleanrender() {\r\n  Screen:PrintString(\"x: \" + mouseX + \" y: \" + mouseY)\r\n}<\/pre>\n<p><\/strong><\/p>\n<p>Running your updated code will show the X and Y coordinates of the mouse in relation to the screen.<\/p>\n<h2>Built-in Numbers<\/h2>\n<p> Below are mostly read-only Number variables; the runtime is the one setting the value of these variables:<\/p>\n<p><strong>lastpress<\/strong> &#8212; the key code of the last pressed key on the keyboard, 0 if not applicable.<br \/>\n<strong>lastunpress<\/strong> &#8212; the key code of the last unpressed key on the keyboard, 0 if not applicable.<br \/>\n<strong>screenwidth<\/strong> &#8212; the width of the screen.<br \/>\n<strong>screenheight<\/strong> &#8212; the height of the screen.<br \/>\n<strong>textwidth<\/strong> &#8212; the width of a single letter on the screen.<br \/>\n<strong>textheight<\/strong> &#8212; the height of a single letter on the screen.<br \/>\n<strong>cursorX<\/strong> &#8212; x location of where the screen will print the text.<br \/>\n<strong>cursorY<\/strong> &#8212; y location of where the screen will print the text.<br \/>\n<strong>mouseX<\/strong> &#8212; x location of the mouse on the screen.<br \/>\n<strong>mouseY<\/strong> &#8212; y location of the mouse on the screen.<\/p>\n<h2>Built-in Booleans<\/h2>\n<p> Below are read-only Boolean variables:<\/p>\n<p><strong>B1<\/strong> &#8212; short for Button 1; set to TRUE when ESCAPE key from keyboard is pressed.<br \/>\n<strong>B2<\/strong> &#8212; short for Button 2; set to TRUE when CONTROL key from keyboard is pressed.<br \/>\n<strong>B3<\/strong> &#8212; short for Button 3; set to TRUE when ENTER\/RETURN key from keyboard is pressed.<br \/>\n<strong>B4<\/strong> &#8212; short for Button 4; set to TRUE when SPACE key from keyboard is pressed.<br \/>\n<strong>BU<\/strong> &#8212; short for Button Up; set to TRUE when ARROW UP key from keyboard is pressed.<br \/>\n<strong>BD<\/strong> &#8212; short for Button Down; set to TRUE when ARROW DOWN key from keyboard is pressed.<br \/>\n<strong>BL<\/strong> &#8212; short for Button Left; set to TRUE when ARROW LEFT key from keyboard is pressed.<br \/>\n<strong>BR<\/strong> &#8212; short for Button Right; set to TRUE when ARROW RIGHT key from keyboard is pressed.<br \/>\n<strong>LMB<\/strong> &#8212; short for Left Mouse Button; set to TRUE when LEFT MOUSE button from mouse is pressed.<br \/>\n<strong>MMB<\/strong> &#8212; short for Middle Mouse Button; set to TRUE when MIDDLE MOUSE button from mouse is pressed.<br \/>\n<strong>RMB<\/strong> &#8212; short for Right Mouse Button; set to TRUE when RIGHT MOUSE button from mouse is pressed.<\/p>\n<p>If any of the buttons above is unpressed the value is set to FALSE.<\/p>\n<p>I guess, that wraps up the Basics!  I&#8217;ll be drafting what&#8217;s to discuss in Intermediate Tutorial Series soon and hopefully get it done soon!  Hopefully next week. Hopefully tomorrow. \ud83d\ude42<\/p>\n<p>~creek23<\/p>\n","protected":false},"excerpt":{"rendered":"<p>From the previous tutorial, we&#8217;ve already tried understanding what&#8217;s written inside the sample code. In this tutorial, we will try to understand the files created along side our sample code &#8220;helloworld.ks&#8221; &#8212; namely, helloworld.konsl and ks.log files. What are they for? helloworld.konsl The .KONSL file is basically the processed file which stores the codes you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"_links":{"self":[{"href":"http:\/\/konsolscript.sourceforge.net\/web\/wp-json\/wp\/v2\/posts\/723"}],"collection":[{"href":"http:\/\/konsolscript.sourceforge.net\/web\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/konsolscript.sourceforge.net\/web\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/konsolscript.sourceforge.net\/web\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/konsolscript.sourceforge.net\/web\/wp-json\/wp\/v2\/comments?post=723"}],"version-history":[{"count":12,"href":"http:\/\/konsolscript.sourceforge.net\/web\/wp-json\/wp\/v2\/posts\/723\/revisions"}],"predecessor-version":[{"id":734,"href":"http:\/\/konsolscript.sourceforge.net\/web\/wp-json\/wp\/v2\/posts\/723\/revisions\/734"}],"wp:attachment":[{"href":"http:\/\/konsolscript.sourceforge.net\/web\/wp-json\/wp\/v2\/media?parent=723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/konsolscript.sourceforge.net\/web\/wp-json\/wp\/v2\/categories?post=723"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/konsolscript.sourceforge.net\/web\/wp-json\/wp\/v2\/tags?post=723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}