Hi Guys,
I wanted to add an animated object to a room. So I created the obejct oLight. I made a view, tried the preview and its working.
I added this to the room script:
function room_Load()
{
oLight.SetView(3);
}
function room_AfterFadeIn()
{
oLight.Animate(0, 5, eRepeat, eNoBlock);
}
But when I start the game, it is still showing the cup image and not the view. If I rightclick on view 3 and search for usages it finds no usage..
Am I missing something obvious? Thanks for any helpful comments :)
For event handlers that are supposed to be called automatically when certain things happen, you can't just add them to the script, you have to link them up in the room event properties pane.
Hey Snarky,
Thanks for your reply! Sorry, but can you describe what you mean with link them up? I did go to the room events in the properties and put it in the room script there. Do you mean something else?
Did you type it or did you click the ... button? Try clicking the button, if it doesn't take you to the start of the corresponding function check the that the names are exactly the same. Best way to fix this, if it's the problem, is to delete one of them and copy/paste the name of the other.
Add a Display() call, like this:
function room_AfterFadeIn()
{
Display("AfterFadeIn called");
oLight.Animate(0, 5, eRepeat, eNoBlock);
}
Do you see that in-game?
As an additional note -
Quote from: Racoon on Mon 18/11/2019 23:27:09
If I rightclick on view 3 and search for usages it finds no usage.
this won't show any usage if you are setting this view in script, only if you have a view set from the beginning in the editor, which currently is only possible with characters. So, this command has a limited purpose.
Okay, I know get what you mean with, that I cant just put it in the script. I finally got it working, yay. Its difficult as a beginner to figure some of these things out. Thanks everyone :-D
For reference, in case somebody else finds this thread, what did you do to fix it?
My mistake was, that I found the script for an animated object on the forums and thought it would just do to copy it to the room script. But for it to work you have to go to the room properties and for example if you want to use "room_AfterFadeIn" you have to click on the "..." next to "Enters room after fade-in" for the function to work.
That's a mistake many many people do...
Glad it's sorted ;)