找回密码
 点一下
查看: 11840|回复: 3

[再改标题]请问如何取得Timer或者Trigger的唯一标识(integer或者string)

[复制链接]
发表于 2010-5-5 18:49:30 | 显示全部楼层 |阅读模式
标题描述可能不太清楚,下面解释一下

以前WE可以通过GetHandleId来取得Timer或者Trigger的唯一值,将其作为key来将变量值存在HashTable中,借由这种方法来在多个Trigger间传值


S2E中我还没有找到类似的方法,至少Timer或者Trigger没有办法转换成Integer或者String



以下是需求实例,当然只是为了描述问题而设的例子而已


[codes=galaxy]
//--------------------------------------------------------------------------------------------------
// Trigger: chat1
//--------------------------------------------------------------------------------------------------
bool gt_chat1_Func (bool testConds, bool runActions) {
    // Variable Declarations
    trigger lv_t;
    text lv_name;

    // Variable Initialization
    lv_t = null;
    lv_name = null;

    // Actions
    if (!runActions) {
        return true;
    }

    lv_name = (PlayerName(EventPlayer()) + FixedToText(libNtve_gf_GamePlayTime(EventPlayer()), c_fixedPrecisionAny));
    lv_t = TriggerCreate("gt_chat2_Func");
    TriggerAddEventChatMessage(lv_t , c_playerAny, "-", false);
    return true;
}

//--------------------------------------------------------------------------------------------------
void gt_chat1_Init () {
    gt_chat1 = TriggerCreate("gt_chat1_Func");
    TriggerAddEventChatMessage(gt_chat1, c_playerAny, "z", true);
}

//--------------------------------------------------------------------------------------------------
// Trigger: chat2
//--------------------------------------------------------------------------------------------------
bool gt_chat2_Func (bool testConds, bool runActions) {
    // Variable Declarations
    text lv_msg;

    // Variable Initialization
    lv_msg = null;

    // Actions
    if (!runActions) {
        return true;
    }

    lv_msg = (StringExternal("Param/Value/99D96A04") + StringToText(EventChatMessage(false)));
    UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText(EventChatMessage(false)));
    return true;
}
[/codes]


chat1的作用是在聊天内容中输入z后,生成一个特殊的字符串为,名字为name,并生成一个Trigger,这里称为chat2

chat2的作用是当玩家输入了带 "-" 的聊天内容后,显示的内容为 name+聊天内容 的文字,其中name应该是由chat1生成的那个特殊字符串,在上面的代码中暂时用StringExternal("Param/Value/99D96A04")代替了

现在的问题是,chat1生成的字符串如何传给chat2,别说用一个类型为Text的全局变量保存啊
发表于 2010-5-5 19:28:11 | 显示全部楼层
其实有DataTable可以用的。

[codes=galaxy]
//--------------------------------------------------------------------------------------------------
// Data Table
// - Data tables provide named storage for any script type.
//   Table access may be either global or thread-local.
//--------------------------------------------------------------------------------------------------
// Types
const int c_dataTypeUnknown             = -1;
const int c_dataTypeAbilCmd             =  0;
const int c_dataTypeActor               =  1;
const int c_dataTypeActorScope          =  2;
const int c_dataTypeAIFilter            =  3;
const int c_dataTypeBank                =  4;
const int c_dataTypeBool                =  5;
const int c_dataTypeByte                =  6;
const int c_dataTypeCameraInfo          =  7;
const int c_dataTypeCinematic           =  8;
const int c_dataTypeColor               =  9;
const int c_dataTypeControl             = 10;
const int c_dataTypeConversation        = 11;
const int c_dataTypeDialog              = 12;
const int c_dataTypeDoodad              = 13;
const int c_dataTypeFixed               = 14;
const int c_dataTypeInt                 = 15;
const int c_dataTypeMarker              = 16;
const int c_dataTypeObjective           = 17;
const int c_dataTypeOrder               = 18;
const int c_dataTypePing                = 19;
const int c_dataTypePlanet              = 20;
const int c_dataTypePlayerGroup         = 21;
const int c_dataTypePoint               = 22;
const int c_dataTypePortrait            = 23;
const int c_dataTypeRegion              = 24;
const int c_dataTypeReply               = 25;
const int c_dataTypeRevealer            = 26;
const int c_dataTypeRoom                = 27;
const int c_dataTypeSound               = 28;
const int c_dataTypeSoundLink           = 29;
const int c_dataTypeString              = 30;
const int c_dataTypeText                = 31;
const int c_dataTypeTimer               = 32;
const int c_dataTypeTransmission        = 33;
const int c_dataTypeTransmissionSource  = 34;
const int c_dataTypeTrigger             = 35;
const int c_dataTypeUnit                = 36;
const int c_dataTypeUnitFilter          = 37;
const int c_dataTypeUnitGroup           = 38;
const int c_dataTypeUnitRef             = 39;
const int c_dataTypeWave                = 40;
const int c_dataTypeWaveInfo            = 41;
const int c_dataTypeWaveTarget          = 42;

