OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: DrStrangelove on 04 Oct 2003, 15:32:17

Title: Array changes var-names to numbers :(
Post by: DrStrangelove on 04 Oct 2003, 15:32:17
Dang! Hi ppl.

I want to script a dynmic ai behaviour. I have a number of goals which change their 'weights', thus changing their importance to the ai.

I wanted to bubblesort all goal weights in an array, like:

Code: [Select]
goals = [heal,ammo,patrol,attack,defend,supply]
goals are:

Code: [Select]
heal = 8
ammo = 6
patrol = 4
supply = 2
attack = 0
defend = 0

Problem: when i write the array, there are only the numbers in it.
Is there a way to keep the var-names in the array ? Otherwise i'd just have to do it in another way.
Title: Re:Array changes var-names to numbers :(
Post by: deaddog on 04 Oct 2003, 15:42:38
You will have to use strings for the names.  Use the call function to convert them back to variable names.

goals = ["heal","ammo","patrol","attack","defend","supply"]

_g=call (goals select 0)    ;or 1 or whatever

I think that might work.

Title: Re:Array changes var-names to numbers :(
Post by: DrStrangelove on 04 Oct 2003, 18:53:47
Ok, thx very much. Although it might be best just to check which goal is the most important one and then check goals against each other.

Only problem is that the most important goal may not be available in a certain situation (why wanna heal when medictent is destroyed ?). I could delete the goal 'heal' compeletely out of the array before every goal level is calculated. mmmH. thx anyway !  :)