for (local.a=1;local.a<=35;local.a++) probllem...

Post your scripting questions / solutions here

Moderator: Moderators

$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

Of course :wink: I used self.mytarget.size in case you might increase the mytargets, that way you wouldn't have to modify your for statement.
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
Aprop
Major
Posts: 291
Joined: Mon Nov 17, 2008 3:40 pm

Post by Aprop »

Hello again.... now i have anothger problem, but its related to this topic so i post here!! I dont know why it dont work.... this is part of thest script///!

Code: Select all

add local.parent:

if (local.parent.ch)
{
local.parent.num++
local.parent.ch[local.parent.num] = self
}
else
{
//first ch
local.parent.num = 1
local.parent.ch = self
}
end
Its called by something like

Code: Select all

$aaa thread add bbb
after that another script is called:

Code: Select all




for (local.i = 1; local.i < (local.parent.num+1); local.i++)
{
local.parent.ch[local.i] thread .........

}




What i want get exacly??

a script that let me add infinite number of entities with diffrent targetnames to one entity parm (??) called for example ".my_entities", and after that get all of those entities by FOR statement...
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

Infinite? 1024 is the maximum :) Hmm, by the looks of your scripts, it doesn't seem anything like what you want to achieve.

Use this to register the entity in 1 variable.
Usage:

Code: Select all

 waitthread register_entity $my_entity
Script:

Code: Select all

register_entity local.entity:

        if (level.entity_register == NIL)
                local.i = 1
        else
                local.i = ( level.entity_register.size + 1 )

        level.entity_register[local.i] = local.entity

end

If you want 1 or all entity's to do something:

Code: Select all

register_execution local.orders local.wait local.tname:

        if (local.tname == NIL || local.tname == "")
        {
                for (local.i = 1; local.i <= level.entity_register.size; local.i++)
                {
                        if (local.wait == 1)
                                level.entity_register[local.i] waitexec local.orders
                        else
                                level.entity_register[local.i] exec local.orders
                }
        }
        else
        {
                for (local.i = 1; local.i <= level.entity_register.size; local.i++)
                {
                        if (local.tname == level.entity_register[local.i].targetname)
                       {
                                if (local.wait == 1)
                                           level.entity_register[local.i] waitexec local.orders
                                else
                                        level.entity_register[local.i] exec local.orders
                       }
                }
        }
end
Usage:

Code: Select all

waitthread register_execution global/myscript.scr 1 "my_targetname"
1 for waitexec, NIL or 0 for exec. Don't specify a targetname if you want all registered entities execute your orders.


Or just a local thread!

Code: Select all

register_thread local.orders local.wait local.tname:

        if (local.tname == NIL || local.tname == "")
        {
                for (local.i = 1; local.i <= level.entity_register.size; local.i++)
                {
                        if (local.wait == 1)
                                level.entity_register[local.i] waitthread local.orders
                        else
                                level.entity_register[local.i] thread local.orders
                }
        }
        else
        {
                for (local.i = 1; local.i <= level.entity_register.size; local.i++)
                {
                        if (local.tname == level.entity_register[local.i].targetname)
                       {
                                if (local.wait == 1)
                                           level.entity_register[local.i] waitthread local.orders
                                else
                                        level.entity_register[local.i] thread local.orders
                       }
                }
        }
end
Usage, similar to the previous script:

Code: Select all

waitthread register_thread "mythread" 1 "my_targetname"
1 for waitthread, NIL or 0 for thread. Don't specify a targetname if you want all registered entities execute your orders.

There are a lot more things you can do ;). Are these scripts you need?

Cheers
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
Aprop
Major
Posts: 291
Joined: Mon Nov 17, 2008 3:40 pm

Post by Aprop »

Aprop wrote:

Code: Select all

local.parent.ch = self

Should be:

Code: Select all

local.parent.ch[1] = self



Anyway, thank you Soldier!
Post Reply