Home   Help Search Login Register  

Author Topic: string identity not working, why????  (Read 1211 times)

0 Members and 1 Guest are viewing this topic.

Offline Linker Split

  • Members
  • *
  • BHD MOD leader
    • BHD MOD site
string identity not working, why????
« 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"
« Last Edit: 10 Jul 2008, 00:09:41 by Linker Split »
ArmA: Black Hawk Down MOD website
Only the dead have seen the end of war (Plato)

Offline loki72

  • Former Staff
  • ****
    • Loki's Nightmare
Re: string identity not working, why????
« Reply #1 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"]

Offline Linker Split

  • Members
  • *
  • BHD MOD leader
    • BHD MOD site
Re: string identity not working, why????
« Reply #2 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



 
ArmA: Black Hawk Down MOD website
Only the dead have seen the end of war (Plato)

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: string identity not working, why????
« Reply #3 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 (_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.
« Last Edit: 10 Jul 2008, 13:19:12 by Wolfrug »
"When 900 years YOU reach, look as good you will not!"

Offline Sick

  • Members
  • *
    • Dev-Heaven.net
Re: string identity not working, why????
« Reply #4 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
« Last Edit: 10 Jul 2008, 08:55:57 by Sick »