Setras Posted February 18, 2012 Share Posted February 18, 2012 Here's a howto: Open chat line by pressing enter, modify ChatInputText by using mission.SetChatInputText() command. Docs say there is one parameter, but lua says the function needs two, i just use 1 as a second parameter. Code: mission.SetChatInputText(userMods.ToWString("Test ABC ABC test"), 1 ) And finally hit enter. Chat script changes ChatInputText only if you modify the edit line, so if you don't change the edit line - you may change it through your addon. So you may send any data by just fast-hitting enter twice + a button on the screen (unfortunateley binds do not work while editing edit line) or before hitting enter. Say, for example, double click F1 for saying "I am out of mana", triple click for "Attacking left turret" and so on. Remember, setting chat input is not a crime, so you won't get any errors while selecting yourself or party members (F1-F6) without open chat line. You also may auto change chat type (party, guild, etc): Code: mission.SetChatInputType( "party" ) For example add this to MainForm.(WidgetForm).xdb: Code: <bindSections> <Item> <bindSection>mission_members</bindSection> <bindedReactions> <Item>target_avatar</Item> <Item>party_member_1</Item> </bindedReactions> </Item> <Item> <bindSection>mission_actions</bindSection> <bindedReactions> <Item>action_04</Item> </bindedReactions> </Item> </bindSections> (just an example)And this code to your addon: Code: Global("PressedButtonData", {} )PressedButtonData.Counter = 0 PressedButtonData.LastButton = 0 PressedButtonData.ForcedText = nil PressedButtonData.LastTime = mission.GetLocalTimeHMS() PressedButtonData.ChatInputLastTime = mission.GetLocalTimeHMS() function timer(params) if params.effectType == ET_FADE and params.wtOwner:IsEqual( mainForm ) then mainForm:PlayFadeEffect( 1.0, 1.0, 1, EA_MONOTONOUS_INCREASE ) userMods.SendEvent( "EVENT_FRAME_TIMER", {sender = common.GetAddonName()} ) end end function StartTimer() common.RegisterEventHandler( timer , "EVENT_EFFECT_FINISHED" ) mainForm:PlayFadeEffect( 1.0, 1.0, 1, EA_MONOTONOUS_INCREASE ) end function StopTimer() common.UnRegisterEventHandler( timer, "EVENT_EFFECT_FINISHED" ) end function ChatInputEnforcer() if GetTimeDifferenceInMilliseconds(PressedButtonData.ChatInputLastTime, mission.GetLocalTimeHMS()) < 3000 then mission.SetChatInputText( PressedButtonData.ForcedText , 1 ) else StopTimer() end end common.RegisterEventHandler( ChatInputEnforcer , "EVENT_FRAME_TIMER" ) function GetTimeDifferenceInMilliseconds (a, local TimeDifferenceInMilliseconds = (a.ms + 1000 * (a.s + 60 * ( a.m + 60 * a.h))) - ( b.ms + 1000 * (b.s + 60 * ( b.m + 60 * b.h))) return(math.abs(TimeDifferenceInMilliseconds)) end function IHavePressedF1Button( par ) if PressedButtonData.LastButton ~= 1 then PressedButtonData.LastButton = 1 PressedButtonData.Counter = 1 end if GetTimeDifferenceInMilliseconds(PressedButtonData.LastTime, mission.GetLocalTimeHMS()) < 1000 then PressedButtonData.Counter = PressedButtonData.Counter + 1 else PressedButtonData.Counter = 1 end if PressedButtonData.Counter == 1 then PressedButtonData.ForcedText = userMods.ToWString("/oom") elseif PressedButtonData.Counter == 2 then PressedButtonData.ForcedText = userMods.ToWString("/healme") end PressedButtonData.ChatInputLastTime = mission.GetLocalTimeHMS() StartTimer() PressedButtonData.LastTime = mission.GetLocalTimeHMS() end common.RegisterReactionHandler( IHavePressedF1Button, 'target_avatar' ) function IHavePressedF2Button( par ) if PressedButtonData.LastButton ~= 2 then PressedButtonData.LastButton = 2 PressedButtonData.Counter = 1 end if GetTimeDifferenceInMilliseconds(PressedButtonData.LastTime, mission.GetLocalTimeHMS()) < 1000 then PressedButtonData.Counter = PressedButtonData.Counter + 1 else PressedButtonData.Counter = 1 end if PressedButtonData.Counter == 1 then PressedButtonData.ForcedText = userMods.ToWString("!W00T W00T RED ALERT!") elseif PressedButtonData.Counter == 2 then PressedButtonData.ForcedText = userMods.ToWString("Heal, zeny, item please!") end PressedButtonData.ChatInputLastTime = mission.GetLocalTimeHMS() StartTimer() PressedButtonData.LastTime = mission.GetLocalTimeHMS() end common.RegisterReactionHandler( IHavePressedF2Button, 'party_member_1' ) And enjoy! Quote Link to comment Share on other sites More sharing options...
Setras Posted February 28, 2012 Author Share Posted February 28, 2012 HURRAY! Все заценили! Quote Link to comment Share on other sites More sharing options...
Nikon Posted February 28, 2012 Share Posted February 28, 2012 Здесь еще кто то есть? О.О Quote Link to comment Share on other sites More sharing options...
Setras Posted February 28, 2012 Author Share Posted February 28, 2012 Гребаная принцесса всех распугала. Уебищная реклама. Скиллкодеру наверно нравится Х_х Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.