User:Ulti/sandbox: Difference between revisions
Jump to navigation
Jump to search
imported>Ulti No edit summary |
imported>Ulti |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{User:Ulti/Nav|active=sandbox}} | |||
<div style="clear:right;"> | |||
This page is a sandbox used for testing my code before putting it live elsewhere on the wiki | This page is a sandbox used for testing my code before putting it live elsewhere on the wiki | ||
-- | </div> | ||
<div style="margin-bottom: .5em; float: left; padding: .5em 0 .8em 1.4em; background: none; width: auto;">__TOC__</div> | |||
===migrating to ASH from PHP (work in progress)=== | <div style="clear: both;margin: 1em 0 0 0;border: 1px solid #aaa;background-color: #ececf7;padding: 1em;"> | ||
===migrating to ASH from PHP/JavaScript (work in progress)=== | |||
ASH is basically half-ass Java because of feature limitations made specific for interacting with KoL.<br> | ASH is basically half-ass Java because of feature limitations made specific for interacting with KoL.<br> | ||
==Default Function Parameters== | <div style="clear: both;margin: 1em 0 0 0;border: 1px solid #aaa;background-color: #ecfcf4;padding: 1em;"> | ||
====Default Function Parameters==== | |||
In PHP you can define default values for your arguments like so: | In PHP you can define default values for your arguments like so: | ||
<pre> | <pre> | ||
Line 28: | Line 32: | ||
print(helloWorld());//prints "Hello world!" to kolmafia's command line interface. | print(helloWorld());//prints "Hello world!" to kolmafia's command line interface. | ||
</pre> | </pre> | ||
====Simple For Loops==== | |||
In PHP, you write simple for loops like so: | |||
<pre> | |||
for($i=1;$i<=5;$i++) | |||
{ | |||
echo "Loop $i"; | |||
} | |||
</pre> | |||
In Ash you write such loops like so: | |||
<pre> | |||
for i from 1 to 5 | |||
{ | |||
print('Loop '+i); | |||
} | |||
</pre> | |||
====dialog boxes==== | |||
In JavaScript you write: | |||
<pre> | |||
confirm("Are you sure?");//returns true or false depending if the user presses ok or cancel in the popup | |||
</pre> | |||
In ash you write it like so: | |||
<pre> | |||
print(user_confirm("Are you sure?"));//returns true or false depending if the user presses yes or no in the popup | |||
</pre> | |||
</div> | |||
</div> | |||
<div style="clear: both;margin: 1em 0 0 0;border: 1px solid #aaa;background-color: #ececf7;padding: 1em;"> | |||
===new main page for the wiki (work in progress)=== | |||
<pre style="clear: both;margin: 1em 0 0 0;border: 1px solid #aaa;background-color: #ecfcf4;padding: 1em;">New User Help | |||
Installation | |||
Kolmafia Guide | |||
FAQ | |||
How Does Kolmafia Help | |||
Automation | |||
Help with Quests | |||
Basement Diving | |||
Related Links | |||
ASH Scripting | |||
CLI | |||
Language Conventions | |||
Functions | |||
Related Links | |||
Contributing | |||
Java | |||
Compiling from Source | |||
Mafia's Code | |||
Making a patch | |||
Wiki | |||
Editing the Documentation | |||
"To do" List</pre> | |||
</div> |
Latest revision as of 08:59, 16 April 2015
Ulti | Talk | My Contributions | My Sandbox | Nav Bar |
This page is a sandbox used for testing my code before putting it live elsewhere on the wiki
migrating to ASH from PHP/JavaScript (work in progress)
ASH is basically half-ass Java because of feature limitations made specific for interacting with KoL.
Default Function Parameters
In PHP you can define default values for your arguments like so:
function helloWorld($msg='Hello world!') { return $msg; } echo helloWorld();//prints "Hello world!" to the browser
In ASH, default parameters is accomplished like so:
string helloWorld(string msg) { return msg; } string hellowWorld() { string msg='Hello world!'; return helloWorld(msg); } print(helloWorld());//prints "Hello world!" to kolmafia's command line interface.
Simple For Loops
In PHP, you write simple for loops like so:
for($i=1;$i<=5;$i++) { echo "Loop $i"; }
In Ash you write such loops like so:
for i from 1 to 5 { print('Loop '+i); }
dialog boxes
In JavaScript you write:
confirm("Are you sure?");//returns true or false depending if the user presses ok or cancel in the popup
In ash you write it like so:
print(user_confirm("Are you sure?"));//returns true or false depending if the user presses yes or no in the popup
new main page for the wiki (work in progress)
New User Help Installation Kolmafia Guide FAQ How Does Kolmafia Help Automation Help with Quests Basement Diving Related Links ASH Scripting CLI Language Conventions Functions Related Links Contributing Java Compiling from Source Mafia's Code Making a patch Wiki Editing the Documentation "To do" List