Set declaration madness
Re:
21 years 4 months agoOriginally posted by Second Chance
Here's your problem right here:You can't assign a value to a variable during declaration.pos1 = iMapEntity.FindByName("Lucrecia's Base");
You can assign a variable during declaration. You just have to declare the variable type first:
hmapentity pos1 = iMapEntity.FindByName("Lucrecia's Base");
and for example even 'cast' to a different type:
hsim pos1 = iSim.Cast ( iMapEntity.FindByName("Lucrecia's Base"));
Works using sets and lists too:
list port_list = List.FromSet ( iDockport.DockportsOfType ( iSim.Cast ( turret_ship ), DT_Cargo, DS_Free ) );
Iwar2 Multiplayer Fan Site
Please Log in or Create an account to join the conversation.
Re:
21 years 4 months ago
Yes, assigning values during declaration is perfectly fine. The problem here is that all declarations must be made at the beginning of a function or task. Once you do something that is not a declaration, you cannot declare anything more. Assigning a value is not a declaration, so unless it is done on the same line as a declaration, there can be no more declarations after that point.
I'm not sure if I'm being very clear, so here are bad and good examples:This does not work because pos1 = ... is not a declaration. You cannot declare anything after that point, so set local_fighters does not work.
This would work because everything is a declaration. Until the first non-declaration line of code for the function, you can keep declaring stuff all you want.
I'm not sure if I'm being very clear, so here are bad and good examples:
Code:
hmapentity pos1;
hship player_ship;
hship marauder1;
hfaction marauder_faction;
pos1 = iMapEntity.FindByName("Lucrecia's Base");
set local_fighters; // This is the set
Code:
hship player_ship;
hship marauder1;
hfaction marauder_faction;
hmapentity pos1 = iMapEntity.FindByName("Lucrecia's Base");
set local_fighters; // This is the set
Please Log in or Create an account to join the conversation.
Re:
21 years 4 months agoOriginally posted by EricMan64
Yes, assigning values during declaration is perfectly fine. The problem here is that all declarations must be made at the beginning of a function or task. Once you do something that is not a declaration, you cannot declare anything more. Assigning a value is not a declaration, so unless it is done on the same line as a declaration, there can be no more declarations after that point.
That's a perfect explanation. It seems this threat becomes a fine beginners guide to pog - coding.
Please Log in or Create an account to join the conversation.
Re:
21 years 4 months ago
I plead the 5th.
No wait, even better; I plead that it was 5am when I wrote that.
Now it's 3pm. I just woke up, and my head hurts.
That my story, and I'm sticking to it.
Where's the water? [xx(]
mailto:second_chance@cox.net
The Ultimate Guide To Modding: I-War 2 - Edge Of Chaos (on hold during SW MP mod)
cartoons.sev.com.au/index.php?catid=4
.
No wait, even better; I plead that it was 5am when I wrote that.
Now it's 3pm. I just woke up, and my head hurts.
That my story, and I'm sticking to it.
Where's the water? [xx(]
mailto:second_chance@cox.net
The Ultimate Guide To Modding: I-War 2 - Edge Of Chaos (on hold during SW MP mod)
cartoons.sev.com.au/index.php?catid=4
.
Please Log in or Create an account to join the conversation.
Re:
21 years 4 months agoOriginally posted by Second Chance
That my story, and I'm sticking to it.
LOL Whats the problem? You were right, I was right and EricMan too.
EricMans explanation was the best for a pog beginner. I think he would make a good teacher/lecturer someday [8D]
We are so deep into the stuff we take too much for granted.
lo-tekk, we're glad to see a new pogger around

Iwar2 Multiplayer Fan Site
Please Log in or Create an account to join the conversation.
Re:
21 years 4 months ago
Oops. I wasn't in much better shape when I wrote that post then when I wrote the first one. mailto:second_chance@cox.net
The Ultimate Guide To Modding: I-War 2 - Edge Of Chaos (on hold during SW MP mod)
cartoons.sev.com.au/index.php?catid=4
.
Please Log in or Create an account to join the conversation.