Skip to content

Scripts for beginners.

User Avatar
#176
Auto-translated
Thank you, that helped. I didn't know that this command could be used to place creatures without tying them to a Faction.

Added 2 hours 42 minutes ago
Asking for advice again.

I wrote this script:
function activatorF ()
s_dwe_fa=GetObjectNamesByType("BUILDING_FAIRIE_TREE");
ReplaceDwelling(s_dwe_fa[0], TOWN_PRESERVE, 991 );
Trigger(OBJECT_TOUCH_TRIGGER, "activator", nil );
end;

Trigger(OBJECT_TOUCH_TRIGGER, "activator", "activatorF" );

SetObjectEnabled("activator", nil);

The script replaces the creatures available for recruitment in the first object found with the type "BUILDING_FAIRIE_TREE" with the 991st creature. This is done when touching "activator", but that's just a minor detail and purely for testing.

The question is, how can I make the script replace not only the first, but all found objects of this type? Another nuance is that the script should be universal and work on different maps, so the number of such objects is not only unknown, but can also be different.

And immediately a second question, for clarification, purely theoretically, is it possible to write such a script and put it somewhere in a root script file or something like that, so that it runs automatically on all maps?

Thank you in advance for your help.