Scripting Question: Schedules
by Donny Wilbanks · in Torque Game Engine · 04/10/2004 (2:41 pm) · 8 replies
Well, Here we go again with the questions. As I see Schedules are a way of assign a event of some sort. I am trying to figure out where to place a schedule script. I have no idea were to start (mostly comes from lack of set places to work with).
(nice thing about neverwinter nights, it had a pretty much state place to place these (the nwn toolset was nifty in that respect), it was called OnHeartBeat - so don't get confused when I mention Heartbeat at some point. It's basicly a scheduling a event - I spent about a year or so playing with it). But the nice thing is that events can be scheduled to run at different times and the like.
I am sure you can attach them to objects (such as players) and other objects (such as special markers). I just lack a good clean example to see WHERE to place them...
So I want to create a event (scheadule)that is checked every seconed? I think I can figure out the proccess of the script it's self, but where to attach it?
the idea is to give a fuel rating to the vechile I am driving, once a seconed check speed and reduce fuel by x amount. But what I don't understand is where to attach the scheadule script?
Can you attach scheadules to objects? (hearbeat type thing)?
(nice thing about neverwinter nights, it had a pretty much state place to place these (the nwn toolset was nifty in that respect), it was called OnHeartBeat - so don't get confused when I mention Heartbeat at some point. It's basicly a scheduling a event - I spent about a year or so playing with it). But the nice thing is that events can be scheduled to run at different times and the like.
I am sure you can attach them to objects (such as players) and other objects (such as special markers). I just lack a good clean example to see WHERE to place them...
So I want to create a event (scheadule)that is checked every seconed? I think I can figure out the proccess of the script it's self, but where to attach it?
the idea is to give a fuel rating to the vechile I am driving, once a seconed check speed and reduce fuel by x amount. But what I don't understand is where to attach the scheadule script?
Can you attach scheadules to objects? (hearbeat type thing)?
#2
Sure, you could create a script called game_events.cs. This would work fine. Or you could kick off the schedule in the onAdd method of the appropriate objects. Or for per-mission schedules, do it in the .mis file.
04/10/2004 (6:57 pm)
Yes, have you checked out the SimObject method called... er... schedule? :)Sure, you could create a script called game_events.cs. This would work fine. Or you could kick off the schedule in the onAdd method of the appropriate objects. Or for per-mission schedules, do it in the .mis file.
#3
04/10/2004 (7:39 pm)
Alright I will take a look in that direction. At this moment I can only work with the script side of things, but allot can be done with that.
#4
04/10/2004 (11:06 pm)
The method I'm referring to is only usable by script, so you should be fine.
#5
04/11/2004 (6:50 am)
Yahhhooo!...
#6
04/11/2004 (7:06 am)
Donny basically what you want to do is simply start the schedule, really anywhere you want, then have the schedule call itself.%blahObject.schedule(1000, "updateFuel");
function blahObject::updateFuel(%this)
{
%fuel = %fuel - 100;
%this.schedule(1000, "updateFuel");
}
#7
In the fps demo aiPlayer.cs this line confuses me:
%obj.schedule(5000, "setScanningPlayers", "true");
there is no function called "setScanningPlayers" that I can find. I assume %obj is the reference to the current function which is onAttackTargetEnterLOS.
So should it really be this?
%this.schedule(5000, "onAttackTargetEnterLOS", "true");
06/04/2004 (11:44 am)
John, your example has a function called updateFuel and I can see where you schedule using the name of the function as a reference. In the fps demo aiPlayer.cs this line confuses me:
%obj.schedule(5000, "setScanningPlayers", "true");
there is no function called "setScanningPlayers" that I can find. I assume %obj is the reference to the current function which is onAttackTargetEnterLOS.
So should it really be this?
%this.schedule(5000, "onAttackTargetEnterLOS", "true");
#8
When you schedule an event for an object as above, its calling a member function/method and passing parameters. %obj is an AIPlayer object above.
I belive you can also do it by itself to call a function that isnt a member function, etc.
I belive you LOS example should be correct...
-s
06/04/2004 (2:33 pm)
There are two syntaxes for the schedule event.When you schedule an event for an object as above, its calling a member function/method and passing parameters. %obj is an AIPlayer object above.
I belive you can also do it by itself to call a function that isnt a member function, etc.
I belive you LOS example should be correct...
-s
Torque Owner Donny Wilbanks
Alright since the game itself loads up the scripts (server side)
game.cs
by adding say
function onServerCreated()
(
...
exec(./game_events.cs");
...
}
create a script that holds the specific event specials?