OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Linker Split on 10 Jul 2008, 00:07:03

Title: string identity not working, why????
Post by: Linker Split on 10 Jul 2008, 00:07:03
Ok, let me explain you what i want to achieve:

I want that when my character is near for example a bush, then the engine recognizes it is the bush lks_bush_leaf3_big.p3d and execut the second part of the script.
Now I'm stuck at this simple string identity, cause I want to compare the string lks_bush_leaf3_big.p3d and the one the engine recognizes through the line _r_obj = str "_obj"

if I put the famous trial line hint format ["%1",_r_obj], it works, the hint appears: lks_bush_leaf3_big.p3d
but when coming to the identity, it doesn't work. why????

Code: [Select]
;my unit
_Character = _this select 0

#START
;find the nearest object in order (passed array which elements are: 0 = player, 1 = nearest object)
_near_obj = nearestObjects [_Character,[],3]

;select the array select 1, so the real object
_obj = _near_obj select 1

:convert the object into a string
_r_obj = str "_obj"

;identity which doesn't work
? _r_obj == "LKS_bush_leaf3_big.p3d" : _Character setDammage 1
~1
goto "START"
Title: Re: string identity not working, why????
Post by: loki72 on 10 Jul 2008, 00:23:39
greetings,

question: are you defining the STR in a stringtable.csv?

example: warfare

stringtable.csv partial
Code: [Select]
LANGUAGE,"English"
STR_V22,"V-22 Osprey"
STR_F22,"F-22 Raptor"
STR_TT650,"Motorcycle"
STR_M2A2, "M2A2 Bradley"
STR_Hind, "Hind-24"
STR_F117,"F117 Nighthawk"
STR_Mig15,"MIG-15"
STR_SU34B,"SU-34B"
STR_BTR80,"BTR-80"


configloadout.sqs - partial
Code: [Select]
_n = _n + [Localize "STR_M107AM"]
Title: Re: string identity not working, why????
Post by: Linker Split on 10 Jul 2008, 00:32:55
no, maybe you didn't get it  :)

I want to transform an object name into a tring, to make the identity. but it is not working,the object _obj is recognized as lks_bush_leaf3_big.p3d, but when comes to
Code: [Select]
? _r_obj == "LKS_bush_leaf3_big.p3d" : _Character setDammage 1, the identity doesn't work, while it should be, the strings are the same



 
Title: Re: string identity not working, why????
Post by: Wolfrug on 10 Jul 2008, 06:00:53
Edit: Hate it how the code-format breaks all other formatting commands  :dry:

That's not how you use the str command. The correct way is:

str (http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=s#786) (_yourVariable)

:) Then you should be getting what you want. If it doesn't work for some reason, just use format. Won't kill you!

Wolfrug out.
Title: Re: string identity not working, why????
Post by: Sick on 10 Jul 2008, 08:36:37
str "_obj"

should be str(_obj)

Also, when comparing strings, they must match 100%, also the case. In your first post example, you don't have any case in the result:
- the hint appears: lks_bush_leaf3_big.p3d
- ? _r_obj == "LKS_bush_leaf3_big.p3d" : _Character setDammage 1