Get property: Difference between revisions
Jump to navigation
Jump to search
imported>Bale mNo edit summary |
imported>Eliteofdelete No edit summary |
||
Line 17: | Line 17: | ||
function_description=Looks for a global or appropriate user preference from the saved files (found in your "Settings" directory) and if it finds one that matches, it returns whatever value is stored for that preference.| | function_description=Looks for a global or appropriate user preference from the saved files (found in your "Settings" directory) and if it finds one that matches, it returns whatever value is stored for that preference.| | ||
code1={{CodeSample| | |||
title=Code Samples| | |||
description=The following example adventures at the daily dungeon once a day if the property "_DailyDungeon" is false and the necessary items are gathered. | | |||
code= | |||
<syntaxhighlight> | |||
if (!(to_boolean(get_property("_DailyDungeon")))) { | |||
if (can_interact()) { | |||
cli_execute("find pick-o-matic lockpicks"); | |||
cli_execute("find eleven-foot pole"); | |||
cli_execute("find ring of Detect Boring Doors"); | |||
} | |||
if ((item_amount($item[pick-o-matic lockpicks]) > 0) && (item_amount($item[eleven-foot pole]) > 0) && (item_amount($item[ring of Detect Boring Doors]) > 0)) { | |||
equip($item[ring of Detect Boring Doors]); | |||
set_property("choiceAdventure692", 3); | |||
set_property("choiceAdventure693", 2); | |||
set_property("choiceAdventure690", 2); | |||
set_property("choiceAdventure691", 2); | |||
set_property("choiceAdventure689", 1); | |||
cli_execute("goal set fat loot token"); | |||
adventure(15, $location[The Daily Dungeon]); | |||
set_property("_DailyDungeon", true); | |||
} | |||
else print("You do not have the required items for the Daily Dungeon."); | |||
} | |||
else print("You have already did the daily Dungeon today."); | |||
</syntaxhighlight>| | |||
moreinfo= | |||
Get_property always returns a string which in this example was converted to a boolean. Note: using an underscore before the property name resets the property's value to false each day. | |||
}}| | |||
see_also={{SeeAlso|set_property}}| | see_also={{SeeAlso|set_property}}| |
Revision as of 03:36, 14 January 2015
Function Syntax
string get_property(string prop )
- prop is the property to get
Looks for a global or appropriate user preference from the saved files (found in your "Settings" directory) and if it finds one that matches, it returns whatever value is stored for that preference.
Code Samples
The following example adventures at the daily dungeon once a day if the property "_DailyDungeon" is false and the necessary items are gathered.
if (!(to_boolean(get_property("_DailyDungeon")))) {
if (can_interact()) {
cli_execute("find pick-o-matic lockpicks");
cli_execute("find eleven-foot pole");
cli_execute("find ring of Detect Boring Doors");
}
if ((item_amount($item[pick-o-matic lockpicks]) > 0) && (item_amount($item[eleven-foot pole]) > 0) && (item_amount($item[ring of Detect Boring Doors]) > 0)) {
equip($item[ring of Detect Boring Doors]);
set_property("choiceAdventure692", 3);
set_property("choiceAdventure693", 2);
set_property("choiceAdventure690", 2);
set_property("choiceAdventure691", 2);
set_property("choiceAdventure689", 1);
cli_execute("goal set fat loot token");
adventure(15, $location[The Daily Dungeon]);
set_property("_DailyDungeon", true);
}
else print("You do not have the required items for the Daily Dungeon.");
}
else print("You have already did the daily Dungeon today.");
Get_property always returns a string which in this example was converted to a boolean. Note: using an underscore before the property name resets the property's value to false each day.
CLI Equivalent
The CLI command "get" works similarly.
See Also
Special
If a matching preference is not found, this function returns an empty string.