scripting:samples:basicbuilding
Simple 'Gather Building' Sample script
Here is a simple script for a 'Gather Building' - i.e. One where the user accesses a 'building' (doesnt have to be an actual building model of course, it could be a rock or a tree or a NPC..) and it gives the user a particular item (up to a defined limit).
To use it on your own world, set a building in the Buildings Editor to be a 'scripted-nowindow' type, then modify the 'AccessBuilding' Event with the building number and the item you want to award.
$kMaxAmountOfItemToGather = 3
//--------------------------------------------------
//------ Access script for Building Type 5 = Berries
//--------------------------------------------------
Event( "AccessBuilding", "5" )
{
$ret = StandardGatherDisplay( "Berries" );
}
//--------------------------------------------------
// StandardGatherDisplay
//--------------------------------------------------
Function StandardGatherDisplay( $itemName )
{
$isInInv = sysPlayerInventory( $itemName )
if ( $isInInv < kMaxAmountOfItemToGather )
{
$amountToAdd = kMaxAmountOfItemToGather - $isInInv
*changeinventory %PLAYER% $amountToAdd $itemName
*updateinventory %PLAYER%
*notify %PLAYER% You collected $amountToAdd $itemName
}
else
{
*alert %PLAYER% You have all the $itemName you can carry right now
}
}
scripting/samples/basicbuilding.txt · Last modified: by 127.0.0.1
