HouseOfAmon Posted August 18, 2006 Share Posted August 18, 2006 Edit... I figured out a way to fix part of my problem.. I still need a way to set variables.. Example.. } if ( uUnknown == vVar) Set xVar (vVar + sVar); <-- How do I do this.. } Link to comment Share on other sites More sharing options...
stoffe Posted August 18, 2006 Share Posted August 18, 2006 I still need a way to set variables.. Example.. } if ( uUnknown == vVar) Set xVar (vVar + sVar); <-- How do I do this.. } xVar = vVar + sVar; ...as long as xVar, vVar and sVar are of the same type, otherwise you'll need to convert the values to the same type first. Here is a complete nonsense script as an example demonstrating a few things you can do with different types of variables: // Declare global script variable. This can be accessed from all functions within this script, // but will only exist for the duration of the script execution (a few milliseconds usually). int MyGlobal; void main() { // Declare local script variables. These only exist within this block of code, i.e. while // inside the { } pair of block delimiters it's defined between. In this case the main() function. float fMyX, fMyY; // Declare floating point script variables... float fSomeValue; int iNum1; // Declare integer script variables int iNum2; int iSum; vector vPos; // Declare vector (x,y,z) script variable string sResult = "The result is "; // Declare string script var and assign constant value to it. object oMyself = OBJECT_SELF; // Declare object reference script var and assign it the object running this script. // Note: Other valid script variable types are: location, talent, event, effect vPos = GetPosition(oMyself); // Assign function value to variable. fMyX = vPos.x; // Assign variable value to another variable. fMyY = vPos.y; iNum1 = 1; // Assign constant value to variable. iNum2 = 2; fSomeValue = 2.5; if (fMyX == fMyY) { // If X and Y are identical... iSum = iNum1 + iNum2; // Add value of two vars and store in another. iSum++; // Increment value of iSum by 1. iSum--; // Subtract value of iSum by 1. iSum /= 2; // Divide value of iSum by 2. iSum *= 4; // Multiply value of iSum by 4; iSum += 10; // Add 10 to the value of iSum; iSum -= 4; // Subtract 4 from the value of iSum. iSum += iNum1 * iNum2; // Multiply iNum1 by iNum2 and add the result to iSum. iSum += FloatToInt(fSomeValue); // Add the non-fractional value of fSomeValue to iSum; // Set the global script variable to the value. MyGlobal = iSum; // Store the value in the global game variable (declared in globalcat.2da) named MyNonsenseSum. // These can be accessed from anywhere in the game. SetGlobalNumber("MyNonsenseSum", iSum); // Store the value in local object numeric variable slot 12 of the object running the script. // Note that the valid range of LocalNums is -127 to 128 only, higher/lower values will overflow. // These can be accessed while in the module where their parent object exists. SetLocalNumber(OBJECT_SELF, 12, iSum); // Post the resulting value to the Feedback log in-game. SendMessageToPC(GetPartyLeader(), sResult + IntToString(iSum)); } } Link to comment Share on other sites More sharing options...
HouseOfAmon Posted August 18, 2006 Author Share Posted August 18, 2006 Thanks Stoffe.. iSum=iSum+vVal; <--- This is exactly what I needed, the SetLocalNumber will be very usefull as well, I got some idea's for setglobal too.. Edit.. ==== Removed Code.. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.