Files
dsrc/sku.0/sys.server/compiled/game/script/beta/donham_terminal.script
T
2013-09-10 23:17:15 -07:00

188 lines
4.8 KiB
Plaintext

/**
* Copyright (c)2000-2002 Sony Online Entertainment Inc.
* All Rights Reserved
*
* Title: terminal_food.script
* Description: BETA SCRIPT: food dispenser
* @author $Author:$
* @version $Revision:$
*/
/***** INCLUDES ********************************************************/
include library.sui;
include library.utils;
/***** INHERITS ********************************************************/
/***** CONSTANTS *******************************************************/
const string DATATABLE_ITEMS_TO_TEST = "datatables/beta/items_to_test.iff";
const string_id SID_ORDER_ITEM = new string_id ("sui", "order_item");
const string CATEGORY_PROMPT = "Select an item category.";
const string ITEM_REQUEST_PROMPT = "Select a template to test.";
const string HANDLER_CATEGORY_RESPONSE = "handleCategoryResponse";
const string HANDLER_ITEM_REQUEST = "handleItemRequest";
const string VAR_ITEM_REQUEST_BASE = "item_request";
const string VAR_ITEM_REQUEST_CATEGORY = VAR_ITEM_REQUEST_BASE + ".category";
/***** TRIGGERS ********************************************************/
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
{
int mnu = mi.addRootMenu ( menu_info_types.SERVER_ITEM_OPTIONS, SID_ORDER_ITEM);
return SCRIPT_CONTINUE;
}
trigger OnObjectMenuSelect(obj_id player, int item)
{
if ( item == menu_info_types.SERVER_ITEM_OPTIONS)
{
if ( dataTableOpen(DATATABLE_ITEMS_TO_TEST) )
{
string[] colName = dataTableGetStringColumn(DATATABLE_ITEMS_TO_TEST, "column_names");
if ( (colName == null) || (colName.length == 0) )
{
sendSystemMessageTestingOnly(player, "Unable to load test item information. Exiting.");
return SCRIPT_CONTINUE;
}
else
{
string[] entries = new string[colName.length];
for ( int i = 0; i < colName.length; i++ )
{
entries[i] = "@beta:" + colName[i];
}
sui.listbox(self, player, CATEGORY_PROMPT, entries, HANDLER_CATEGORY_RESPONSE);
}
}
}
return SCRIPT_CONTINUE;
}
/***** FUNCTIONS *******************************************************/
/***** MESSAGEHANDLERS *************************************************/
messageHandler handleCategoryResponse()
{
if ( params == null )
{
return SCRIPT_CONTINUE;
}
obj_id playerId = sui.getPlayerId(params);
if ( (playerId == null) || (playerId == obj_id.NULL_ID) )
{
return SCRIPT_CONTINUE;
}
else
{
//debugSpeakMsg(self, "player = " + playerId);
int selRow = sui.getListboxSelectedRow(params);
if ( selRow == -1 )
{
return SCRIPT_CONTINUE;
}
else
{
if ( dataTableOpen(DATATABLE_ITEMS_TO_TEST) )
{
string title = "unknown";
string[] colName = dataTableGetStringColumn(DATATABLE_ITEMS_TO_TEST, "column_names");
if ( (colName == null) || (colName.length == 0) )
{
return SCRIPT_CONTINUE;
}
else
{
title = colName[selRow];
}
string[] templates = dataTableGetStringColumn(DATATABLE_ITEMS_TO_TEST, selRow + 1);
if ( (templates == null) || (templates.length == 0) )
{
return SCRIPT_CONTINUE;
}
else
{
if ( !title.equals("unknown") )
{
setObjVar(playerId, VAR_ITEM_REQUEST_CATEGORY, title);
sui.listbox(self, playerId, ITEM_REQUEST_PROMPT, sui.OK_ONLY, title, templates, HANDLER_ITEM_REQUEST);
}
}
}
}
}
return SCRIPT_CONTINUE;
}
messageHandler handleItemRequest()
{
if ( params == null )
{
return SCRIPT_CONTINUE;
}
obj_id playerId = sui.getPlayerId(params);
if ( (playerId == null) || (playerId == obj_id.NULL_ID) )
{
return SCRIPT_CONTINUE;
}
else
{
//debugSpeakMsg(self, "entering handleItemRequest...");
//string category = sui.getListboxTitle(params);
string category = getStringObjVar(playerId, VAR_ITEM_REQUEST_CATEGORY);
removeObjVar(playerId, VAR_ITEM_REQUEST_BASE);
int selRow = sui.getListboxSelectedRow(params);
if ( selRow == -1 )
{
return SCRIPT_CONTINUE;
}
else
{
if ( dataTableOpen(DATATABLE_ITEMS_TO_TEST) )
{
string template = dataTableGetString(DATATABLE_ITEMS_TO_TEST, selRow, category);
if ( (template == null) || (template.equals("")) )
{
//debugSpeakMsg(self, "Unable to retrieve template: category = " + category + " selRow = " + selRow);
}
else
{
obj_id pInv = utils.getInventoryContainer(playerId);
if ( (pInv == null) || (pInv == obj_id.NULL_ID) )
{
//debugSpeakMsg(self, "Unable to determine player's inventory");
return SCRIPT_CONTINUE;
}
else
{
obj_id itemId = createObject(template, pInv, "");
if ( (itemId == null) || (itemId == obj_id.NULL_ID) )
{
//debugSpeakMsg(self, "Unable to create requested item!");
return SCRIPT_CONTINUE;
}
else
{
//debugSpeakMsg(self, "Object successfully created for " + getName(playerId));
}
}
}
}
}
}
return SCRIPT_CONTINUE;
}