100 of bottles of bear...
100 of bottles of bear...
nay know how to make a script that make an NPC sing one "hundred of bootles of bear on the wall, you take one..." and so on. nayone? been trying for ages
BTW if possible avoid using heartbeat
BTW if possible avoid using heartbeat
"Those who control the past control the future, those who control the present control the past" And I rule the PRESENT!!
I put the 'laughter' back in 'slaughter'
I put the 'laughter' back in 'slaughter'
In the onSpawn script, make a function that sings the line and calls itself again after a few seconds (using DelayCommand). Call that function from the main() and of you go.
[url="http://www.sorcerers.net/Games/BG2/SpellsReference/Main.htm"]Baldur's Gate 2 Spells Reference[/url]: Strategy, tips, tricks, bugs, cheese and corrections to the manual.
Originally posted by Xyx
In the onSpawn script, make a function that sings the line and calls itself again after a few seconds (using DelayCommand). Call that function from the main() and of you go.
I tried to put a while loop that did what you said but using recursion migt be a good way to do it. I'll check it out. When using the while loop I got a TMI
"Those who control the past control the future, those who control the present control the past" And I rule the PRESENT!!
I put the 'laughter' back in 'slaughter'
I put the 'laughter' back in 'slaughter'
- lunarwater
- Posts: 101
- Joined: Tue Jun 12, 2001 10:00 pm
- Contact:
I would suggest staying away from recursion because it will slowly fill up your memory after a while (if it does nothing but call itself and never return). The servers stack may start to blow chuncks eventually. My suggestion would be to rethink the while loop idea in conjunction with the DelayCommand.
Another way to do this is to create a user defined event. In the on spawn Delay a triggering of that event. Then in the main() of the event, have your bear singing code and at the end a delayed triggering of the event all over again. This way each funtion should finish up.
Another way to do this is to create a user defined event. In the on spawn Delay a triggering of that event. Then in the main() of the event, have your bear singing code and at the end a delayed triggering of the event all over again. This way each funtion should finish up.
"May your forehead grow like the mighty oak."
"May a thousand camel fleas nest in your armpits."
"May a thousand camel fleas nest in your armpits."
How does this work? An event is nothing more than just another function, isn't it? Why would you not recurse when using an event?
[url="http://www.sorcerers.net/Games/BG2/SpellsReference/Main.htm"]Baldur's Gate 2 Spells Reference[/url]: Strategy, tips, tricks, bugs, cheese and corrections to the manual.
- lunarwater
- Posts: 101
- Joined: Tue Jun 12, 2001 10:00 pm
- Contact:
Aren't the events simply handled similar to signals and interrupts? I could be wrong, because I do not know biowares underlying framework. You define the different signals (or events) and then provide the code to execute when the interrupt is caught. My guess is the function that causes an event to take place simply takes the constant that you pass in (the event variable) and then triggers this. However, like I said, Bioware could have a different implementation, in which case i would suggest the looping method.
"May your forehead grow like the mighty oak."
"May a thousand camel fleas nest in your armpits."
"May a thousand camel fleas nest in your armpits."
what happens when you uncoment the setspawnincondition line is that a local var i sset on the object. This var is later used in the actual running of that event to set of the userdefined event. This way the user defined event is fired and we use getuserdefinedeventnumber to determine what event was triggered and off we go.
@Lunarwater I don't quite get what you mean? could you clarify your first post plz
@Lunarwater I don't quite get what you mean? could you clarify your first post plz
"Those who control the past control the future, those who control the present control the past" And I rule the PRESENT!!
I put the 'laughter' back in 'slaughter'
I put the 'laughter' back in 'slaughter'
- lunarwater
- Posts: 101
- Joined: Tue Jun 12, 2001 10:00 pm
- Contact:
All I wanted to say was just a warning against using recursion with something that may go on infinitely (or until the server crashes, reboots). If the beer song ends after 100 repetitions, then disregard my posts. If not, then what I was trying to say is that if function a() calls function a(), so much memory is used for each time the function gets called (for local variables, return location, etc..). Once the function a() calls itself too many times, the system will not be able to allocate any more memory to the process and crash. Somehow, you would have to program a function that does not continuously need more memory at each iteration w/o freeing it. As for the specifics of the scripting language, I am still learning myself. I do know, however, that every recursive call can be rewritten using looping (and every loop can be rewritten using tail recursion). Sorry for any confusion. I think I've successfully done more bad than good... Good luck at any rate.
"May your forehead grow like the mighty oak."
"May a thousand camel fleas nest in your armpits."
"May a thousand camel fleas nest in your armpits."
lunawather: you are correct, speaking from a programmers perspective, that one needs to be carefull with recussion *iff* it doesn't return something(or a condition are made that breaks the method), then it will countinue endlessly as a neverending loop requiering more and more memory
So I think your warning is justified
I don't know much about NwNScript though, so can't really help you there (although I could program this in my sleep in Java )
So I think your warning is justified
I don't know much about NwNScript though, so can't really help you there (although I could program this in my sleep in Java )
Insert signature here.
Originally posted by Xandax
I don't know much about NwNScript though, so can't really help you there (although I could program this in my sleep in Java )
Me to but in pascal that is. I didn't quite get my mind about the nwn script language yet but i'm learning it quite fast so in a couple of weeks I'll probably manage this scrit quite easy but as things are now....
I haven't had the time to check any of your suggestions yet (busy programming by comp project for school) I'll try it out a.s.a.I.h.t. (as soon as I have time )
"Those who control the past control the future, those who control the present control the past" And I rule the PRESENT!!
I put the 'laughter' back in 'slaughter'
I put the 'laughter' back in 'slaughter'
I tried a couple of things. Regular recursion gives a stack overflow error almost instantly.
Using the user defined event did not cause the stack error but froze my machine. Maybe it would have given me the stack error if I waited two days, but I didn't. Not sure if that means it uses recursion or not. It certainly didn't try to execute any of the floating text code until after it was finished. I know because I once capped it off at 100 iterations and got 100 floating strings during the next five minutes.
Using the user defined event did not cause the stack error but froze my machine. Maybe it would have given me the stack error if I waited two days, but I didn't. Not sure if that means it uses recursion or not. It certainly didn't try to execute any of the floating text code until after it was finished. I know because I once capped it off at 100 iterations and got 100 floating strings during the next five minutes.
[url="http://www.sorcerers.net/Games/BG2/SpellsReference/Main.htm"]Baldur's Gate 2 Spells Reference[/url]: Strategy, tips, tricks, bugs, cheese and corrections to the manual.