* Fixed the "can't interact with the world" glitch. Turns out it was my fault. :)

* Restored the resource pool (and cleaned up the JS interface to it ...
array and counters are updated in one spot (wrapper functions to
add/deduct/define), without need for constant refresh).
* Added crude boxes in game setup to enter initial resource value.
* The command buttons still don't work when clicked (and clicking
continues to be erratic, only triggering if hammering the mouse button
... I think it's related to the return function() hack Philip set up),
but that's next on the list. :)
* Oh, and the command buttons don't currently realign to the different
corners with Alt+G, but all the rest should.

This was SVN commit r2715.
This commit is contained in:
Acumen 2005-09-14 00:50:25 +00:00
parent 093e5c2519
commit 4ab25c7274
7 changed files with 309 additions and 109 deletions

View File

@ -95,13 +95,16 @@ function entity_event_gather( evt )
if( evt.target.traits.supply.max > 0 )
{
if( evt.target.traits.supply.curr <= gather_amt )
{
if( evt.target.traits.supply.curr <= gather_amt )
{
gather_amt = evt.target.traits.supply.curr;
evt.target.kill();
}
evt.target.traits.supply.curr -= gather_amt;
this.player.resource[evt.target.traits.supply.type.toString().toUpperCase()] += gather_amt;
}
// Remove amount from target.
evt.target.traits.supply.curr -= gather_amt;
// Add extracted resources to player's resource pool.
getGUIGlobal().giveResources(evt.target.traits.supply.type.toString(), parseInt(gather_amt));
}
}
@ -160,17 +163,22 @@ function entity_event_takesdamage( evt )
}
// If the fallen is worth any loot,
if (this.traits.loot && (this.traits.loot.food || this.traits.loot.wood || this.traits.loot.stone || this.traits.loot.ore))
if (this.traits.loot)
{
// Give the inflictor his resources.
if (this.traits.loot.food)
getGUIGlobal().GiveResources("Food", parseInt(this.traits.loot.food));
if (this.traits.loot.wood)
getGUIGlobal().GiveResources("Wood", parseInt(this.traits.loot.wood));
if (this.traits.loot.stone)
getGUIGlobal().GiveResources("Stone", parseInt(this.traits.loot.stone));
if (this.traits.loot.ore)
getGUIGlobal().GiveResources("Ore", parseInt(this.traits.loot.ore));
// Cycle through all loot on this entry.
pool = this.traits.loot;
for( loot in pool )
{
switch( loot.toString().toUpperCase() )
{
default:
// Give the inflictor his resources.
getGUIGlobal().giveResources( loot.toString(), parseInt(pool[loot]) );
// Notify player.
console.write ("Spoils of war! " + pool[loot] + " " + loot.toString() + "!");
break;
}
}
}
// Notify player.
@ -372,9 +380,9 @@ function attempt_add_to_build_queue( entity, create_tag, list, tab )
break;
default:
// Deduct the given quantity of resources.
localPlayer.resource[resource.toString().toUpperCase()] -= pool[resource].cost;
getGUIGlobal().deductResources(resource.toString(), parseInt(pool[resource].cost));
console.write("Spent " + pool[resource].cost + " " + resource + ".");
console.write("Spent " + pool[resource].cost + " " + resource + " to purchase " + entity.traits.id.generic);
break;
}
}

View File

@ -523,6 +523,74 @@
]]></action>
</object>
<!--
==========================================
- RESOURCES
==========================================
-->
<object name="pgSessionSetupResourceGroup"
type="image"
style="wheatBorderBlack"
size="100%-200 0%+165 100%-10 0%+300"
>
<object name="pgSessionSetupResourceFoodLabel"
type="text"
style="wheatTextLabelBlack"
size="0%+5 0%+5 40%-5 25%-5"
>Food:
</object>
<object name="pgSessionSetupResourceFoodCounter"
type="input"
style="wheatBorderBlack"
size="60%+5 0%+5 100%-5 25%-5"
>1000
</object>
<object name="pgSessionSetupResourceWoodLabel"
type="text"
style="wheatTextLabelBlack"
size="0%+5 25%+5 40%-5 50%-5"
>Wood:
</object>
<object name="pgSessionSetupResourceWoodCounter"
type="input"
style="wheatBorderBlack"
size="60%+5 25%+5 100%-5 50%-5"
>1000
</object>
<object name="pgSessionSetupResourceStoneLabel"
type="text"
style="wheatTextLabelBlack"
size="0%+5 50%+5 40%-5 75%-5"
>Stone:
</object>
<object name="pgSessionSetupResourceStoneCounter"
type="input"
style="wheatBorderBlack"
size="60%+5 50%+5 100%-5 75%-5"
>1000
</object>
<object name="pgSessionSetupResourceOreLabel"
type="text"
style="wheatTextLabelBlack"
size="0%+5 75%+5 40%-5 100%-5"
>Ore:
</object>
<object name="pgSessionSetupResourceOreCounter"
type="input"
style="wheatBorderBlack"
size="60%+5 75%+5 100%-5 100%-5"
>1000
</object>
</object>
<!--
==========================================
- MAIN MENU - BUTTONS

