When to use Detach()

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
blckfire
Apprentice Poster
Posts: 54
Joined: Thu Feb 26, 2015 10:28 am

When to use Detach()

Post by blckfire »

So, I've got a couple of scripts that are fired up after a character does some actions. Are these scripts attached to the character or are they ran separately?

The kind of script is something like this:

Code: Select all

program x

somecode....

Start_Script(":somepackage:somescript", params);

endprogram
So, is that script attached to a character and therefore needs to be detached or I don't need to worry about it? I read in the forums that normally you use detach when you're running a use script but I don't think this is the case.
RusseL
Forum Regular
Posts: 375
Joined: Fri Feb 20, 2009 8:30 pm

Re: When to use Detach()

Post by RusseL »

Hi,
as far as i know Start_Script starting already detached script, but you can easily test it with character.attached() method, so you can see which script is attached atm.

A script is attached when you use any item and get sysmessage "you are already doing another action". So if you want to avoid it and execute any use_script 'background' use detach().

Usecase:

Code: Select all

sendsysmessage(who, "You start crafting an item....");
Detach();
// After this line you are able to use another items
sleep(10);
MakeNewItem(who.backpack, blabla, .....);
blckfire
Apprentice Poster
Posts: 54
Joined: Thu Feb 26, 2015 10:28 am

Re: When to use Detach()

Post by blckfire »

Thank you, it's pretty much how I thought it worked, I just wanted to be sure since the code I have is a bit outdated (POL96).

In my case I have a few background scripts that control some stats and effects of the player and, ofc I want the character to be able to perform other actions while these are running.
Post Reply