The Daily Click ::. Forums ::. Klik Coding Help ::. Need some help about string manipulation.
 

Post Reply  Post Oekaki 
 

Posted By Message

Riptide



Registered
  26/07/2013 21:07:20
Points
  101
21st September, 2013 at 21/09/2013 22:27:15 -

Hi there
I wanna do string manipulation for coding my game in an easier way.
There is why i need it.
I have a basic inventory, okay, no problem (at the moment ) for that.
I have weapons which i recognize them with ID's example:
1=Pistol
2=Flamethrower
3=Rocket-Launcher

I have a string object and i do these conditions:

• If WeaponID = 1
==> Set weaponName to "Pistol"

• If WeaponID = 2
==> Set weaponName to "Flamethrower"

• If WeaponID = 3
==> Set weaponName to "Rocket-Launcher"

And i'm gonna make a LOT of weapons in this game so i don't want to do one condition (or more maybe) for one weapon
i want to store a string in an object like:

" 1=Pistol;2=Flamethrower;3=Rocket-Launcher "

and an extension (like String parser or string tokeniser i guess) and this extension would do:

• Always (For example)
==> set weaponName to (String parser => for each piece of string (delimited by ";") => find weaponID and set it's 'value' (delimited by "="))

I practised it,searched and i can't find the solution. Thanks for helping guys and cya !



Edited by Riptide

 
Working on some engines, working for the fun !

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
21st September, 2013 at 21/09/2013 23:46:06 -

That's a *really* bad idea - use an array instead (or even an ini file, if you must)

 
n/a

Riptide



Registered
  26/07/2013 21:07:20
Points
  101
22nd September, 2013 at 22/09/2013 18:16:41 -

Okay then i'm gonna make a condiction for each weapon. Thx for the reply sketchy !

 
Working on some engines, working for the fun !
   

Post Reply



 



Advertisement

Worth A Click