Jump to content

Too many arguments. Why?


antstubell

Recommended Posts

Can somebody explain why this script is fine...

 

ObjectReference Property ObjToActivate1 Auto

Event OnActivate(ObjectReference akActionRef)
if (akActionRef == Game.GetPlayer())

ObjToActivate1.Activate(self)
Disable(self)

Endif
EndEvent

 

… but this script...

 

ObjectReference Property ObjToActivate1 Auto

Event OnActivate(ObjectReference akActionRef)
if (akActionRef == Game.GetPlayer())

ObjToActivate1.Activate(self)
Delete(self)

Endif
EndEvent

 

… gives the error...

too many arguments passed to function

?

Link to comment
Share on other sites

Correct way to script this :

 

 

ObjectReference Property ObjToActivate1 Auto
Event OnActivate(ObjectReference akActionRef)
if (akActionRef == Game.GetPlayer())
ObjToActivate1.Activate(self)
Self.Disable()
Endif
EndEvent
..................................................................................................................
ObjectReference Property ObjToActivate1 Auto
Event OnActivate(ObjectReference akActionRef)
if (akActionRef == Game.GetPlayer())
ObjToActivate1.Activate(self)
Utility.Wait(1.0)
Self.Disable()
Self.Delete()
Endif
EndEvent

It's recommended to "Wait" before "Disable/Delete", if before you have an "Activate()" function, the reason is that the "Activate()" can easily be interrupted before the "activate()" function is finish.
Example: if the activated object has an animation to play that need some seconds to execute.
* Also disable before delete.
Edited by maxarturo
Link to comment
Share on other sites

My bad. Should have been...

 

ObjectReference Property ObjToActivate1 Auto
ObjectReference Property ObjToDis1 Auto

Event OnActivate(ObjectReference akActionRef)
if (akActionRef == Game.GetPlayer())

ObjToActivate1.Activate(self)
ObjToDis1.disable()
Self.Delete()

Endif
EndEvent

 

Sorry maxarturo page didn't load quick enough to see your reply. Of course you're correct and I noticed it just now.

 

EDIT: You forgot Utility.wait(1.0) and 1.0 is quite a long time. I prefer 0.2.

Link to comment
Share on other sites

Don't mention it, we all make stupid mistakes !.

You can't even start to imagine what kept me busy the last 4 days, a completely newbie's mistake !...... @#!*%@#$......

 

Edit: Yeah.... you see what i mean !...... #@&*!@*#(%&^^^.....

* Corrected.

Edited by maxarturo
Link to comment
Share on other sites

maxarturo: I am very surprised by your patience with such postings. Thank you..

 

antstubell wrote: "Can somebody explain why.."

; https://www.creationkit.com/index.php?title=Disable_-_ObjectReference
Function Disable(bool abFadeOut = False) native

    Disable(self)        ; compiles fine, because SELF will be treated as Bool

; https://www.creationkit.com/index.php?title=Delete_-_ObjectReference
Function Delete() native

    Delete(self)    ; error: "too many arguments passed to function"
                    ; no argument in native function, SELF cannot be treated as Bool

maybe you should use next code that makes sure you do not use a property which is the same as SELF (persistence circle would occur otherwise)

  ObjectReference PROPERTY ObjToActivate1 auto

EVENT OnActivate(ObjectReference akActionRef)
IF (akActionRef == Game.GetPlayer() as ObjectReference)
ELSE
    RETURN    ; - STOP -
ENDIF
;---------------------
    gotoState("Done")            ; ### STATE ###

    ObjToActivate1.Activate(self as ObjectReference)
    Utility.Wait(0.25)           ; adjust the waittime, if needed (see previous posting of maxarturo)

    self.Disable()
    self.Delete()
ENDEVENT


;===============================
state Done    ; do not use the activation event anymore
;=========
EVENT OnActivate(ObjectReference akActionRef)
ENDEVENT
;=======
endState
Edited by ReDragon2013
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...