Thanks to an excellent demo by Wall04 (Selection Demo) and some other help from all you guys, I think I am on my way.
But I still have a problem with variables. I defined some variables within a mob as follows;
Unit // Units players can control
MenSoliders
icon = 'mensoldier.dmi'
name = "Men Soldiers"
var
msattack = 4
msarch = 0
msdef = 4
msmoral = 23
Now I would like to be able to call up and use those variables, but can't seem to figure out how. Keep getting an undefined variable error.
An example of trying (just to see if I can get to the variable) is the following code;
if(Select.len)
// give it/them a destination
world << "Selecting [object] at [object.x],[object.y]"
for(var/mob/Unit/U in Select)
U.destination = object
world << "[object.msattack]"
Any help would be appreciated :)
Mark
ID:174180
![]() Sep 21 2003, 5:56 am
|
|
OK, think I follow :)
If I do, I can't make the variable specific to Unit because each unit (men soldiers, wargs, etc.) will have different variables. So I tried the code, for(var/mob/Unit/U in Select) U.destination = object for(var/mob/Unit/MenSoldiers/MU in Select) world << "[MU.msattack]" and I get this; fantasyorg.dm:232:error:MU:undefined type: MU fantasyorg.dm:233:error:MU.msattack:undefined type: MU.msattack fantasyorg.dm:232:MU :warning: variable defined but not used Mark |
ok, the problem is:
for(var/mob/Unit/MenSoldiers/MU in Select) it is: MenSoliders in your code i think, thats the reason it wont work. check the spelling |
the variables you have for /mob/Unit/MenSoldiers will not work for mob/Unit because you need to be more 'destinct' with the for loop. /mob/Unit/MenSoldiers is where the variable is, and /mob/Unit is where you were trying to look for them, and it does not go into the parts of /mob/Unit looking for variables.
Either make the variables for /mob/Unit or change the for loop to for(var/mob/Unit/MenSoldiers/M in Select)
EDIT: "Sorry if im confusing you, Its just how I am..."