View File

@ -45,6 +45,86 @@
]]></action>
</object>
<!-- GROUP: RESOURCE COUNTER -->
<object name="snResourceCounter"
hotkey="resourcepool.toggle"
>
<action on="Press"><![CDATA[
guiToggle(this.name);
]]></action>
<object name="snResourceCounter_Food"
style="resource_counter"
type="button"
sprite="resource_food_counter"
tooltip="Food, plus some word-wrapping: Material, usually of plant or animal origin, that contains or consists of essential body nutrients, such as carbohydrates, fats, proteins, vitamins, or minerals, and is ingested and assimilated by an organism to produce energy, stimulate growth, and maintain life."
>
<action on="Load"><![CDATA[
addCrd (this.name, rb, 50, 0, -200, 4, snConst.MiniIcon.Width+54, snConst.MiniIcon.Height);
addCrd (this.name, lb, 50, 0);
addCrd (this.name, lt, 50, 100);
addCrd (this.name, rt, 50, 100);
]]></action>
</object>
<object name="snResourceCounter_Wood"
style="resource_counter"
type="button"
sprite="resource_wood_counter"
tooltip="Wood"
>
<action on="Load"><![CDATA[
addCrd (this.name, rb, 50, 0, Crd[Crd.last].coord[rb].x+Crd[Crd.last].coord[rb].width+5, Crd[Crd.last].coord[rb].y, Crd[Crd.last].coord[rb].width, Crd[Crd.last].coord[rb].height);
addCrd (this.name, lb, 50, 0);
addCrd (this.name, lt, 50, 100);
addCrd (this.name, rt, 50, 100);
]]></action>
</object>
<object name="snResourceCounter_Stone"
style="resource_counter"
type="button"
sprite="resource_stone_counter"
tooltip="Stone"
>
<action on="Load"><![CDATA[
addCrd (this.name, rb, 50, 0, Crd[Crd.last].coord[rb].x+Crd[Crd.last].coord[rb].width+5, Crd[Crd.last].coord[rb].y, Crd[Crd.last].coord[rb].width, Crd[Crd.last].coord[rb].height);
addCrd (this.name, lb, 50, 0);
addCrd (this.name, lt, 50, 100);
addCrd (this.name, rt, 50, 100);
]]></action>
</object>
<object name="snResourceCounter_Ore"
style="resource_counter"
type="button"
sprite="resource_ore_counter"
tooltip="Wood"
>
<action on="Load"><![CDATA[
addCrd (this.name, rb, 50, 0, Crd[Crd.last].coord[rb].x+Crd[Crd.last].coord[rb].width+5, Crd[Crd.last].coord[rb].y, Crd[Crd.last].coord[rb].width, Crd[Crd.last].coord[rb].height);
addCrd (this.name, lb, 50, 0);
addCrd (this.name, lt, 50, 100);
addCrd (this.name, rt, 50, 100);
]]></action>
</object>
<object name="snResourceCounter_Population"
style="resource_counter"
type="button"
sprite="resource_population_counter"
tooltip="Population"
>
<action on="Load"><![CDATA[
addCrd (this.name, rb, 50, 0, Crd[Crd.last].coord[rb].x+Crd[Crd.last].coord[rb].width+5, Crd[Crd.last].coord[rb].y, Crd[Crd.last].coord[rb].width+9, Crd[Crd.last].coord[rb].height);
addCrd (this.name, lb, 50, 0);
addCrd (this.name, lt, 50, 100);
addCrd (this.name, rt, 50, 100);
]]></action>
</object>
</object>
<!-- GROUP: STATUS PANE -->
<object name="snStatusPane"
hotkey="session.statuspane.toggle"
@ -85,7 +165,8 @@
<!-- COMMAND BUTTONS (arc the Status Pane) -->
<object name="snStatusPaneCommand1_1"
type="button"
/>
>
</object>
<object name="snStatusPaneCommandGroup1" >
<object type="button" name="snStatusPaneCommand1_2" />
<object type="button" name="snStatusPaneCommand1_3" />
@ -99,7 +180,9 @@
<object type="button" name="snStatusPaneCommand1_11" />
<object type="button" name="snStatusPaneCommand1_12" />
</object>
<object type="button" name="snStatusPaneCommand2_1" />
<object name="snStatusPaneCommand2_1"
type="button"
/>
<object name="snStatusPaneCommandGroup2" >
<object type="button" name="snStatusPaneCommand2_2" />
<object type="button" name="snStatusPaneCommand2_3" />
@ -113,7 +196,9 @@
<object type="button" name="snStatusPaneCommand2_11" />
<object type="button" name="snStatusPaneCommand2_12" />
</object>
<object type="button" name="snStatusPaneCommand3_1" />
<object name="snStatusPaneCommand3_1"
type="button"
/>
<object name="snStatusPaneCommandGroup3" >
<object type="button" name="snStatusPaneCommand3_2" />
<object type="button" name="snStatusPaneCommand3_3" />
@ -127,7 +212,9 @@
<object type="button" name="snStatusPaneCommand3_11" />
<object type="button" name="snStatusPaneCommand3_12" />
</object>
<object type="button" name="snStatusPaneCommand4_1" />
<object name="snStatusPaneCommand4_1"
type="button"
/>
<object name="snStatusPaneCommandGroup4" >
<object type="button" name="snStatusPaneCommand4_2" />
<object type="button" name="snStatusPaneCommand4_3" />
@ -141,7 +228,9 @@
<object type="button" name="snStatusPaneCommand4_11" />
<object type="button" name="snStatusPaneCommand4_12" />
</object>
<object type="button" name="snStatusPaneCommand5_1" />
<object name="snStatusPaneCommand5_1"
type="button"
/>
<object name="snStatusPaneCommandGroup5" >
<object type="button" name="snStatusPaneCommand5_2" />
<object type="button" name="snStatusPaneCommand5_3" />
@ -155,7 +244,9 @@
<object type="button" name="snStatusPaneCommand5_11" />
<object type="button" name="snStatusPaneCommand5_12" />
</object>
<object type="button" name="snStatusPaneCommand6_1" />
<object name="snStatusPaneCommand6_1"
type="button"
/>
<object name="snStatusPaneCommandGroup6" >
<object type="button" name="snStatusPaneCommand6_2" />
<object type="button" name="snStatusPaneCommand6_3" />
@ -169,7 +260,9 @@
<object type="button" name="snStatusPaneCommand6_11" />
<object type="button" name="snStatusPaneCommand6_12" />
</object>
<object type="button" name="snStatusPaneCommand7_1" />
<object name="snStatusPaneCommand7_1"
type="button"
/>
<object name="snStatusPaneCommandGroup7" >
<object type="button" name="snStatusPaneCommand7_2" />
<object type="button" name="snStatusPaneCommand7_3" />
@ -183,7 +276,9 @@
<object type="button" name="snStatusPaneCommand7_11" />
<object type="button" name="snStatusPaneCommand7_12" />
</object>
<object type="button" name="snStatusPaneCommand8_1" />
<object name="snStatusPaneCommand8_1"
type="button"
/>
<object name="snStatusPaneCommandGroup8" >
<object type="button" name="snStatusPaneCommand8_2" />
<object type="button" name="snStatusPaneCommand8_3" />
@ -197,7 +292,9 @@
<object type="button" name="snStatusPaneCommand8_11" />
<object type="button" name="snStatusPaneCommand8_12" />
</object>
<object type="button" name="snStatusPaneCommand9_1" />
<object name="snStatusPaneCommand9_1"
type="button"
/>
<object name="snStatusPaneCommandGroup9" >
<object type="button" name="snStatusPaneCommand9_2" />
<object type="button" name="snStatusPaneCommand9_3" />
@ -211,7 +308,9 @@
<object type="button" name="snStatusPaneCommand9_11" />
<object type="button" name="snStatusPaneCommand9_12" />
</object>
<object type="button" name="snStatusPaneCommand10_1" />
<object name="snStatusPaneCommand10_1"
type="button"
/>
<object name="snStatusPaneCommandGroup10" >
<object type="button" name="snStatusPaneCommand10_2" />
<object type="button" name="snStatusPaneCommand10_3" />
@ -223,54 +322,12 @@
<object type="button" name="snStatusPaneCommand10_9" />
<object type="button" name="snStatusPaneCommand10_10" />
<object type="button" name="snStatusPaneCommand10_11" />
<object type="button" name="snStatusPaneCommand10_12" />
</object>
<object type="button" name="snStatusPaneCommand11_1" />
<object name="snStatusPaneCommandGroup11" >
<object type="button" name="snStatusPaneCommand11_2" />
<object type="button" name="snStatusPaneCommand11_3" />
<object type="button" name="snStatusPaneCommand11_4" />
<object type="button" name="snStatusPaneCommand11_5" />
<object type="button" name="snStatusPaneCommand11_6" />
<object type="button" name="snStatusPaneCommand11_7" />
<object type="button" name="snStatusPaneCommand11_8" />
<object type="button" name="snStatusPaneCommand11_9" />
<object type="button" name="snStatusPaneCommand11_10" />
<object type="button" name="snStatusPaneCommand11_11" />
<object type="button" name="snStatusPaneCommand11_12" />
</object>
<object type="button" name="snStatusPaneCommand12_1" />
<object name="snStatusPaneCommandGroup12" >
<object type="button" name="snStatusPaneCommand12_2" />
<object type="button" name="snStatusPaneCommand12_3" />
<object type="button" name="snStatusPaneCommand12_4" />
<object type="button" name="snStatusPaneCommand12_5" />
<object type="button" name="snStatusPaneCommand12_6" />
<object type="button" name="snStatusPaneCommand12_7" />
<object type="button" name="snStatusPaneCommand12_8" />
<object type="button" name="snStatusPaneCommand12_9" />
<object type="button" name="snStatusPaneCommand12_10" />
<object type="button" name="snStatusPaneCommand12_11" />
<object type="button" name="snStatusPaneCommand12_12" />
</object>
<object type="button" name="snStatusPaneCommand13_1" />
<object name="snStatusPaneCommandGroup13" >
<object type="button" name="snStatusPaneCommand13_2" />
<object type="button" name="snStatusPaneCommand13_3" />
<object type="button" name="snStatusPaneCommand13_4" />
<object type="button" name="snStatusPaneCommand13_5" />
<object type="button" name="snStatusPaneCommand13_6" />
<object type="button" name="snStatusPaneCommand13_7" />
<object type="button" name="snStatusPaneCommand13_8" />
<object type="button" name="snStatusPaneCommand13_9" />
<object type="button" name="snStatusPaneCommand13_10" />
<object type="button" name="snStatusPaneCommand13_11" />
<object type="button" name="snStatusPaneCommand13_12" />
// Setup all.
<action on="Load"><![CDATA[
defineCommandButtons();
]]></action>
<object type="button" name="snStatusPaneCommand10_12"
>
<action on="Load"><![CDATA[
defineCommandButtons(this.name);
]]></action>
</object>
</object>
<object name="snStatusPaneCommandProgress"

