mrdefender Posted July 30, 2005 Share Posted July 30, 2005 Greets I'm working on my mod and a question popped in my mind.... Do I have to use 'nSomething' for int variables? Can I just use 'Something' ? Got 3 variables that look wierd: nX, nY, nZ I ask this cause all the scripts I see have 'n' in them :-/ Link to comment Share on other sites More sharing options...
stoffe Posted July 30, 2005 Share Posted July 30, 2005 Do I have to use 'nSomething' for int variables? Can I just use 'Something' ? Got 3 variables that look wierd: nX, nY, nZ You can name your variables any combination of alphanumerical characters (letters, underscore and numbers only), as long as it doesn't start with a number as the first character. The n-prefix is just a coding standard where you use the first character to denote what kind of data type that variable holds. It's just done for your own convenience (or others reading the script) to help you keep track of what kind of variable it is. If you don't like it there's no point in doing it. In that coding standard, n just signifies that it's a number/integer value... n = integer f = float o = object v = vector l = location e = effect etc... Link to comment Share on other sites More sharing options...
mrdefender Posted July 31, 2005 Author Share Posted July 31, 2005 Why can't I add 'if' with this? int StartingConditional() { object oPC = GetFirstPC(); object oItem = GetItemPossessedBy(oPC, "item"); if ( (GetIsObjectValid(oItemW) == TRUE) ) { return TRUE; } return FALSE; } ala int nValue = GetScriptParameter( 1 ); if ( nValue == 1 ) { blah blah } :( Link to comment Share on other sites More sharing options...
stoffe Posted July 31, 2005 Share Posted July 31, 2005 Why can't I add 'if' with this? int StartingConditional() { object oPC = GetFirstPC(); object oItem = GetItemPossessedBy(oPC, "item"); if ( (GetIsObjectValid(oItemW) == TRUE) ) { return TRUE; } return FALSE; } I'm not sure I understand what you are trying to do, but you can use if to check for a condition. Are you trying to merge the first script with the second? However, in the first script you have a naming error with the variables. You declare the variable as oItem but then check for a variable named oItemW in the if-statement. This should work: int StartingConditional() { object oPC = GetFirstPC(); object oItem = GetItemPossessedBy(oPC, "item"); if (GetIsObjectValid(oItem)) return TRUE; return FALSE; } ...but may just as well be written like this instead, a bit shorter and saves a few variables: int StartingConditional() { return GetIsObjectValid(GetItemPossessedBy(GetFirstPC(), "item")); } Or, if this is for TSL, you could just use the standard conditional script that comes with the game that lets you check for items in inventory in a dialog. It's named c_have_item, to use it you set the tag of the item to check for in the String Param. Link to comment Share on other sites More sharing options...
mrdefender Posted July 31, 2005 Author Share Posted July 31, 2005 I did not know there was such a script (have item) I'll be using that What I was trying to do is something like this: if ( nValue == 10 ) { int StartingConditional() { return GetIsObjectValid(GetItemPossessedBy(GetFirstPC(), "item")); } } I could enter somescript (param1) 10 , does a check for the specific item listed in '10' then decide if the dialogue tree/node/thingy would show up or not Link to comment Share on other sites More sharing options...
Darth333 Posted July 31, 2005 Share Posted July 31, 2005 I could enter somescript (param1) 10 , does a check for the specific item listed in '10' then decide if the dialogue tree/node/thingy would show up or not ic...if you want to check if your PC has a specific item, you can use the generic script c_hasitem (meaning you don't need to make a script, just type c_hasitem in the dlg file) which is: int StartingConditional() { string sTag = GetScriptStringParameter(); if ( GetIsObjectValid( GetItemPossessedBy( GetFirstPC(), sTag))) return TRUE; return FALSE; } Just type your item tag in the .dlg file Otherwise, the script would be: int StartingConditional() { return GetIsObjectValid(GetItemPossessedBy(GetFirstPC(), "my_item")); } Link to comment Share on other sites More sharing options...
Darkkender Posted August 1, 2005 Share Posted August 1, 2005 You can name your variables any combination of alphanumerical characters (letters, underscore and numbers only), as long as it doesn't start with a number as the first character. The n-prefix is just a coding standard where you use the first character to denote what kind of data type that variable holds. It's just done for your own convenience (or others reading the script) to help you keep track of what kind of variable it is. If you don't like it there's no point in doing it. In that coding standard, n just signifies that it's a number/integer value... n = integer f = float o = object v = vector l = location e = effect etc... Just on a special note that coding standard is called Hungarian Notation. Named after a hungarian employ who worked for Microsoft who used that notation and became an almost universal programming notation style. Except integers usually use "I" instead of "N". Just thought I would throw in that fun fact. Link to comment Share on other sites More sharing options...
mrdefender Posted August 1, 2005 Author Share Posted August 1, 2005 f = float Float? *quickly gathers supplies for a "I am your father" float for the jedi academy's lightsaber playoffs* I don't suppose this has anything to do with Bao-Dur's remote? Link to comment Share on other sites More sharing options...
stoffe Posted August 1, 2005 Share Posted August 1, 2005 Float? *quickly gathers supplies for a "I am your father" float for the jedi academy's lightsaber playoffs* I don't suppose this has anything to do with Bao-Dur's remote? float is short for floating point value, ie a value that contains decimals, and not just whole numbers like an integer does. 3 <-- integer 3.14 <--- float Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.