Перейти к содержанию

Дайджесты за январь-февраль

Обновления гайдов и аддонов

Январь Февраль

Мониторинг серверов и редактор аддонов

Представляем вам две легенды. То, о чем можно было только мечтать, стало реальностью.

Мониторинг серверов Редактор аддонов

Подсказки из игры на вашем сайте

Теперь вы можете отображать сведения о внутриигровых элементах простым наведением курсора мыши.

Подробнее

Апдейтер аддонов

Представляем вам программу для автообновления аддонов и делимся подробностями.

Подробнее Скачать

userMade.function()


Setras

Рекомендуемые сообщения

We had a discuss in one of add-on's topics, but i had thought that everyone should know somevery usefull tricks you can do in AO.

So here's the first one:

----------------========(I)========----------------

Creating your own timer.

It's helpfull if you need something to renew faster or slower than each second.

An example of what it is and how it could be used is in TS3Viewer addon. It shows you who's speaking in your TS room in real time, and sometimes it happens so that you hear multiple people giving short comments and so on and renewing the window each second i not fast enough.

What you need is(isuppose you know how to create add-ons and widgets as well as basics of Lua):

A dummy widget of any size and position, even a tootally transparent 1x1 pixel one would do the job.

Let's say it's called wtKenny.

Also we need any WidgetPlayEffect, like fade effect, size or move are OK as well.

And a handler with a function that will repeatedley run that effect.

So here's a lil example of a timer using widget wtKenny and triggering each 0.25 seconds (250 milliseconds):

Code:

function timer(params)

  if params.effectType == ET_FADE and params.wtOwner:IsEqual( wtKenny ) then 

    wtKenny:PlayFadeEffect( 1.0, 1.0, 250, EA_MONOTONOUS_INCREASE )

    userMods.SendEvent( "EVENT_250_MS_TIMER", {sender = common.GetAddonName()} )

  end

end

function MyFunctionHere(params)

--Insert your code here

end

function Init()

    wtKenny = mainForm:GetChildChecked( "Kenny", false )

    common.RegisterEventHandler( timer, "EVENT_EFFECT_FINISHED" )

    common.RegisterEventHandler( MyFunctionHere, "EVENT_250_MS_TIMER" )

    wtKenny:PlayFadeEffect( 1.0, 1.0, 250, EA_MONOTONOUS_INCREASE )

end

Init()

In this example an event called "EVENT_250_MS_TIMER" is sent to every user addon each 250 milliseconds with params.sender equal to your addon's name.

CAUTION /!\

Use unique event name or perform a check to ensure that you've got an event from your timer, because otherwise you'll run functions triggered by other addons, which, for example, could make you run functions twice or even more often than expected!

CAUTION /!\

Second parameter in userMods.SendEvent must be a table!

----------------========(II)========----------------

Today evening i'll edit this post and show you how to find direction to target, and maybe tomorrow evening - even a distance to target ;-)

Ссылка на комментарий
Поделиться на другие сайты

Quote:
Today evening i'll edit this post and show you how to find direction to target, and maybe tomorrow evening - even a distance to target ;-)

?
Ссылка на комментарий
Поделиться на другие сайты

Yeah, job and stuff... Sleepless night and after i was working all day long, came back 30 minutes ago and i already want to sleep, sry...

But here is a LITTLE tip: Attach widget 2D and observe it's on-screen coordinates and player camera rotation.

Ссылка на комментарий
Поделиться на другие сайты

Гость
Ответить в этой теме...

×   Вставлено с форматированием.   Восстановить форматирование

  Разрешено использовать не более 75 эмодзи.

×   Ваша ссылка была автоматически встроена.   Отображать как обычную ссылку

×   Ваш предыдущий контент был восстановлен.   Очистить редактор

×   Вы не можете вставлять изображения напрямую. Загружайте или вставляйте изображения по ссылке.

×
×
  • Создать...

Важная информация

Пользуясь сайтом, вы принимаете Условия использования