View File

@ -111,6 +111,7 @@ function setupSession ()
// Initialise Resource Pools by attaching them to the Player object.
// (CPlayer code takes care of giving a copy to each player.)
createResources();
/*
if (sessionType == "Skirmish")
{
@ -137,7 +138,7 @@ function setupSession ()
// will be replaced soon by native version that doesn't block.
// Start refreshing the session controls.
setInterval( snRefresh, 1, 100 );
setInterval( snRefresh, 1, 100 );
}
// ====================================================================

View File

@ -5,7 +5,7 @@
// ====================================================================
function defineCommandButtons()
function defineCommandButtons(command)
{
snStatusPaneCommand = new Array();
snStatusPaneCommand.tab = new Object();
@ -13,9 +13,10 @@ function defineCommandButtons()
snStatusPaneCommand.button = new Object();
// Maximum number of buttons (either single or lists).
snStatusPaneCommand.tab.max = 10;
snStatusPaneCommand.tab.max = command.substring (command.lastIndexOf ("d")+1, command.lastIndexOf ("_")); // 10
// Maximum number of entries in a list.
snStatusPaneCommand.list.max = 12;
snStatusPaneCommand.list.max = command.substring (command.lastIndexOf ("_")+1, command.length); // 12
// Number of tabs that are single buttons (no list).
snStatusPaneCommand.button.max = 5;
// When we reach this button, split the rows (remainder are vertical, not horizontal).
@ -156,13 +157,13 @@ function UpdateList(listIcon, listCol)
guiUnHide("snStatusPaneCommand" + listCol + "_1");
// Store content info in tab button for future reference.
snStatusPaneCommand[1][listCol].type = "list";
snStatusPaneCommand[listCol][1].type = "list";
// Extract entity list into an array.
listArray = parseDelimiterString(listName, ";");
// Reset list length.
snStatusPaneCommand[1][listCol].last = 0;
snStatusPaneCommand[listCol][1].last = 0;
// Populate appropriate command buttons.
for (createLoop = 1; createLoop < snStatusPaneCommand.list.max; createLoop++)
@ -215,9 +216,9 @@ function UpdateCommand(listIcon, listCol)
guiHide("snStatusPaneCommand" + "Group" + listCol);
// Store content info in tab button for future reference.
snStatusPaneCommand[1][listCol].type = "command";
snStatusPaneCommand[1][listCol].last = 0;
snStatusPaneCommand[1][listCol].name = listIcon;
snStatusPaneCommand[listCol][1].type = "command";
snStatusPaneCommand[listCol][1].last = 0;
snStatusPaneCommand[listCol][1].name = listIcon;
return (listCol-1);
}
@ -227,25 +228,29 @@ function UpdateCommand(listIcon, listCol)
// ====================================================================
function pressCommandButton(GUIObject, tab, list)
function pressCommandButton(commandButton, tab, list)
{
console.write ("Button pressed. " + commandButton + " " + tab + " " + list);
console.write (snStatusPaneCommand[tab][list].type);
switch (list)
{
case 1:
GUIObject.caption = "";
commandButton.caption = "";
if (snStatusPaneCommand[tab][list].type == "list")
{
// Click the tab button to toggle visibility of its list (if it's of a list type).
GUIObjectToggle ("snStatusPaneCommand" + "Group" + tab);
guiToggle ("snStatusPaneCommand" + "Group" + tab);
console.write ("Toggled " + "snStatusPaneCommand" + "Group" + tab);
}
else
{
console.write ("Some weird action.");
// Perform appropriate actions for different command buttons.
switch (snStatusPaneCommand[tab][list].name)
{
case action_patrol:
setCursor("action-patrol");
setCursor ("action-patrol");
selectLocation(
function (x, y) {
issueCommand (selection, NMT_Patrol, x, y);
@ -253,7 +258,7 @@ function pressCommandButton(GUIObject, tab, list)
);
break;
case action_attack:
setCursor("action-attack");
setCursor ("action-attack");
selectEntity(
function (target) {
issueCommand (selection, NMT_AttackMelee, target);
@ -342,7 +347,7 @@ function refreshCommandButtons()
// Set position of progress bar.
GUIObject.size = getGUIObjectByName("snStatusPaneCommand" + selection[0].actions.create.queue.valueOf()[0].tab + "_" + selection[0].actions.create.queue.valueOf()[0].list).size;
// Set progress bar tooltip.
GUIObject.tooltip = "Training " + selection[0].actions.create.queue.valueOf()[0].traits.id.generic + " ... " + (Math.round(selection[0].actions.create.queue.valueOf()[0].traits.creation.time-Math.round(selection[0].actions.create.progress.valueOf().current)) + " seconds remaining.");
GUIObject.tooltip = "Training " + selection[0].actions.create.queue.valueOf()[0].traits.id.generic + " ... " + (Math.round(selection[0].actions.create.queue.valueOf()[0].traits.creation.time-Math.round(selection[0].actions.create.progress.valueOf().current)) + " seconds remaining.";
// Reveal progressbar.
GUIObject.hidden = false;

View File

@ -8,11 +8,12 @@
function createResources()
{
// Defines all resource types for future use.
// Assigns the value of game setup resource values as starting values.
addResource ("Food", 0);
addResource ("Wood", 0);
addResource ("Stone", 0);
addResource ("Ore", 0);
addResource ("Food", getGUIObjectByName ("pgSessionSetupResourceFoodCounter").caption);
addResource ("Wood", getGUIObjectByName ("pgSessionSetupResourceWoodCounter").caption);
addResource ("Stone", getGUIObjectByName ("pgSessionSetupResourceStoneCounter").caption);
addResource ("Ore", getGUIObjectByName ("pgSessionSetupResourceOreCounter").caption);
addResource ("Population", 0);
addResource ("Housing", 0);
}
@ -23,7 +24,10 @@ function addResource (resourceName, resourceQty)
{
// Creates a resource type.
// MT: Rewritten to use JavaScript's nice associative-array-alikes. Requires the valueOf() hack - I'm looking into this.
// Ensure resource name is title-case.
resourceName = toTitleCase (resourceName);
// Create uppercase name.
resourceNameU = resourceName.toUpperCase();
if (!localPlayer.resource)
{
@ -31,13 +35,40 @@ function addResource (resourceName, resourceQty)
localPlayer.resource = new Array();
}
// Set resource name to upper-case to ensure it matches resource control name.
resourceName = resourceName.toUpperCase();
// Store resource's name and starting value.
localPlayer.resource.valueOf()[resourceName] = resourceQty;
localPlayer.resource.valueOf()[resourceNameU] = resourceQty;
// Update GUI resource counter.
if (resourceName != "Housing")
getGUIObjectByName ("snResourceCounter_" + resourceName).caption = resourceQty;
console.write("Added " + resourceName );
console.write( "Added " + resourceName + " (" + resourceQty + ")" );
}
// ====================================================================
function setResources (resourceName, resourceQty)
{
// Generic function to set the value of a resource in the player's pool.
// Ensure resource name is title-case.
resourceName = toTitleCase (resourceName);
// Create uppercase name.
resourceNameU = resourceName.toUpperCase();
if ( localPlayer.resource.valueOf()[resourceNameU] )
{
// Set resource value.
localPlayer.resource.valueOf()[resourceNameU] = resourceQty;
// Update GUI resource counter.
getGUIObjectByName ("snResourceCounter_" + resourceName).caption = localPlayer.resource.valueOf()[resourceNameU];
console.write ("Resource set to " + resourceQty + " " + resourceName + ".");
return ( true );
}
// If the resource wasn't in the list, report an error.
console.write ("Failed to set resource " + resourceName + " to " + resourceQty);
return ( false ) ;
}
// ====================================================================
@ -46,15 +77,25 @@ function giveResources (resourceName, resourceQty)
{
// Generic function to add resources to the player's Pool.
if ( localPlayer.resource.valueOf()[resourceName] )
// Ensure resource name is title-case.
resourceName = toTitleCase (resourceName);
// Create uppercase name.
resourceNameU = resourceName.toUpperCase();
if ( localPlayer.resource.valueOf()[resourceNameU] )
{
localPlayer.resource.valueOf()[resourceName] += resourceQty;
console.write ("Earned " + resourceQty + " resources.");
return ( true );
// Set resource value.
localPlayer.resource.valueOf()[resourceNameU] += resourceQty;
// Update GUI resource counter.
getGUIObjectByName ("snResourceCounter_" + resourceName).caption = localPlayer.resource.valueOf()[resourceNameU];
console.write ("Earned " + resourceQty + " " + resourceName + ".");
return ( true );
}
// If the resource wasn't in the list, report an error.
return false;
console.write ("Failed to add " + resourceQty + " to resource " + resourceName);
return ( false );
}
// ====================================================================
@ -63,14 +104,24 @@ function deductResources (resourceName, resourceQty)
{
// Generic function to remove resources from the player's Pool.
if( localPlayer.resource.valueOf()[resourceName] )
// Ensure resource name is title-case.
resourceName = toTitleCase (resourceName);
// Create uppercase name.
resourceNameU = resourceName.toUpperCase();
if( localPlayer.resource.valueOf()[resourceNameU] )
{
localPlayer.resource.valueOf()[resourceName] -= resourceQty;
console.write("Deducted " + resourceQty + " resources.");
return( true );
// Set resource value.
localPlayer.resource.valueOf()[resourceNameU] -= resourceQty;
// Update GUI resource counter.
getGUIObjectByName ("snResourceCounter_" + resourceName).caption = localPlayer.resource.valueOf()[resourceNameU];
console.write("Deducted " + resourceQty + " " + resourceName + ".");
return( true );
}
// If the resource wasn't in the list, report an error.
console.write ("Failed to deduct " + resourceQty + " from resource " + resourceName);
return false;
}

View File

@ -65,4 +65,14 @@ function addArrayElement(Array)
return (Array.last - 1);
}
// ====================================================================
function toTitleCase (string)
{
// Returns the title-case version of a given string.
string = string.substring(0,1).toUpperCase() + string.substring(1, string.length).toLowerCase();
return (string);
}
// ====================================================================