// General functionality
native void     DataTableClear (bool global);
native int      DataTableValueCount (bool global);
native string   DataTableValueName (bool global, int index);
native bool     DataTableValueExists (bool global, string name);
native int      DataTableValueType (bool global, string name);
native void     DataTableValueRemove (bool global, string name);

// Type-specific value set/get
// - c_dataTypeAbilCmd
native void         DataTableSetAbilCmd (bool global, string name, abilcmd val);
native abilcmd      DataTableGetAbilCmd (bool global, string name);

// - c_dataTypeActor
native void         DataTableSetActor (bool global, string name, actor val);
native actor        DataTableGetActor (bool global, string name);

// - c_dataTypeActorScope
native void         DataTableSetActorScope (bool global, string name, actorscope val);
native actorscope   DataTableGetActorScope (bool global, string name);

// - c_dataTypeAIFilter
native void         DataTableSetAIFilter (bool global, string name, aifilter val);
native aifilter     DataTableGetAIFilter (bool global, string name);

// - c_dataTypeBank
native void         DataTableSetBank (bool global, string name, bank val);
native bank         DataTableGetBank (bool global, string name);

// - c_dataTypeBool
native void         DataTableSetBool (bool global, string name, bool val);
native bool         DataTableGetBool (bool global, string name);

// - c_dataTypeByte
native void         DataTableSetByte (bool global, string name, byte val);
native byte         DataTableGetByte (bool global, string name);

// - c_dataTypeCameraInfo
native void         DataTableSetCameraInfo (bool global, string name, camerainfo val);
native camerainfo   DataTableGetCameraInfo (bool global, string name);

// - c_dataTypeCinematic
native void         DataTableSetCinematic (bool global, string name, int val);
native int          DataTableGetCinematic (bool global, string name);

// - c_dataTypeColor
native void         DataTableSetColor (bool global, string name, color val);
native color        DataTableGetColor (bool global, string name);

// - c_dataTypeControl
native void         DataTableSetControl (bool global, string name, int val);
native int          DataTableGetControl (bool global, string name);

// - c_dataTypeConversation
native void         DataTableSetConversation (bool global, string name, int val);
native int          DataTableGetConversation (bool global, string name);

// - c_dataTypeDialog
native void         DataTableSetDialog (bool global, string name, int val);
native int          DataTableGetDialog (bool global, string name);

// - c_dataTypeDoodad
native void         DataTableSetDoodad (bool global, string name, doodad val);
native doodad       DataTableGetDoodad (bool global, string name);

// - c_dataTypeFixed
native void         DataTableSetFixed (bool global, string name, fixed val);
native fixed        DataTableGetFixed (bool global, string name);

// - c_dataTypeInt
native void         DataTableSetInt (bool global, string name, int val);
native int          DataTableGetInt (bool global, string name);

// - c_dataTypeMarker
native void         DataTableSetMarker (bool global, string name, marker val);
native marker       DataTableGetMarker (bool global, string name);

// - c_dataTypeObjective
native void         DataTableSetObjective (bool global, string name, int val);
native int          DataTableGetObjective (bool global, string name);

// - c_dataTypeOrder
native void         DataTableSetOrder (bool global, string name, order val);
native order        DataTableGetOrder (bool global, string name);

// - c_dataTypePing
native void         DataTableSetPing (bool global, string name, int val);
native int          DataTableGetPing (bool global, string name);

// - c_dataTypePlanet
native void         DataTableSetPlanet (bool global, string name, int val);
native int          DataTableGetPlanet (bool global, string name);

// - c_dataTypePlayerGroup
native void         DataTableSetPlayerGroup (bool global, string name, playergroup val);
native playergroup  DataTableGetPlayerGroup (bool global, string name);

