Difference between pages "Daily Deeds" and "Gametime to int"

From Kolmafia
(Difference between pages)
Jump to navigation Jump to search
imported>Roippi
 
imported>Theraze
(Created page with "{{ #vardefine:name|gametime_to_int}}{{ #vardefine:return_type|int}}{{ FunctionPage| name={{#var:name}}| function1={{Function| name={{#var:name}}| aggregate={{#var:aggregate}}| ...")
 
Line 1: Line 1:
Basic daily deed customization allows you to show/hide elements on the daily deeds panel, and to reorder those elements as desired.  More advanced customization features include adding "custom deeds" that can perform a variety of tasks: everything from performing a CLI command, to using an item or casting a skill, to executing ASH scripts.
+
{{
 +
#vardefine:name|gametime_to_int}}{{
 +
#vardefine:return_type|int}}{{
  
== Customizing Daily Deeds ==
+
FunctionPage|
 +
name={{#var:name}}|
  
Daily Deeds customization essentially involves editing a user preference in order to specify the elements shown on the Daily Deeds panel.  Fortunately, a GUI exists to aid you in performing the most common tasks.  This is reached by going to Preferences > Daily Deeds tab.
+
function1={{Function|
 +
name={{#var:name}}|
 +
aggregate={{#var:aggregate}}|
 +
return_type={{#var:return_type}}|
 +
return_also={{#var:return_also}}|
 +
}}|
  
To edit which deeds are shown, look at the bottom of this panel.  Each element represents a line on your Daily Deeds panel.  Many of these are individual buttons; "Breakfast", for example, is a button that simply executes breakfast.  Some deeds are more complicated, such as the "Demon Summoning" deed that adds a combobox filled with your currently known summons.  Still others simply represent informational lines of text displayed by default at the bottom.  You can rearrange these at will by dragging and dropping.  Remove unwanted deeds by pressing the delete key; re-add them by dragging and dropping the appropriate element from the "Built-in Deeds" box up above.
+
function_description=Returns the current KoL game time using milliseconds since rollover.|
  
To start creating custom deeds, click the "add custom" button.  A GUI will pop up which will help you build custom command, item, skill, and/or text deeds.  Combo deeds for now (and likely forever) will need to be hand-coded if you want to use them.
+
code1={{CodeSample|
 +
title=Code Samples|
 +
description=This code will tell you how many MS it took to list the gCLI commands.|
 +
code=
 +
<syntaxhighlight>
 +
int starttime = gametime_to_int();
 +
CLI_EXECUTE("help");
 +
print("It took "+(gametime_to_int()-starttime)+" MS to list all gCLI commands.");
 +
</syntaxhighlight>}}|
 +
}}
  
==== Example ====
+
code2={{CodeSample|
The following image is created by this declaration
+
title=Code Samples|
 +
description=This code will tell you how many MS it has been since KoL's official rollover time.|
 +
code=
 +
<syntaxhighlight>
 +
print("It has been "+gametime_to_int()+" MS since the rollover began.");
 +
</syntaxhighlight>}}|
 +
}}
  
<pre style="white-space:pre-wrap;">
+
code3={{CodeSample|
> get dailyDeedsOptions
+
title=Code Samples|
 +
description=This code will tell you long since KoL's official rollover time began without hitting the server.|
 +
code=
 +
<syntaxhighlight>
 +
print((gametime_to_int() / (86400000 / 24)) + ":" + ((gametime_to_int() / (86400000 / 1440)) % 60))
 +
 +
17:34print("It has been "+(gametime_to_int() / (86400000 / 24)) + ":" + ((gametime_to_int() / (86400000 / 1440)) % 60)+" since the rollover began.");
 +
</syntaxhighlight>}}|
 +
}}
  
$CUSTOM|Text|Demonstration of customized Daily Deeds,$CUSTOM|Text|//\\//\\//\\ by Roippi //\\//\\//\\,$CUSTOM|Text| ,$CUSTOM|Text|This is a built-in deed:,VIP Pool,$CUSTOM|Text|So is this:,April Shower,$CUSTOM|Text| ,$CUSTOM|Text|This is a custom "Command" button that tracks a preference (hermitHax0red),$CUSTOM|Text|If/when hermitHax0red is true,| this deed is greyed out.,$CUSTOM|Text|When clicked|,| it gets clovers.,$CUSTOM|Command|Is the hermit hax0red?|hermitHax0red|hermit * clover,$CUSTOM|Text| ,$CUSTOM|Text|This is a custom line of text that also tracks some preferences:,$CUSTOM|Text|I've ascended |knownAscensions| times. My last adventure was in zone: |lastAdventure,$CUSTOM|Text| ,$CUSTOM|Text|This is a "Skill" type button. It has a few uses,| but usually tracks a multi-use skill with an arbitrary limit:,$CUSTOM|Skill|get me some BRICKOs|libramSummons|summon brickos|7,$CUSTOM|Text| ,$CUSTOM|Text|Lastly,| here is a multiple Command deed.,$CUSTOM|Text|You define the displayText,| an int preference,| the button command,| and the preference disabling threshold.,$CUSTOM|Text|It is up to you to make the preference track whatever your button is doing.,$CUSTOM|Command|Run my custom ASH script up to 5 times|_farmingLoops|call farm.ash|5,$CUSTOM|Text| ,$CUSTOM|Text|You can define your own preferences and call ash scripts with your button commands.,$CUSTOM|Text|I haven't demonstrated all of the different types and overloaded variants here,| but this should be a good starting place.,$CUSTOM|Text|Have fun.
+
code4={{CodeSample|
</pre>
+
title=Code Samples|
 +
description=This code will tell you how many MS it has been since KoL's official rollover time.|
 +
code=
 +
<syntaxhighlight>
 +
print("You have "+(23 - (gametime_to_int() / (86400000 / 24)))+":"+(59 - ((gametime_to_int() / (86400000 / 1440)) % 60))+" left until rollover begins.")
 +
</syntaxhighlight>}}|
 +
}}
  
: [[File:Ddprefs3.JPG]]
+
{{SeeAlso|today_to_string|gameday_to_int|gameday_to_string|time_to_string|now_to_string}}
  
 
+
[[Category:Miscellaneous Functions]]
== Custom Deeds ==
 
 
 
All deeds are specified by one comma-delimited preference "dailyDeedsOptions". Order matters. Built-in deeds are simply called by referring to their built-in name; these are viewable by pulling up the Daily Deeds tab and looking in the "Built-in Deeds" list. In the source code these can be found in DailyDeedsPanel.BUILTIN_DEEDS.
 
 
 
Custom deeds provide the user with a way of adding buttons or text to their daily deeds panel that is not natively provided for. All deeds start with the keyword '''$CUSTOM''' followed by a pipe symbol, '''|'''. As you are constructing a custom deed, you separate the different arguments with pipes.
 
 
 
All deed types except for Text require a preference to track. If you want to add a button that is always enabled, use a dummy preference (you do not have to create one, just specify one that doesn't exist, such as "false").
 
 
 
There are currently 5 different types of custom deeds. Remember that all of these "acceptable forms" are prefaced by $CUSTOM|.
 
 
 
==== Command ====
 
execute a command with a button press
 
 
 
acceptable forms:
 
 
 
Command|displayText|preference
 
 
 
Command|displayText|preference|command
 
 
 
Command|displayText|preference|command|maxUses
 
 
 
*displayText - the text that will be displayed on the button
 
*preference - the preference to track for enabling/disabling the button.  Default threshold for disabling the button is 1 if maxUses is not specified.
 
*command - the command to execute. If not specified, will default to displayText.
 
*maxUses - an arbitrary integer. Specifies a threshold to disable the button at. A counter in the form of <preference>/<maxUses> will be displayed to the right of the button.
 
 
 
==== Item ====
 
this button will use fuzzy matching to find the name of the item specified. Will execute "use <itemName>" when clicked. Will only be visible when you possess one or more of the item.
 
 
 
acceptable forms:
 
 
 
BooleanItem|displayText|preference
 
 
 
BooleanItem|displayText|preference|itemName
 
 
 
Item|displayText|preference|itemName|maxUses
 
 
 
*itemName - the name of the item that will be used. If not specified, will default to displayText.
 
 
 
==== Skill ====
 
cast a skill that is tracked by a boolean or int preference. Will execute "cast <skillName>" when clicked.  Will not be visible if you don't know the skill.
 
 
 
acceptable forms:
 
 
 
Skill|displayText|preference
 
 
 
Skill|displayText|preference|skillName
 
 
 
Skill|displayText|preference|skillName|maxCasts
 
 
 
*preference - the preference to track for enabling/disabling the button.  Default threshold for disabling the button is 1 if maxCasts is not specified.
 
*skillName- the name of the skill that will be cast. If not specified, will default to displayText. Must be specified if maxCasts are specified.
 
*maxCasts - an arbitrary integer. Specifies a threshold to disable the button at. A counter in the form of <preference>/<maxCasts> will be displayed to the right of the button.
 
 
 
 
 
==== Combo ====
 
 
 
$CUSTOM|Combo|displayText|preference1|<item block>
 
 
 
$CUSTOM|Combo|displayText|preference1|maxUses|<item block>
 
 
 
 
 
where the <item block> consists of an arbitrary number of:
 
 
 
$ITEM|displayText|preferenceN|command|
 
 
 
This is a cleaner way of collapsing a number of related command deeds into one combobox element.  Note that there is no GUI to help you construct this, you must manually add it to your dailyDeedsOptions preference.
 
 
 
*Preference1 - The preference to track for enabling/disabling the '''entire combobox'''.  Default threshold is 1 if maxUses is not specified.
 
*Preference2 - The individual preference to disable each individual item in the combobox.  Note that there is no way to supply maxUses for each individual element; 1 (or true) is always the max.
 
 
 
A common use of this deed is to create a custom Greatest American Pants combobox:
 
 
 
<pre style="white-space:pre-wrap;">
 
$CUSTOM|Combo|GAPants|_gapBuffs|5|$ITEM|free spells|false|equip greatampant; gap skill|$ITEM|elem & tough|false|equip greatampant; gap structure|$ITEM|+25%ItemD|false|equip greatampant; gap vision|$ITEM|+100%Mox|false|equip greatampant; gap speed|$ITEM|5xCrit|false|equip greatampant; gap accuracy</pre>
 
 
 
[[File:GAPdeed.png]]
 
 
 
==== Text ====
 
 
 
acceptable forms:
 
Text|pretty much anything.
 
 
 
You can supply as many arguments as you want to a Text deed. Any argument that uniquely matches a preference will be replaced by that preference's value. If you want to use a comma in your text, immediately follow the comma with a pipe character so it will not be parsed as the end of the Text deed.
 
 
 
[[Category:Tech Support]]
 

Revision as of 16:16, 9 July 2011

Function Syntax

int gametime_to_int()

Returns the current KoL game time using milliseconds since rollover.

Code Samples

This code will tell you how many MS it took to list the gCLI commands.

int starttime = gametime_to_int();
CLI_EXECUTE("help");
print("It took "+(gametime_to_int()-starttime)+" MS to list all gCLI commands.");


code2=

Code Samples

This code will tell you how many MS it has been since KoL's official rollover time.

print("It has been "+gametime_to_int()+" MS since the rollover began.");

| }}

code3=

Code Samples

This code will tell you long since KoL's official rollover time began without hitting the server.

print((gametime_to_int() / (86400000 / 24)) + ":" + ((gametime_to_int() / (86400000 / 1440)) % 60))
 
17:34print("It has been "+(gametime_to_int() / (86400000 / 24)) + ":" + ((gametime_to_int() / (86400000 / 1440)) % 60)+" since the rollover began.");

| }}

code4=

Code Samples

This code will tell you how many MS it has been since KoL's official rollover time.

print("You have "+(23 - (gametime_to_int() / (86400000 / 24)))+":"+(59 - ((gametime_to_int() / (86400000 / 1440)) % 60))+" left until rollover begins.")

| }}

See Also

today_to_string() | gameday_to_int() | gameday_to_string() | time_to_string() | now_to_string()