Aller au contenu

Photo

How do you convert from String to Resource?


  • Veuillez vous connecter pour répondre
3 réponses à ce sujet

#1
JamesX

JamesX
  • Members
  • 1 876 messages
Search doesn't seem to be working right now, so I am sorry if this topic is discussed to death.

I am trying to write a script that adds an item using parameter.

But I can't figure out how to change the parameter string into a Resource to be used with UT_AddItemToInventory.

Does anyone know how to do that? 

#2
weriKK

weriKK
  • Members
  • 106 messages
From my understanding, resources are manually created assets and by their nature static. Because you are unable to create resources dynamically afaik, there is not much point in referring to them that way during the game.



That being said, the treasure.xls file can be used to map resources to identifiers. Using GetM2DAResource() you can retrieve these resources in your scripts:

resource res = GetM2DAResource(TABLE_TREASURES, "COLUMN", ROW_ID);



For example use GetM2DAResource(TABLE_TREASURES, "Weapon", 5); to retrieve the resource located in the 5th row of the Weapon column inside the treasure.xls file. All you need is creating your own M2DA version of this xls file and fill it with items you wish to access.

#3
Nodrak

Nodrak
  • Members
  • 144 messages
IIRC there is a StringToResource() function built in.

Edit: Nope sorry, I double checked and its ResourceToString...  You might want to look at the SetLocalResource() function, it might be what you need depending on your script.

Modifié par Nodrak, 20 novembre 2009 - 07:25 .


#4
Sunjammer

Sunjammer
  • Members
  • 926 messages
Change your script to accept a resource as the parameter.