
quick question
Moderator: Event DM
- Crimzonfist
- Prince of Bloated Discourse
- Posts: 199
- Joined: Thu Aug 25, 2005 7:44 am
- Location: Michigan
quick question
the wording for the return() function in the lexicon is a bit confusing to me. I assume when its run in a script it stops said script.
but im realy not sure

Member - Ivory Order of the Sun
Journeyman of the AKN
"True integrity is doing the right thing, even when no ones watching."
Journeyman of the AKN
"True integrity is doing the right thing, even when no ones watching."
- Crimzonfist
- Prince of Bloated Discourse
- Posts: 199
- Joined: Thu Aug 25, 2005 7:44 am
- Location: Michigan
- jaythespacehound
- Apprentice Scholar
- Posts: 940
- Joined: Wed Sep 22, 2004 6:52 am
- Location: Hobart Australia (feels like a small island sometimes...hang on it is) GMT+10
If you use it in a function, it will also return the value given in Return something;
ie:
Er... that ended up being a rather long example...
Anyway here's what it does:
Like all scripts, it starts at void main()
It then gets the PC to be rewarded, namely the PC currently talking to the npc this script is on.
Then it creates a random number from 1 to 3 (Random(n) generates a random number from 0 to n hence the + 1)
Then it gets how much gold needs to be added using the function GetNewGold, which was created above the void main statement by:
Getting how much gold the player has,
Multiplying that by the random number.
Working out the difference between the gold the player has and how much he should have,
returning that difference to the void main script,
The void main then uses that to add that amount of gold to the player's pile.
See the bit before each function sets what kind of information it returns.
void main() for example
the prefix is void, which means it returns nothing.
For GetNewGold, the prefix is int. Which means it returns an integer value.
Hope that made sense and helped someone .
It certainly gave me something to do heh.
Jay
ie:
Code: Select all
// This function gets the gold of a player and calculates the new gold value to set.
int GetNewGold(object oPlayer, int iGoldMult)
{
// Get how much gold the player has
int iGold = GetGold(oPlayer);
// Get how much he should end up with
int iGoldFinal = (iGold * iGoldMult);
// Get how much gold to add
int iGoldToAdd = (iGoldFinal - iGold);
return iGoldToAdd;
}
void main()
{
// Get the PC in the conversation
object oPC = GetPCSpeaker();
// create a random reward from 1 - 3 times the current gold value
int iReward = (Random(2) + 1);
//Use the above function to find how much gold the player should be given
int iAddGold = GetNewGold(oPC, iReward);
//adds the reward
GiveGoldToCreature(oPC, iAddGold);
}
Anyway here's what it does:
Like all scripts, it starts at void main()
It then gets the PC to be rewarded, namely the PC currently talking to the npc this script is on.
Then it creates a random number from 1 to 3 (Random(n) generates a random number from 0 to n hence the + 1)
Then it gets how much gold needs to be added using the function GetNewGold, which was created above the void main statement by:
Getting how much gold the player has,
Multiplying that by the random number.
Working out the difference between the gold the player has and how much he should have,
returning that difference to the void main script,
The void main then uses that to add that amount of gold to the player's pile.

See the bit before each function sets what kind of information it returns.
void main() for example
the prefix is void, which means it returns nothing.
For GetNewGold, the prefix is int. Which means it returns an integer value.
Hope that made sense and helped someone .

It certainly gave me something to do heh.
Jay