Jump to content

(Question) How to unattach script from itself?


Rinart73

Recommended Posts

When I'm trying to do something like this in script that I attached earlier:

-- MyScript
function initialize()
    local entity = Entity()
    if someCondition then
        entity:removeScript(pathToMyScript)
    end
end

server just crashes with error "EXCEPTION_ACCESS_VIOLATION".

 

So.. how to removeScript from itself?

Link to comment
Share on other sites

When I'm trying to do something like this in script that I attached earlier:

-- MyScript
function initialize()
    local entity = Entity()
    if someCondition then
        entity:removeScript(pathToMyScript)
    end
end

server just crashes with error "EXCEPTION_ACCESS_VIOLATION".

 

So.. how to removeScript from itself?

 

just use terminate() instead ... it sets the script to invalid and removes it automagically on the next ocassion!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...