jaam Posted August 4, 2014 Share Posted August 4, 2014 IsWaiting is a vanilla function Why do you keep prefixing your ints with $ when outputting them with print ? Link to comment
Guest tomm434 Posted August 4, 2014 Share Posted August 4, 2014 IsWaiting is a vanilla function wow I didn't even know this function before you told me. Seems risky to use for me. But I think that compiler should pick this up - it compiles only with "let" Why do you keep prefixing your ints with $ when outputting them with print ? Well, I didn't know "Print" existed before I saw Odessa's debug script. Before I used "PrintC". But simple "Print" is more convenient. Link to comment
prideslayer Posted August 4, 2014 Author Share Posted August 4, 2014 I think it's just unclear when you need it and when you don't, better safe than sorry? I don't know the rules either, though I know it's needed (for some reason) when passing a string var into NX functions. Link to comment
Guest tomm434 Posted August 4, 2014 Share Posted August 4, 2014 I saw that in Odessa's script. So it's not necesary, I get it, thanks. :) Link to comment
jaam Posted August 4, 2014 Share Posted August 4, 2014 $ applies to stringVar, its an alias for ToString. Does it also work for converting integer to string ? Link to comment
DoctaSax Posted August 4, 2014 Share Posted August 4, 2014 Numbers, form names, sure. Link to comment
jaam Posted August 4, 2014 Share Posted August 4, 2014 Yeah, I never realized , though it's plain in the source Link to comment
Odessa Posted August 4, 2014 Share Posted August 4, 2014 @AJ: There is a function to suppress NVSE errors actually: From nvse_whatsnew.txt: testexpr (did I test that one ? Can't remember ) From OBSE docs: TestExpr - attempts to evaluate an expression, returning false if an error occurs during evaluation and true otherwise. This can be useful when checking if an array index is out of bounds or if an element exists with a given key, among other things. TestExpr suppresses the output of error messages to the console and log file.(bool) TestExpr expr Example: [code]array_var arraylet array := ar_Construct Arrayif testexpr (array[5] := 2) PrintC "5 is a valid index, assignment succeeded."else PrintC "Index 5 is out of bounds, no assignment."endiflet array := ar_Construct StringMapif testexpr (array["INDEX"]) PrintC "An element exists in array with key 'INDEX'"else PrintC "No element with the specified key exists."endif [/code] So it returns false if an NVSE error is generated (and suppresses it), else true. I guess you might use it instead of bothering to check if a key exists, like try/except in some languages: if TestExpr MyMapArray[someKey] += 1 ; * increment entry if it exists already else let MyMapArray[someKey] := 1 ; * else create it at 1 endif Or to write pretentious 1-line loops: while TestExpr MyArray[iKey+=1] += 1 loop Link to comment
jaam Posted August 10, 2014 Share Posted August 10, 2014 I think DoctaSax did test testexpr, isn't it Doc ? Link to comment
DoctaSax Posted August 10, 2014 Share Posted August 10, 2014 I don't think I did much with it, actually. Link to comment
jaam Posted August 10, 2014 Share Posted August 10, 2014 My bad, one more thing to verify Link to comment
Odessa Posted August 14, 2014 Share Posted August 14, 2014 So, V4.1 added this function: RunScript It is not documented apart from name in nvse_whatsnew, and is not mentioned in the OBSE docs. The GECK compiler throws an error unless you pass it an inventory item base form, like "RunScript Vodka". I haven't tested it in game. What does it do? Link to comment
jaam Posted August 14, 2014 Share Posted August 14, 2014 It requires a parameter which is a form containing a script. If the script is found it will be run, as in added to the list of active scripts. This should let you start a script that is not attached to any reference. As far as I know, the script will keep running until it crashes. Link to comment
DoctaSax Posted August 14, 2014 Share Posted August 14, 2014 Is that limited to a particular script type? Link to comment
jaam Posted August 14, 2014 Share Posted August 14, 2014 Those that are implemented using the ScriptForm form. That includes, actors, activators, Inventory Items, Containers, Doors, Lights, Item Mod, Quest, Armor AddOn, Spells and effects should logically work too, but they are not sufficiently decoded to guaranty it. Link to comment
A.J. Posted August 14, 2014 Share Posted August 14, 2014 @AJ: There is a function to suppress NVSE errors actually I was hoping in something more... easier, something like "DontShowMeErrorsOnConsoleForThatMod", better with a shortcut like DSME... I can't even get the OBSE example Link to comment
jaam Posted August 15, 2014 Share Posted August 15, 2014 News from the front: I think Odessa's issue should be fixed in the upcoming version. Turned out to a concurrency issue when using too many strings/arrays in loops. @A.J. the logic behind those messages is to allow end users to report bugs to mod author. If you routinely generate those error with "non bugged" code, please upload a sample. Link to comment
Odessa Posted August 15, 2014 Share Posted August 15, 2014 @AJ: I've written an article on GECK wiki about TestExpr, hopefully it will make sense . Suppressing errors for an entire mod would be very bad practise, but TestExpr lets you tell NVSE "I know this line might fail, but tell me and not the user if it does, and I'll handle it". I've tested TestExpr a bit and it seems to work as intended. Link to comment
A.J. Posted August 15, 2014 Share Posted August 15, 2014 If you routinely generate those error with "non bugged" code, please upload a sample. It's not really "not bugged", they do good, but I don't need them in these cases. I noticed Get functions return an error on console when the ref doesn't exist. For example, I have a script that checks all the slots for equipped object but it spams an error if there's nothing in the slot. I don't need it, I'm actually checking what is equipped. Another example, I have a script that spawns a creature with PlaceAtMe and then executes the code on its ref. It needs "some time" to be spawned, so the script will constantly check with If GetType 43 when the creature is really spawned. But in the meantime, for some frames, it returns a error on console of course, it's the time the creature needs to be spawned. They do good, they are right to notify the error, but I'm aware of those errors and I find it's normal, that's why I wanted to remove them, because I guess if all the mods work in this way all togheter it would be impossible to track down "real" errors in console @Odessa thank you I'll check it Link to comment
Odessa Posted August 22, 2014 Share Posted August 22, 2014 RunScript does not appear to work. I have the following object script attached to a misc item: scn nvserunscript ref rMe float fTimer Begin GameMode if fTimer > 0 let fTimer -= GetSecondsPassed return endif let fTimer := 2 let rMe := GetCurrentScript Print "Runscript GameMode " + $rMe Print "or " + (GetFormIDString rMe) End RunScript nvsetestToken Does not appear to do anything. If I instead additem the token, the script runs as expected. Note: I only tested it for documentation purposes, so take this as informational not as a request to have it fixed, if it is broken. Link to comment
Odessa Posted August 23, 2014 Share Posted August 23, 2014 The function IsPlayable is broken, and appears to return 1 to everything. For example: Print "Testing IsPlayable AmmoCompanion" let iInt := IsPlayable AmmoCompanion Print "Returned: " + $iInt Print "Testing IsPlayable WeapKnifeCombatCass" let iInt := IsPlayable WeapKnifeCombatCass Print "Returned: " + $iInt Print "Testing IsPlayable Weap10mmPistol" let iInt := IsPlayable Weap10mmPistol Print "Returned: " + $iInt Testing IsPlayable AmmoCompanionReturned: 1Testing IsPlayable WeapKnifeCombatCassReturned: 1Testing IsPlayable Weap10mmPistolReturned: 1 EDIT: Actually, IsPlayable just only works for armor (see below). I have tested it for this and it works correctly Link to comment
Guest luthienanarion Posted August 23, 2014 Share Posted August 23, 2014 IsPlayable and SetIsPlayable only work on ARMO forms. Perhaps they should be expanded to work with more form types. Link to comment
jaam Posted August 23, 2014 Share Posted August 23, 2014 ARMO use a specific way to store the information. Link to comment
Odessa Posted August 23, 2014 Share Posted August 23, 2014 Thanks. It looks like you can use the GetWeaponFlags1 bitmask to check if a weapon is playable already. It would be convenient if IsPlayable was expanded to work for other types though... Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now