Jump to content

Digest Jan-Feb

We talk about what was done and updated in the past month. We help keep abreast of events.

January February

Servers monitoring and the Addons Editor

We present you two legends. All dreams come true.

Servers monitoring The Addons Editor

Game tooltips

Tooltips provide a way for 3rd party fansites and extensions to display detailed information on mouseover.

Read more

The Addons Updater

Let us to introduce the addons updating software and to share the details

Read more Download

You may send chat messages with addon's help.


Setras

Recommended Posts

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, B)

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!

Link to comment
Share on other sites

  • 2 weeks later...

Гребаная принцесса всех распугала. Уебищная реклама. Скиллкодеру наверно нравится Х_х

Link to comment
Share on other sites

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using our site you agree to the Terms of Use