// - c_dataTypePoint
native void         DataTableSetPoint (bool global, string name, point val);
native point        DataTableGetPoint (bool global, string name);

// - c_dataTypePortrait
native void         DataTableSetPortrait (bool global, string name, int val);
native int          DataTableGetPortrait (bool global, string name);

// - c_dataTypeRegion
native void         DataTableSetRegion (bool global, string name, region val);
native region       DataTableGetRegion (bool global, string name);

// - c_dataTypeReply
native void         DataTableSetReply (bool global, string name, int val);
native int          DataTableGetReply (bool global, string name);

// - c_dataTypeRevealer
native void         DataTableSetRevealer (bool global, string name, revealer val);
native revealer     DataTableGetRevealer (bool global, string name);

// - c_dataTypeRoom
native void         DataTableSetRoom (bool global, string name, int val);
native int          DataTableGetRoom (bool global, string name);

// - c_dataTypeSound
native void         DataTableSetSound (bool global, string name, sound val);
native sound        DataTableGetSound (bool global, string name);

// - c_dataTypeSoundLink
native void         DataTableSetSoundLink (bool global, string name, soundlink val);
native soundlink    DataTableGetSoundLink (bool global, string name);

// - c_dataTypeString
native void         DataTableSetString (bool global, string name, string val);
native string       DataTableGetString (bool global, string name);

// - c_dataTypeText
native void         DataTableSetText (bool global, string name, text val);
native text         DataTableGetText (bool global, string name);

// - c_dataTypeTimer
native void         DataTableSetTimer (bool global, string name, timer val);
native timer        DataTableGetTimer (bool global, string name);

// - c_dataTypeTransmission
native void         DataTableSetTransmission (bool global, string name, int val);
native int          DataTableGetTransmission (bool global, string name);

// - c_dataTypeTransmissionSource
native void                 DataTableSetTransmissionSource (bool global, string name, transmissionsource val);
native transmissionsource   DataTableGetTransmissionSource (bool global, string name);

// - c_dataTypeTrigger
native void         DataTableSetTrigger (bool global, string name, trigger val);
native trigger      DataTableGetTrigger (bool global, string name);

// - c_dataTypeUnit
native void         DataTableSetUnit (bool global, string name, unit val);
native unit         DataTableGetUnit (bool global, string name);

// - c_dataTypeUnitFilter
native void         DataTableSetUnitFilter (bool global, string name, unitfilter val);
native unitfilter   DataTableGetUnitFilter (bool global, string name);

// - c_dataTypeUnitGroup
native void         DataTableSetUnitGroup (bool global, string name, unitgroup val);
native unitgroup    DataTableGetUnitGroup (bool global, string name);

// - c_dataTypeUnitRef
native void         DataTableSetUnitRef (bool global, string name, unitref val);
native unitref      DataTableGetUnitRef (bool global, string name);

// - c_dataTypeWave
native void         DataTableSetWave (bool global, string name, wave val);
native wave         DataTableGetWave (bool global, string name);

// - c_dataTypeWaveInfo
native void         DataTableSetWaveInfo (bool global, string name, waveinfo val);
native waveinfo     DataTableGetWaveInfo (bool global, string name);

// - c_dataTypeWaveTarget
native void         DataTableSetWaveTarget (bool global, string name, wavetarget val);
native wavetarget   DataTableGetWaveTarget (bool global, string name);

[/codes]

----------- 帖子于 19:28 更新 --------- 之前内容发布于 19:26 ------------

此外还可以使用Bank。

见链接http://bbs.islga.org/read-htm-tid-40410.html
回复

使用道具 举报

 楼主| 发表于 2010-5-6 08:58:37 | 显示全部楼层
我知道有DataTable,这个东西可以看成是是以前HashTable的扩展

但是原来的GetHandleId在哪里,如果不能确定key,用什么存贮方式都没啥区别啊



好象我描述还是不是很清楚,于是改一下标题
回复

使用道具 举报

发表于 2010-5-6 15:14:35 | 显示全部楼层
啊,抱歉没看到你回帖呀,这个唯一标识我也不清楚。

我知道有一个函数UnitFromId(int i),可以通过一个整数来获取单位,但是这貌似只是在地图上摆好了的单位才能用的,如何对单位获取到其ID我没有找到,至于其他的类型我也没有发现唉。

不知道谁可以来指导下。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-9-28 19:15 , Processed in 0.091447 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表