Author Topic: Local Variables + d6  (Read 349 times)

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
Local Variables + d6
« on: August 09, 2012, 11:05:08 am »


               Hello,

I am attempting to write a script that will allow me to set a local integer on a container that will represent the number of d6 to be rolled. The result of this xd6 roll will then be the amount of gold spawned into the container.

Unfortunately, my meager scripting knowledge has left me to come up with this:

void main()
{
int iDiceNum = GetLocalInt(OBJECT_SELF, "iDiceNum");
int iDiceNum + d6;

CreateItemOnObject("it_gold001", OBJECT_SELF,);

}

Which is obviously both incomplete and non-functional.

Can anyone point me in the right direction?

-NineCoronas
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Local Variables + d6
« Reply #1 on: August 09, 2012, 11:31:37 am »


               It would be something like this:
void main()
{
int iDiceNum = GetLocalInt(OBJECT_SELF, "iDiceNum");
CreateItemOnObject("it_gold001", OBJECT_SELF, d6 (iDiceNum));
}

All the dice roll functions have an option for rolling multiple dice.  You just feed the stored int into there.
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Local Variables + d6
« Reply #2 on: August 10, 2012, 01:05:14 am »


               So if you wanted it to be 2d6 you would write it like d6(2)  etc...
               
               

               
            

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
Local Variables + d6
« Reply #3 on: August 10, 2012, 02:29:46 am »


               I want the number of dice to be called from a local variable on the object that uses this script so I don't have to make individual scripts for every dice roll.

That said, if you place a local variable on a placeable in the palette and then have that placeable spawned in-game via another script will the variables still be on that placeable?

Because that's how I'm bringing in the placeable that this script is supposed to be attached too is via another script
               
               

               
            

Legacy_Krevett

  • Full Member
  • ***
  • Posts: 203
  • Karma: +0/-0
Local Variables + d6
« Reply #4 on: August 10, 2012, 02:40:53 am »


               Yes your vars will stil be on the placeable when spawned...
               
               

               
            

Legacy_JediMindTrix

  • Sr. Member
  • ****
  • Posts: 383
  • Karma: +0/-0
Local Variables + d6
« Reply #5 on: August 10, 2012, 02:49:55 am »


               I fixed it. The issue was in the resref of the item I was trying to spawn in. Works like a charm now, thanks guys!