Author Topic: CreateItemOnObject then add variables and description?  (Read 313 times)

Legacy_AmbrosiaPW

  • Jr. Member
  • **
  • Posts: 70
  • Karma: +0/-0
CreateItemOnObject then add variables and description?
« on: April 22, 2011, 02:48:22 am »


               Hello!

I want to give a PC an item that has a variable in it but I'd like to create it on the spot.

I was successfull at creating an item then using CreateItemOnObject to put it in a PC's inventory, but I need to be able to give the PC a different item with a different variable when they complete the first quest. Then when the second one is complete give them a different item with a different variable.

I could make these items all seperate and waiting for the NPC to give to the PC, but that would mean I would need a lot of quest items. (10 NPC's X 5 item's each = 50 items)

I would think this wouldn't be good for my module since it is already pretty big. I want to, instead, create the item on the spot and give it the neccesary info like image resref and a variable.

Can I do this? Is this the right way of thinking? Thank you!
               
               

               


                     Modifié par AmbrosiaPW, 22 avril 2011 - 01:58 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
CreateItemOnObject then add variables and description?
« Reply #1 on: April 22, 2011, 03:28:16 am »


               You can easily set a local variable on a created object. The CreateItemOnObject should return an object. Here's some fake code:

object oItem = CreateItemOnObject( sResRef, oItemReceiver);
SetLocalString(oItem,"sLocalVariable","thestringdatajammedinthelocalvariable");

               
               

               


                     Modifié par henesua, 22 avril 2011 - 02:29 .
                     
                  


            

Legacy_AmbrosiaPW

  • Jr. Member
  • **
  • Posts: 70
  • Karma: +0/-0
CreateItemOnObject then add variables and description?
« Reply #2 on: April 22, 2011, 03:41:21 am »


               Oh ok, cool thank you! This stuff makes more and more sense the more I learn.

So do I have to have an item created in my module already for me to give it out like this? Am I able to have a standard item and change the image when I put it in someone's inventory?

Thank you!
               
               

               
            

Legacy_Ryuhi2000

  • Full Member
  • ***
  • Posts: 159
  • Karma: +0/-0
CreateItemOnObject then add variables and description?
« Reply #3 on: April 22, 2011, 07:04:10 pm »


               no you dont need to create an item if you want to seta variable on it.
you can set variables on any item you would just use scripting to add the variable to the item.

edit: i myself use integers since they are extremely easy to work with xample value   0  can mean  not complete or they integer doesnt exist or 1 can mean complete or the variable does exist
               
               

               


                     Modifié par Ryuhi2000, 22 avril 2011 - 06:07 .