Community Forum

FS15 trigger problem

Forum Overview >> Scripting

CategoryScripting
Created04.09.2015 21:58


Jim Panousis (Jimi540) 04.09.2015 22:05
Hello,

I have a problem with a trigger i'm trying to create.

In my map i put an object with a sriptcallback attribute which is:
name: onCreate
value: modOnCreate.TEST

In my script i wrote:

TEST = {};

local TEST_mt = Class(TEST, Object);
InitObjectClass(TEST, "TEST");

function TEST.onCreate(id)
print("trigger test");
end;

etc....

It seems that it is not working as i don't get any print.
What's the problem?

Ron Smith (pasnthru99) 10.09.2015 20:39
shouldn't the print option be first?

Jim Panousis (Jimi540) 10.09.2015 23:13
I'm using the "print" function just to confirm that the onCreate worked.
In my case didn't print, so onCreate didn't worked, and i don't know why.

Any help? Giants? Anyone?

Emil Drefers (Unknown) 11.09.2015 18:35
Hi,

the "onCreate" attribute has a wrong value.

Ron is somehow right, you could add a further print on the very first line of your script to check if it loaded at all.
But that's not the actual problem ;)

the "onCreate" function in your script should be named:

function onCreate(id)
print("MyMod doing a test");
end

Assuming that the mod's name is "MyMod" the user attribute in the trigger should be:
MyMod.onCreate

Does that help?

Cheers,
Emil


Jim Panousis (Jimi540) 12.09.2015 15:27
Hello Emil,

Yes now it worked, but still i can't understand why it didn't worked with the modOnCreate value.

I want to make it more dynamicallly as if i change my mod name now it won't work.
Can you tell me what i must write in the script and what in the attribute value for this setup?

Thanks

Emil Drefers (Unknown) 14.09.2015 08:21
Hi,

that's not possible.
The user attribute "onCreate" must know the mod's name in advance.
Otherwise it is completly unclear which mod has to be used by/for this object.

Cheers,
Emil


Note: Log in to post. Create a new account here.