Aller au contenu

Photo

Create resource from a string variable?


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

#1
FalloutBoy

FalloutBoy
  • Members
  • 580 messages
From this page: http://social.biowar...(dascript_type)

"There are no native functions that can be used to convert another data type to a resource."

That is exceptionally annoying. Is this planned functionality? Because it is going to make it impossible to do a lot of creative creature spawning via script. I can't construct a string and say "okay spawn this!"

Modifié par FalloutBoy, 10 décembre 2009 - 06:45 .


#2
FalloutBoy

FalloutBoy
  • Members
  • 580 messages
I'm thinking maybe I could make a header file that contained a resource define for every creature in the game. Store these in an array, assuming you can even make a resource array. Then I could dynamically look up whichever one I wanted. Not only would this be hard to maintain, but I'm guessing it would be spectacularly inefficient compared to an in-engine solution.


#3
sillyrobot

sillyrobot
  • Members
  • 171 messages
My bag of beans add-in does this through the use of a 2DA. This offers the additional possibility of allowing players to add M2DA additions in the future should they wish.


#4
Phaenan

Phaenan
  • Members
  • 315 messages
That's also what I do myself. Some custom 2DA tables with (among other stuff) a resource column, and ultreia.
Maybe not ideal, but still, I found it more handy than a bunch of declarations.

Modifié par Phaenan, 10 décembre 2009 - 01:34 .


#5
J.O.G

J.O.G
  • Members
  • 355 messages
Well, normally you should know what resources exist while writing the spawning script, so you can use a 2DA or an array:
resource[] r;
r[0]=R"my_cat.utc";
r[1]=R"my_wolf.utc";
r[2]=R"my_ogre.utc";
r[3]=R"my_dragon.utc";
CreateObject(OBJECT_TYPE_CREATURE,r[Random(4)],GetLocation(GetHero()));

Modifié par J.O.G, 10 décembre 2009 - 03:19 .


#6
FalloutBoy

FalloutBoy
  • Members
  • 580 messages
I hope there was a really good engine-related reason for doing this because NWN was not like this and having to hard code all the resource names makes for a painfully inflexible system. I hope it was not just so they could determine the dependent resources at compile time. That's only a marginally useful feature when you aren't changing creature blueprints frequently.

Modifié par FalloutBoy, 10 décembre 2009 - 05:58 .


#7
Phaenan

Phaenan
  • Members
  • 315 messages
From what I remember, one of the Bioware officials (can remember which one, sowwy ^_~) told us he pushed that "StringToResource()" suggestion in the api todo, and it should be in there someday. While that doesn't change anything for now, it's nonetheless nice. Me thinks. :o

Modifié par Phaenan, 10 décembre 2009 - 06:16 .


#8
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages

FalloutBoy wrote...

I hope there was a really good engine-related reason for doing this because NWN was not like this and having to hard code all the resource names makes for a painfully inflexible system. I hope it was not just so they could determine the dependent resources at compile time. That's only a marginally useful feature when you aren't changing creature blueprints frequently.

I couldn't agree more. As for the dependent resources, since you can do it with script calls which would of course hides the script dependency, it doesn't seem likely to me that was their reasoning...but I suppose it could be.

It isn't very difficult to make your own conversion function to do it, although it would be all hardcoded...
[dascript]
resource StringToResource( string sTemplate )
{ if( sTemplate != "" )
  { sTemplate = StringLowerCase( sTemplate );
    if( sTemplate == "chicken.utc" ) return R "chicken.utc";
    if( sTemplate == "hurlock.utc" ) return R "hurlock.utc";
    // etc for every possible resource.
  }
 
  return R "";
}
[/dascript]

Modifié par Axe_Murderer, 11 décembre 2009 - 02:22 .


#9
FalloutBoy

FalloutBoy
  • Members
  • 580 messages
Thanks, Axe. That is probably what I will do. Makes me sad though.