Jump to content
Alloder.pro: about Allods with love
Search In
  • More options...
Find results that contain...
Find results in...

New program for writers

We turn from quantity to quality and tell you how we will supplement the Allods Team program with rewards in rubles.

More

The new Updater

Let us to introduce the new addon updater software and to share the details

Read more

Alloder 2.0

We have started the process of project evolve, and this relates not only, and not even primarily of the site's view

Read more

You may send chat messages with addon's help.


Setras
 Share

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...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

 Share

×
×
  • Create New...

Important Information

By using our site you agree to the Terms of Use