User Tools

Site Tools


4rpl:commands:setunitwantsern

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
4rpl:commands:setunitwantsern [2024/06/13 18:56] – [Workaround for SetUnitWantsErn(<-uid 0)] Kalli4rpl:commands:setunitwantsern [2025/03/24 04:21] (current) – Mentioned undock issue in description and added function quick copy. Vertu
Line 11: Line 11:
 ===== Description ===== ===== Description =====
 Sets whether the unit with the specified UID desires an ERN. Pass `true` to make the unit desire ERN, or `false` to indicate it does not. Sets whether the unit with the specified UID desires an ERN. Pass `true` to make the unit desire ERN, or `false` to indicate it does not.
 +
 +Beware that when an ERN is docked to a unit, you can't use this API to have that unit release the ERN by having it no longer want one. See the workaround code if this is a concern.
  
  
Line 26: Line 28:
 # and recreate it without the ERN. That's what this function is for. # and recreate it without the ERN. That's what this function is for.
  
-<-uid GetUnitWantsErn not GetUnitErnState AND if+<-uid GetUnitWantsErn not <-uid GetUnitErnState AND if
   <-uid @freeErnFromUnit   <-uid @freeErnFromUnit
  endif  endif
Line 32: Line 34:
 :freeErnFromUnit :freeErnFromUnit
 ->UID ->UID
-  <-UID getunitconstructingdata ev2 dup -1 eq if pop 999 endif ->buildResources+  <-UID getunitconstructingdata ev2 pop dup -1 eq if pop 999 endif ->buildResources 
 +  <-UID getunittype <-UID getunitposition <-UID getunitsettings createunit dup ->newUID <-buildResources constructunit 
 +  # Resources that are on the way to the old unit will be lost. 
 +   
 +# Enable/disable the settings that you don't need by commenting them out. 
 +  <-newUID <-UID  
 +    # dup2 getunitmaxammo setunitmaxammo 
 +    dup2 getunitammo setunitammo 
 +    dup2 getunitcandestroy setunitcandestroy 
 +    dup2 getunitselectable setunitselectable 
 +    dup2 getunitenabled setunitenabled 
 +    dup2 getunitarmed setunitarmed 
 +    dup2 getunitsupplied setunitsupplied 
 +    # dup2 getunithealrate setunithealrate 
 +    # dup2 getunitmaxhealth setunitmaxhealth 
 +    dup2 getunithealth setunithealth 
 +    # dup2 getunitrange setunitrange 
 +    dup2 getunitstuncount setunitstuncount 
 +    dup2 getunitmovecell dup -1 neq if setunitmovecell else pop pop pop pop endif  
 +    pop pop 
 +     
 +<-UID 1 1 1 destroyunit  
 + 
 +</code> 
 +Just the function (for quick copy and paste): 
 +<code 4rpl> 
 +:freeErnFromUnit 
 +->UID 
 +  <-UID getunitconstructingdata ev2 pop dup -1 eq if pop 999 endif ->buildResources
   <-UID getunittype <-UID getunitposition <-UID getunitsettings createunit dup ->newUID <-buildResources constructunit   <-UID getunittype <-UID getunitposition <-UID getunitsettings createunit dup ->newUID <-buildResources constructunit
   # Resources that are on the way to the old unit will be lost.   # Resources that are on the way to the old unit will be lost.
4rpl/commands/setunitwantsern.1718304971.txt.gz · Last modified: 2025/02/14 14:56 (external edit)