Aller au contenu

Photo

Script syntax? resource r = R + filename_variable.


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

#1
_ShadowHawk

_ShadowHawk
  • Members
  • 78 messages
Trying to define a resource from a varable rather than a string literal. What's the correct syntax? Where can I find an updated script guide (I haven't been in a BioWare tool kit since NWN).

In other words:

    resource r = R"my_res_ref.uti"; // compiles normally

but how to use a variable:

    resource r = R"" + sVar + ".uti"; // throws an error

Thanks

#2
Phaenan

Phaenan
  • Members
  • 315 messages
Did you figure how to do it, if that's possible ?

I also tried to find out how to simply extract the resource from existent items, but to no avail.



If anyone knows, well, please. :o

#3
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
Couldn't find anything either. Just spitballing here so try
resouce r = R( sVar +".uti" );
resouce r = R[ sVar +".uti" ];
resouce r = R{ sVar +".uti" };
resouce r = R"\\"" +sVar +".uti" +"\\"";   // ha ha if this one works, should be only one backslash.

Modifié par Axe_Murderer, 17 novembre 2009 - 08:40 .


#4
Sunjammer

Sunjammer
  • Members
  • 926 messages
What we actually need is the omitted StringToResource function so you can:

resource rMyItem = StringToResource("myitem.uti");

Modifié par Sunjammer, 17 novembre 2009 - 09:23 .


#5
_ShadowHawk

_ShadowHawk
  • Members
  • 78 messages

Sunjammer wrote...

What we actually need is the omitted StringToResource function so you can:

resource rMyItem = StringToResource("myitem.uti");

I realized that immediately and it would be perfect, but Georg et al have their hands full right now without being asked to code a new function.

(i.e. My game is among those crashing at random 5 to 10 minute intervals.)

So I guess I'll keep tinkering in the mean time.

#6
_ShadowHawk

_ShadowHawk
  • Members
  • 78 messages

Axe_Murderer wrote...

Couldn't find anything either. Just spitballing here so try
resouce r = R( sVar +".uti" );
resouce r = R[ sVar +".uti" ];
resouce r = R{ sVar +".uti" };
resouce r = R"\\\\"" +sVar +".uti" +"\\\\"";   // ha ha if this one works, should be only one backslash.

None of these work I'm sorry to say.

#7
Nodrak

Nodrak
  • Members
  • 144 messages
Er... If:

resource r = R"my_res_ref.uti"; // compiles normally



but:

resource r = R"" + sVar + ".uti"; // throws an error



did you try:

resource r = R"" + sVar;



Or are you setting sVar yourself and know that it does not have the extension?

#8
Phaenan

Phaenan
  • Members
  • 315 messages
Found a lil' something while cruising through creature_core. Hm ? No, it wasn't what I was looking for, tho, but that's not the point. <_<
Some types of object contain resources within their local variables, for example the placeables used as traps. And as long as there's a var somewhere it's easy to use it :
resource rTrap = GetLocalResource(oPettyPlaceable, "PLC_TRAP_ITEM");
DisplayFloatyMessage(GetHero(), "Gotcha: "+ResourceToString(rTrap), FLOATY_MESSAGE, 0xFFFFFF);

While such a local variable doesn't exists for items, one can add a new var through MD2A and put the resource there when the item initially spawn. (via events if there's one appropriate, or manually)
It ain't perfect, but well, it's better than naught.

Modifié par Phaenan, 18 novembre 2009 - 10:38 .