Aller au contenu

Photo

Local Variables + d6


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

#1
JediMindTrix

JediMindTrix
  • Members
  • 283 messages
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

#2
Failed.Bard

Failed.Bard
  • Members
  • 774 messages
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.

#3
ffbj

ffbj
  • Members
  • 593 messages
So if you wanted it to be 2d6 you would write it like d6(2) etc...

#4
JediMindTrix

JediMindTrix
  • Members
  • 283 messages
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

#5
Krevett

Krevett
  • Members
  • 104 messages
Yes your vars will stil be on the placeable when spawned...

#6
JediMindTrix

JediMindTrix
  • Members
  • 283 messages
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!