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

Servers monitoring and the Addons Editor

We present you two legends. All dreams come true.

Servers monitoring The Addons Editor

Digest April

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

Read more

Game tooltips

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

Read more

userMade.function()


Setras
 Share

Recommended Posts

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 ;-)

Link to comment
Share on other sites

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.

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.

 Share

×
×
  • Create New...

Important Information

By using our site you agree to the Terms of Use