Can someone explain what script signals are?
Moderator: Moderators
Can someone explain what script signals are?
I am not really sure what they do and suspect I may have a signal related issue, so I am trying to figure out how they work and what they do.
Re: Can someone explain what script signals are?
This old chestnut;
Basically its a way to kill previously called (Thread) functions.
SetSignalMask assigns a bitmask to the (Thread) function it is called from.
Every call to Signal that matches in a bitwise AND will kill the function.
e.g.
Foo() and Foo2() will kill any previous instances of themselves every time they are called (this is the common pattern with AimWeapon), Bar() will kill both Foo() and Foo2(). Note that Elmo() will inherit the signal mask of the function calling it - and consequently Bar() kills Elmo() too.
See also:
http://springrts.com/phpbb/viewtopic.ph ... start=2%7C
http://springrts.com/wiki/Animation-CobThreads#Signals
Basically its a way to kill previously called (Thread) functions.
SetSignalMask assigns a bitmask to the (Thread) function it is called from.
Every call to Signal that matches in a bitwise AND will kill the function.
e.g.
Code: Select all
function Foo()
Signal(4)
SetSignalMask(4) -- 100
-- Do Stuff
Spring.StartThread(Elmo)
end
function Foo2()
Signal(2)
SetSignalMask(2) -- 010
--Do Stuff
end
function Bar()
Signal(6) -- 110
-- Do stuff
end
See also:
http://springrts.com/phpbb/viewtopic.ph ... start=2%7C
http://springrts.com/wiki/Animation-CobThreads#Signals
Re: Can someone explain what script signals are?
That is problematic. That means in order to have a 32nd weapon we would have to have a positively huge number or do I not understand this correctly?
Re: Can someone explain what script signals are?
You could of course kill your scrips manually.
For example having a looping script check a condition etc.
For example having a looping script check a condition etc.
Re: Can someone explain what script signals are?
LUS signal masks do not have to be numbers.
Re: Can someone explain what script signals are?
What else can they be?
Re: Can someone explain what script signals are?
In technical info, using bitmasks is quite neat.. i dont see why this is troublesome.
Re: Can someone explain what script signals are?
Any lua object:smoth wrote:What else can they be?
http://springrts.com/phpbb/viewtopic.ph ... al#p454171
also:
http://springrts.com/phpbb/viewtopic.ph ... al#p517392
Re: Can someone explain what script signals are?
They are neat for smaller applications. I find the way they constrain things to be clumsy and inflexible.PicassoCT wrote:In technical info, using bitmasks is quite neat.. i dont see why this is troublesome.
Re: Can someone explain what script signals are?
why, you can end multiple threads by knowing the hexadecimal killerconstant.. its comfy
Re: Can someone explain what script signals are?
except that you have to be really careful which ids you use. that makes it cumbersome. Want to add a new id? have fun.
Re: Can someone explain what script signals are?
Just use powers of two: 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, ...
As Kloot said, abandon BOS/COB and use Lua unit scripts.
Yes that would be problematic. TA bos/cob are limited to 32 bits signed integer, which means they must be in the range [2^31 , 2^31-1]. So you can't have a 32nd weapon. Because 2^32 would not be a positively huge number, it would be a number so huge it would overflow and come back negative.smoth wrote:That is problematic. That means in order to have a 32nd weapon we would have [...]
As Kloot said, abandon BOS/COB and use Lua unit scripts.
Re: Can someone explain what script signals are?
I am using a lua script. It tries to treat numbers as values for a bitwise evaluation.
if I had it my way I would do 1,2,3,4,5 as the signal id. however, it tries to handle that via bitwise. my bug with the script was because I put 515 instead of 512 which it then did the bitwise evaluation and BAM weapons were getting their signal canceled.
if I had it my way I would do 1,2,3,4,5 as the signal id. however, it tries to handle that via bitwise. my bug with the script was because I put 515 instead of 512 which it then did the bitwise evaluation and BAM weapons were getting their signal canceled.
Re: Can someone explain what script signals are?
As FLOZi links to TOBI posts point out : In LUS, don't use numbers, but unique empty table object, so you can have unlimited signals.
Re: Can someone explain what script signals are?
This is for a generic script that covers most units. The Sig IDs ARE in a table already. so what? need to do "a","b","c"? Why can't I just use a look up table with numbers? You guys say create a table but the example I saw shows IDs being assigned some string.
the term table in lua can mean many things including but not limited to A FUNCTION.
So you are saying my signal tag can be a function? That makes very little sense to me.
the term table in lua can mean many things including but not limited to A FUNCTION.
So you are saying my signal tag can be a function? That makes very little sense to me.
Re: Can someone explain what script signals are?
I see, I went over it with Kingraptor. I get it now.
Re: Can someone explain what script signals are?
Please post a brief description of the solution.
Re: Can someone explain what script signals are?
http://paste.springfiles.com/view/175ab271
I read this, saw that the code has some retarded kludge that if something is a number it tries to treat it as a bitwise evaluation.
complained a bit.
did this.
stopped caring.
I read this, saw that the code has some retarded kludge that if something is a number it tries to treat it as a bitwise evaluation.
complained a bit.
did this.
Code: Select all
local SIG_AIM = {}
for i=1, 32 do
SIG_AIM[i] = {}
end
Re: Can someone explain what script signals are?
Code: Select all
Signal(2 ^ (weaponID - 1))
edit:
In fact as Spring lua uses 32bit floats to represent numbers, the largest integer it can represent is 2^24, so if you wish to use more than 25 weapon IDs (don't forget 2^0) you will need to use non-numerical Signals for at least some of them.
Re: Can someone explain what script signals are?
Signal checks the type of the mask var. If mask is a number, it does bitwise.