Game Development Community

Creating Datablocks

by Alex Huck · in Torque Game Engine · 06/06/2006 (5:34 pm) · 1 replies

(Noob question)
Hi, I'm trying to create a new datablock classification called "missionWeatherData(missionName)" What I am trying to do is make datablocks, which contain information on the odds a certain weather. To let me have control over the climates of each zone (No snow in a sand desert)

Here is a demo of what it would look like making one for a zone called "missionName":
Definition of "missionName"s weather attributes
datablock missionWeatherData(missionName) {
oddsRain = 0.3; // 30% chance of rain
oddsSnow = 0; // It will never snow
oddsFog = 0.2; // 20% chance it will get foggy
fogAmount = 0.5; // A percent, 100% (1) fog is nearly no visability
oddsLightning = 0.1; // 10% chance of a lightning storm
};


In the game, here is where it will add the Object to the scene:

new missionWeather(FPSWeather) {
dataBlock = "missionName";
};

Here it says what will happen when it is added to the scene:

function missionWeather::onAdd(%this, %obj) {
%mission = %this.getDatablock();
%oddsRain = %this.oddsRain;
%oddsSnow = %this.oddsSnow;
%oddsFog = %this.oddsFog;
%fogAmount = %this.fogAmount;
%oddsRain = %this.oddsLightning;
// startWeatherCycle will create a new weather scenario every 5 minutes, what weather it will pick is based on the odds, which are inputed
startWeatherCycle(%oddsRain, %oddsSnow ,%oddsFog ,%fogAmount ,%oddsLightning);
}

My questions:

Question 1) Does this even slightly resemble proper syntax for creating datablocks? I havn't been able to test it much, because of question 2, which brings me to...

..Question 2) Once I do the datablock declaration at the top it says "Unable to instantiate non-conobject class missionWeatherData."

I assume this means it doesn't have the datablock classification "missionWeatherData" In it's vocabulary so to speak, it doesn't know what it means. So how do I tell it what to do. What I want is a simple datablock that holds weather attributes of each zone, so that when I create a missionWeather Object in my zone, it calls "startWeatherCycle();" With the proper arguments based on what that particular zones datablock has to say about weather conditions.
Do I need the source to add these new class defines?

In short all I want is a "Datablocks for dummies" guide. :)

#1
07/11/2006 (8:39 am)
A simpler solution would be to make a scriptObject that held all theses values, set the class property on the scriptobject to the name of the missionWeather . datablocks need to declared in C you can't just make datablocks for non existing items.


new scriptObject(){ class = fred};
function fred::onAdd(%this){ };
function fred::anotherFunction(%this){};