NewTimer with Table

Started by vcmptr, Jun 01, 2015, 04:26 PM

Previous topic - Next topic

vcmptr

Firstly I don't know it's whether bug. I might be doing something wrong.
NewTimer function not working with table arg.

I'm trying it:
function onScriptLoad()
{
local table = {};
NewTimer("TimerTest", 1000, 1, table);

}


function TimerTest(table)
{
print(type(table));
print("Testing");
}
But does not happen anything.
My English is not good.

DizzasTeR

I don't know if this is wrong or right, but if I had to make something like that I will do:

function onScriptLoad()
{
        table <- {};
        NewTimer("TimerTest", 1000, 1);
}

function TimerTest(table)
{
        print(type(table));
        print("Testing");
}

vcmptr

Quote from: Doom_Killer on Jun 01, 2015, 04:37 PMI don't know if this is wrong or right, but if I had to make something like that I will do:

function onScriptLoad()
{
        table <- {};
        NewTimer("TimerTest", 1000, 1);
}

function TimerTest(table)
{
        print(type(table));
        print("Testing");
}
But you are not send table.
My English is not good.

.

The current timer implementation doesn't support tables, instances, arrays. Just the fundamental types like integer, float, boolean etc.
.

DizzasTeR

Quote from: vcmptr on Jun 01, 2015, 04:48 PM
Quote from: Doom_Killer on Jun 01, 2015, 04:37 PMI don't know if this is wrong or right, but if I had to make something like that I will do:

function onScriptLoad()
{
        table <- {};
        NewTimer("TimerTest", 1000, 1);
}

function TimerTest(table)
{
        print(type(table));
        print("Testing");
}
But you are not send table.

Which is why the table is global so it can be accessed anywhere anytime.

.

#5
Quote from: Doom_Killer on Jun 02, 2015, 01:27 AMWhich is why the table is global so it can be accessed anywhere anytime.

Yes and you also pollute your entire global namespace. But what would you dummies know about the dangers of that. You just don't give a f* and as long as it works you simply couldn't care less. And when it stops working, you start b!ttching all over the place. Stop f*ing with that <- instancing operator on the global table. It's for your own good.
.

DizzasTeR

Quote from: S.L.C on Jun 02, 2015, 04:58 AM
Quote from: Doom_Killer on Jun 02, 2015, 01:27 AMWhich is why the table is global so it can be accessed anywhere anytime.

Yes and you also pollute your entire global namespace. But what would you dummies know about the dangers of that. You just don't give a f* and as long as it works you simply couldn't care less. And when it stops working, you start b!ttching all over the place. Stop f*ing with that <- instancing operator on the global table. It's for your own good.

And then how do you expect me to access a data entirely? Why not use something while its needed, perhaps you can post a perfect example on how to do this without global instance so that I may know as well.

Murdock

Quote from: Doom_Killer on Jun 02, 2015, 07:24 AMAnd then how do you expect me to access a data entirely? Why not use something while its needed, perhaps you can post a perfect example on how to do this without global instance so that I may know as well.

S.L.C. is right, and for an example it really depends on what you're making

PlayerX

local table = {};
function func1()
{
      table[0] <- "lel";
      table[1] <- FindPlayer(10);
}

function func2()
{
     local gettable = table;
     ...
}

for now >_>
If some see me on a server and see that I'm not from Argentina, is an impostor >_>.
Playing since 9 years.

.

#9
I've created a pull request to allow any type in timer arguments. However, it comes at a cost. I had to update the Sqrat and Squirrel libraries to achieve that. Which means that, if accepted, there could be some unforeseen issues until discovered. Function arguments are now more strict you can't pass any type you like as you used to previously. As an example If the function requires 3 arguments (integer, integer, float). You have to pass those correctly. And you also can't use more than 11 custom parameters for timers. I believe that's a fair number.  EXISTING PLUGINS MUST ALSO BE RECOMPILED.

But now this should work just fine:
function onScriptLoad()
{
local table = {};
NewTimer("TimerTest", 1000, 3, table);
}

function onPlayerJoin(player)
{
NewTimer("TimerTest", 1000, 3, player);
}

function TimerTest(obj)
{
print(type(obj));
print("Testing");
}

.

.

A small update to the request of this topic. (sorry for the Bump. but better now before someone else decides he needs this and starts asking questions. as if people search around here)
.