Bad syntax in for loop?
18 years 11 months ago #18670
by JT
_______________
Surgeon-General's Warning: Early test cases of Torn Stars have resulted in fatalities. The errors in the software should be gone by now. Hopefully.
Bad syntax in for loop? was created by JT
I spent the better part of yesterday tweaking the Torn Stars suite files to include some of my more-favourite themes from Freelancer. When I tested the revised suites in the game, they worked great: the Ambient music played just like it should have (the Alcuin system meshes pretty well with the Rheinland theme, I figure). However, the Tension and Action music didn't play when I decided to go test out that feature by pissing off the locals quite royally.
I reviewed the source code of Torn Stars to discover why: the tMusic package provides basic support for combat music, but has no functionality to actually start it!
As an enterprising Canadian (read: exceedingly bored), I figured it was my very duty to write a package of my own to patch in this ability. TS_Combat_Music_JT was born.
However, I'm running into a wall. I've gotten the Pog SDK set up nicely, and have been trying to ram a pretty nice chunk of code into it. Unfortunately, PC doesn't like my for loop.
Does anyone have any ideas what's going on? My syntax looks fine to me. If it were walking down the street, I'd even give it a wolf whistle.
<font face="Courier New">\Jeremy\games\simulation\iwar2\TornStars\TS_Combat_Music_JT.pog(68) : Error: Syntax error("i")</font id="Courier New">
_______________
"The art of flying is to throw yourself at the ground and miss." --Douglas Adams
I reviewed the source code of Torn Stars to discover why: the tMusic package provides basic support for combat music, but has no functionality to actually start it!
As an enterprising Canadian (read: exceedingly bored), I figured it was my very duty to write a package of my own to patch in this ability. TS_Combat_Music_JT was born.
However, I'm running into a wall. I've gotten the Pog SDK set up nicely, and have been trying to ram a pretty nice chunk of code into it. Unfortunately, PC doesn't like my for loop.
Does anyone have any ideas what's going on? My syntax looks fine to me. If it were walking down the street, I'd even give it a wolf whistle.
Code:
//miscellaneous irrelevant code snipped
task monitor_environment()
{
hship player = iShip.FindPlayerShip();
hship ship;
int i;
int restart;
set ships;
list player_fleet;
float delay_time;
while(1) {
//Do we have hostiles?
ships = iSim.PlayerHostilesInRadius(100km, TM_Ship);
if(Set.ItemCount(ships)) {
//Check every ship in the fleet to see if it has been attacked
player_fleet = Global.List("g_epic_fleet_player_list");
//If the fleet hasn't been loaded yet, we'll wait a couple of
// seconds and then try again.
if(List.IsEmpty(player_fleet)) {
Task.Sleep(Task.Current(), 2.0);
continue;
}
for(i = 0; i < List.ItemCount(player_fleet); i++) { // ***LINE 68***
ship = List.GetNth(i);
...
<font face="Courier New">\Jeremy\games\simulation\iwar2\TornStars\TS_Combat_Music_JT.pog(68) : Error: Syntax error("i")</font id="Courier New">
_______________
"The art of flying is to throw yourself at the ground and miss." --Douglas Adams
_______________
Surgeon-General's Warning: Early test cases of Torn Stars have resulted in fatalities. The errors in the software should be gone by now. Hopefully.
Please Log in or Create an account to join the conversation.
18 years 11 months ago #14398
by mdvalley
Replied by mdvalley on topic Bad syntax in for loop?
The i++ is the problem. Despite what the SDK says, POG does not in fact support “variable++�. However, “++variable� works fine. Use:
for(i = 0; i < List.ItemCount(player_fleet), ++i)
instead.
for(i = 0; i < List.ItemCount(player_fleet), ++i)
instead.
Please Log in or Create an account to join the conversation.
18 years 11 months ago #14400
by JT
_______________
Surgeon-General's Warning: Early test cases of Torn Stars have resulted in fatalities. The errors in the software should be gone by now. Hopefully.
Replied by JT on topic Bad syntax in for loop?
Ah, thankee.
Also noticed I made a booboo on the very next line, forgetting to include player_fleet in the arguments of the List.GetNth() function... almost makes you think that they used C instead of C++ to make Flux and Independence War 2, with their non-object-oriented library features.
_______________
"The art of flying is to throw yourself at the ground and miss." --Douglas Adams
Also noticed I made a booboo on the very next line, forgetting to include player_fleet in the arguments of the List.GetNth() function... almost makes you think that they used C instead of C++ to make Flux and Independence War 2, with their non-object-oriented library features.
_______________
"The art of flying is to throw yourself at the ground and miss." --Douglas Adams
_______________
Surgeon-General's Warning: Early test cases of Torn Stars have resulted in fatalities. The errors in the software should be gone by now. Hopefully.
Please Log in or Create an account to join the conversation.
18 years 11 months ago #14401
by JT
_______________
Surgeon-General's Warning: Early test cases of Torn Stars have resulted in fatalities. The errors in the software should be gone by now. Hopefully.
Replied by JT on topic Bad syntax in for loop?
I've got my code compiling happily now. Surprisingly, it works. The Tension music does give me a "sixth sense" in terms of recognising danger, which isn't quite so realistic, but I'm enjoying the combat quite a bit more all the same because it doesn't seem quite so empty.
I can distribute the mod files to anyone who wishes, but they'll have to obtain their own music for the suite files -- like our good friend Mr. Robertson, I will never transcend legal rights. It's the principle, dagnabbit!
Without a custom set of suite files, the mod has little or no use in the Torn Stars library.
Here's my suite for "Empire", for example:
I've also been considering a suite like this:
That's because the Freelancer race music is pretty tense stuff. And because it sounds downright cool. That part's important too.
_______________
"The art of flying is to throw yourself at the ground and miss." --Douglas Adams
I can distribute the mod files to anyone who wishes, but they'll have to obtain their own music for the suite files -- like our good friend Mr. Robertson, I will never transcend legal rights. It's the principle, dagnabbit!
Without a custom set of suite files, the mod has little or no use in the Torn Stars library.
Here's my suite for "Empire", for example:
Code:
[Suite_properties]
key_name=empire
[Ambient]
stream[0]=sound:\audio\music\music_li_space
[Action]
stream[0]=sound:\audio\music\music_li_battle
[Discovery]
stream[0]=sound:\audio\music\music_li_space
[Tension]
stream[0]=sound:\audio\music\music_li_danger
[Theme]
stream[0]=sound:\audio\music\music_li_space
I've also been considering a suite like this:
Code:
[Suite_properties]
key_name=empire
[Ambient]
stream[0]=sound:\audio\music\solarwind
[Action]
stream[0]=sound:\audio\music\music_race_loop
[Discovery]
stream[0]=sound:\audio\music\solarwind
[Tension]
stream[0]=sound:\audio\music\music_race_start
[Theme]
stream[0]=sound:\audio\music\solarwind
That's because the Freelancer race music is pretty tense stuff. And because it sounds downright cool. That part's important too.
_______________
"The art of flying is to throw yourself at the ground and miss." --Douglas Adams
_______________
Surgeon-General's Warning: Early test cases of Torn Stars have resulted in fatalities. The errors in the software should be gone by now. Hopefully.
Please Log in or Create an account to join the conversation.
- Second Chance
- Offline
- King of Space
18 years 11 months ago #14402
by Second Chance
Replied by Second Chance on topic Bad syntax in for loop?
Wow, another POG coder! Looks like TS is just what the doctor ordered for this community. Again, kudos to all the TS members.
Between all the new Pog-coding blood TS is bringing in, and the PSO and texture stuff Jasper is working on; I predict exiting times ahead.
mailto:second_chance@cox.net
The Ultimate Guide To Modding: I-War 2 - Edge Of Chaos
.
Between all the new Pog-coding blood TS is bringing in, and the PSO and texture stuff Jasper is working on; I predict exiting times ahead.
mailto:second_chance@cox.net
The Ultimate Guide To Modding: I-War 2 - Edge Of Chaos
.
Please Log in or Create an account to join the conversation.