Ulysses

General => Developers Corner => Topic started by: feldma on February 15, 2016, 02:25:23 AM

Title: A few questions about ULX commands...
Post by: feldma on February 15, 2016, 02:25:23 AM
Hi all.

I'm working on stuff and I need to know if a few things are possible:

Firstly, is it possible to restrict a ULX command to once every, let's say, TTT round?

And is it possible to have a command that saves (such as "every round do this", but you can override that with a different command)?

I know this will require a fair amount of coding, but yeah, if anyone could point me in the right direction (if it's even possible).

Chances are I'll need to create an entirely new addon for this, no doubt.

Thanks,
Feldma.
Title: Re: A few questions about ULX commands...
Post by: roastchicken on February 15, 2016, 06:15:54 AM
Firstly, is it possible to restrict a ULX command to once every, let's say, TTT round?

Yes, but there isn't any premade ULib/ULX way to do it. Just slap an if statement in your code checking if a TTT round has passed since the last time it was called.

And is it possible to have a command that saves (such as "every round do this", but you can override that with a different command)?

Not exactly sure what you're asking for. If you want something to happen every round you can go ahead and put it in a hook (I would assume TTT has some round hooks). Then just have another command to remove that hook when called.
Title: Re: A few questions about ULX commands...
Post by: Decicus on February 15, 2016, 08:29:31 AM
Not exactly sure what you're asking for. If you want something to happen every round you can go ahead and put it in a hook (I would assume TTT has some round hooks). Then just have another command to remove that hook when called.

They do indeed. They're listed here: http://ttt.badking.net/guides/hooks
Title: Re: A few questions about ULX commands...
Post by: feldma on February 15, 2016, 12:16:50 PM
Nevermind the last question, I'm going to need to think of a better way of doing what I want to do.

However, regarding the hooks, if I wished to use TTTPrepareRound(), would I do it like:

Code: [Select]
if TTTPrepareRound() then
-- code
end

Since I'm horrible at coding and hooks, I'm not sure if that would work.
Title: Re: A few questions about ULX commands...
Post by: Bytewave on February 15, 2016, 12:33:01 PM
Nevermind the last question, I'm going to need to think of a better way of doing what I want to do.

However, regarding the hooks, if I wished to use TTTPrepareRound(), would I do it like:

Code: [Select]
if TTTPrepareRound() then
-- code
end

Since I'm horrible at coding and hooks, I'm not sure if that would work.
No. You add hooks like this.
Code: [Select]
hook.Add(string eventname, string uniquehookname, function callback)So, an example (for TTTBeginRound) would be:
Code: [Select]
hook.Add( "TTTBeginRound", "unique_name_goes_here", function()
    -- code goes here
end

edit: whew it's been a while
Title: Re: A few questions about ULX commands...
Post by: feldma on February 15, 2016, 01:10:15 PM
Ahh, yes. I see now how that works.

Thanks.