4rpl:commands:registerscript
                
                                                            
                    
Differences
This shows you the differences between two versions of the page.
 
| Both sides previous revisionPrevious revisionNext revision | Previous revision | 
| 4rpl:commands:registerscript [2022/05/11 13:29]  –  Karsten75 | 4rpl:commands:registerscript [2025/02/14 14:57] (current)  – external edit 127.0.0.1 | 
|---|
| ~~NOTOC~~ | ~~NOTOC~~ | 
| <=[[4rpl:start| Index]] | <=[[4rpl:start| Index]] \\ | 
|  | <= [[4rpl:start#Messaging]] | 
|  |  | 
| :!: Available in version 1.3 and later. | :!: Available in version 1.3 and later. | 
|  |  | 
| === Discussion === | === Discussion === | 
| This was added to CW4 as an attempt to give a similar API to what was in CW3.  [[|Messaging]] is likely the better option in most cases. | This was added to CW4 as an attempt to give a similar API to what was in CW3.  Messaging is likely the better option in most cases. | 
|  |  | 
| This works a lot like messaging.  There is a global map and RegisterScript adds an entry into that map with the name you specify and the script it is called from.  So it stores a named reference to a script instance in a global map,  Get/SetRegiseredScriptVar looks up that instance in the map and then Gets/Sets a var on it.  So if you have a Foo script attached to Unit A and Foo calls RegisterScript("AName"), that will be a problem if another instance of Unit A runs Foo and it does the same thing.  So Foo would more likely call RegisterScript("AName:" self concat) or something like that.  And the only reason it would ever call RegisterScript would be so some other script could get/set some variable on it | This works a lot like messaging.  There is a global map and RegisterScript adds an entry into that map with the name you specify and the script it is called from.  So it stores a named reference to a script instance in a global map,  Get/SetRegiseredScriptVar looks up that instance in the map and then Gets/Sets a var on it.  So if you have a Foo script attached to Unit A and Foo calls RegisterScript("AName"), that will be a problem if another instance of Unit A runs Foo and it does the same thing.  So Foo would more likely call RegisterScript("AName:" self concat) or something like that.  And the only reason it would ever call RegisterScript would be so some other script could get/set some variable on it | 
 
                4rpl/commands/registerscript.1652275740.txt.gz · Last modified: 2025/02/14 14:56 (external edit)