[RELz] Oblivion Script Extender (OBSE) 0018

Post » Thu Nov 25, 2010 9:29 pm

Hmm, I'm having a problem with using %z in a plugin function I'm developing. I didn't touch the string_var interface part of the example plugin so that is as it should be.
		// register to use string var interface		// this allows plugin commands to support '%z' format specifier in format string arguments		OBSEStringVarInterface* g_Str = (OBSEStringVarInterface*)obse->QueryInterface(kInterface_StringVar);		g_Str->Register(g_Str);

The function itself passes the arguments to a more global internal function, dunno if that matters or not.
static bool Cmd_CreateMenuFloatValue_Execute(COMMAND_ARGS){	//Console_Print("Cmd_CreateMenuFloatValue_Execute");	return CreateMenuValue_Execute(PASS_COMMAND_ARGS, kCreateFloat);}
static bool CreateMenuValue_Execute(COMMAND_ARGS, UInt32 mode){	//Console_Print("CreateMenuValue_Execute");	const char* separatorChar = GetSeparatorChars(scriptObj);	char stringArg[kMaxMessageLength] = { 0 };	UInt32 menuType = 0;........	bool bExtracted = false;	switch (mode){	case kCreateFloat: {			bExtracted = ExtractFormatStringArgs(0, stringArg, paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, kCommandInfo_SetMenuChildFloatValue.numParams, &menuType, &newFloatVal);			Console_Print("kCreateFloat [%s]", stringArg);.......		}		break;
Everytime I try to use it with a %z in the format string the result is that the content of whatever string_var I passed was ignored. Am I doing something wrong? :unsure:
User avatar
Vivien
 
Posts: 3530
Joined: Fri Apr 13, 2007 2:47 pm

Post » Thu Nov 25, 2010 2:20 pm

Functions that operate on references require a reference (explicit or implied).
Functions that operate on base objects will use the supplied objectID or, if one is not supplied, will use the base object of the reference (explicit or implied). But it will still operate on a base object, regardless of how the function is written.

Ah. Thank you. So only functions that require a reference will operate on a reference and all other functions that may take a reference or an object operate on the base object?

That wasn't entirely clear from the documentation. From the section on Function Calling Conventions:
These functions can either be called on a reference or have an objectID passed in as an argument. If an objectID is passed in, it takes precedence over a calling reference.

I took it to mean that if a reference was supplied, the function would operate on that instance, not the base object, but if a base object was supplied it would operate on all instances. I'm sure if I'd thought about it for more than a minute I could have figured it out myself based on the functions but my brain is still swimming in a sea of html tags. :wacko:

Thanks to everyone being patient and taking the time to explain things. It is appreciated! :)
User avatar
kitten maciver
 
Posts: 3472
Joined: Fri Jun 30, 2006 2:36 pm

Post » Fri Nov 26, 2010 3:20 am

Hmm, I'm having a problem with using %z in a plugin function I'm developing. I didn't touch the string_var interface part of the example plugin so that is as it should be.

OBSEStringVarInterface::Register() is deprecated. Instead use:
		// register to use string var interface		// this allows plugin commands to support '%z' format specifier in format string arguments		OBSEStringVarInterface* g_Str = (OBSEStringVarInterface*)obse->QueryInterface(kInterface_StringVar);		RegisterStringVarInterface(g_Str);

I'll update the example plugin project to reflect that change.

@TheMagician: Yes. The optional ref is there for convenience; the following are equivalent:
ref.doSomething

base = ref.getBaseObjectdoSomething base

User avatar
Joey Bel
 
Posts: 3487
Joined: Sun Jan 07, 2007 9:44 am

Post » Fri Nov 26, 2010 12:32 am

[If a command can be used without a reference,] the optional ref is there for convenience; the following are equivalent:
ref.doSomething

base = ref.getBaseObjectdoSomething base

That's wonderfully succinct and should be transferred verbatim to documentation. :)
User avatar
Nicholas
 
Posts: 3454
Joined: Wed Jul 04, 2007 12:05 am

Post » Thu Nov 25, 2010 11:40 am

I can't duplicate the crash using the posted code or other variations.
Please post the full script.

That doesn't sound very encouraging, but here is my latest test script as requested.

This is an object script attached to a non playable clothing item, added to the player by a simple quest script.
Scn aaaTesterItemSref		actorref		clonearray_var	setBegin GameMode	if (actor)		message "test loop"		foreach set <- actor.getitems			let clone := apple			let clone := cloneForm clone			actor.additem clone 1		loop	else		message "starting test"		let actor := getContainer		messageEX "%n" actor	endifEnd

The only output I get is a "starting test" UI message.

I did some testing with similar code in quest scripts and they seem to work as expected. I only seem to get crashes when its an object script.
User avatar
Marguerite Dabrin
 
Posts: 3546
Joined: Tue Mar 20, 2007 11:33 am

Post » Thu Nov 25, 2010 7:29 pm

That doesn't sound very encouraging, but here is my latest test script as requested.

This is an object script attached to a non playable clothing item, added to the player by a simple quest script.
Your script will loop infinitely, which is probably why it CTDs. See if it doesn't when you clone forms in only a single frame.
User avatar
Kelly John
 
Posts: 3413
Joined: Tue Jun 13, 2006 6:40 am

Post » Thu Nov 25, 2010 8:22 pm

Your script will loop infinitely, which is probably why it CTDs. See if it doesn't when you clone forms in only a single frame.
Yep, thats what it was. I guess I was kind of expecting to see the rest of the messages instead of the game just crashing right on the spot. How embarrassing...

So I take it that UI messages and console text is displayed after the frame that the are called in?
User avatar
Charlie Ramsden
 
Posts: 3434
Joined: Fri Jun 15, 2007 7:53 pm

Post » Thu Nov 25, 2010 11:48 am

So I take it that UI messages and console text is displayed after the frame that the are called in?

Don't know about UI messages, but console text is displayed right away. I've had scripts with infinite loops, and gotten the debug text out to the console. I strongly recommend using PrintC/DebugPrint, and conscribe for your debug. It is just so much simpler than using messages. Especially since conscribe lets you anolyze the entire debug log afterwards.
User avatar
Alex [AK]
 
Posts: 3436
Joined: Fri Jun 15, 2007 10:01 pm

Post » Thu Nov 25, 2010 4:05 pm

You guys rock! :celebration:
User avatar
Melanie Steinberg
 
Posts: 3365
Joined: Fri Apr 20, 2007 11:25 pm

Post » Thu Nov 25, 2010 2:00 pm

I'm over half way through the reformat and have over 50 functions added to the consolidated function list/index of functions.

Does anyone have any objections to my reorganizing some of the lists? For example, is there any reason why the list of console functions couldn't be alphabetical? It seems most of the content is simply appended as it is added, but I don't mind reorganizing it since I'm mucking around in here anyway.

[Added Apr 24]: Handling deprecated functions:

I've noticed that a couple of the deprecated functions have had their syntax and usage removed from the documentation but examples of use still persist (eg. sv_Construct, MessageBoxEx). This seems a little confusing from a documentation perspective. Would it be possible to restore this documentation but keep it separate at the end of the document under Deprecated Functions? Or keep it in tact but tagged as deprecated? These could be cross-referenced with the replacement functions so that scripters can see how to update old techniques with new, improved ones. This information is still of interest from an archival perspective and may be of use to modders updating old scripts.
User avatar
Bek Rideout
 
Posts: 3401
Joined: Fri Mar 02, 2007 7:00 pm

Post » Fri Nov 26, 2010 3:52 am

Hello,

Thank you for the new version of OBSE! :)

I have two questions, please:
  • Is there a syntax giving the length, the width and the height of an object?
  • Is there a syntax giving the height of the ground (z) in tamriel with the values x y?

Thank you.
User avatar
April
 
Posts: 3479
Joined: Tue Jun 20, 2006 1:33 am

Post » Thu Nov 25, 2010 9:49 pm

OT, but I thought the OBSE guys would be the most likely to know.

What is the random number generator used by the game/CS for the section of items from a levelled list?
User avatar
Luna Lovegood
 
Posts: 3325
Joined: Thu Sep 14, 2006 6:45 pm

Post » Thu Nov 25, 2010 6:11 pm

Quick question, is it possible to retrieve a function by its opcode and, in turn, be able to 'use it'? I'm trying to parse a condition list from the ConditionEntry structure in GameForms.h.

Oh and, pssssttt...... plugin opcodes..... :whistling:

-kyoma
User avatar
dean Cutler
 
Posts: 3411
Joined: Wed Jul 18, 2007 7:29 am

Post » Thu Nov 25, 2010 2:20 pm

Requesting (again) Functions to get information normally only accessible via http://cs.elderscrolls.com/constwiki/index.php/Begin (e.g. OnHit).
I know you refused to implement them so far, because this would require tracking them all the time, even if no Mod is interested in this information.


How about also adding Start/StopTracking-Commands, so you have to activate the commands (for a specific Reference) first, before you're actually able to use them?
This would ensure you're only tracking required information and won't slow down the Performance if it's not nessesary.


Edit:
Maybe this would be sth. for an OBSE-Plugin, but since I don't know that much about programming (yet) I'm not able to create one myself. :(
User avatar
Sam Parker
 
Posts: 3358
Joined: Sat May 12, 2007 3:10 am

Post » Thu Nov 25, 2010 4:02 pm

I'm over half way through the reformat and have over 50 functions added to the consolidated function list/index of functions.

Does anyone have any objections to my reorganizing some of the lists? For example, is there any reason why the list of console functions couldn't be alphabetical? It seems most of the content is simply appended as it is added, but I don't mind reorganizing it since I'm mucking around in here anyway.

[Added Apr 24]: Handling deprecated functions:

I've noticed that a couple of the deprecated functions have had their syntax and usage removed from the documentation but examples of use still persist (eg. sv_Construct, MessageBoxEx). This seems a little confusing from a documentation perspective. Would it be possible to restore this documentation but keep it separate at the end of the document under Deprecated Functions? Or keep it in tact but tagged as deprecated? These could be cross-referenced with the replacement functions so that scripters can see how to update old techniques with new, improved ones. This information is still of interest from an archival perspective and may be of use to modders updating old scripts.

Sure, deprecated function docs should be included.
You are welcome to reorganize as you see fit.
  • Is there a syntax giving the length, the width and the height of an object?
  • Is there a syntax giving the height of the ground (z) in tamriel with the values x y?


No, neither. For #1 you might want to check with DragoonWraith and see if his nifScript plugin has support for that.
OT, but I thought the OBSE guys would be the most likely to know.

What is the random number generator used by the game/CS for the section of items from a levelled list?

The standard library rand().
Quick question, is it possible to retrieve a function by its opcode and, in turn, be able to 'use it'? I'm trying to parse a condition list from the ConditionEntry structure in GameForms.h.

Oh and, pssssttt...... plugin opcodes..... :whistling:

-kyoma

25D0-25DF.

The command table isn't exposed to plugins. PM me about what you're trying to do.
Requesting (again) Functions to get information normally only accessible via http://cs.elderscrolls.com/constwiki/index.php/Begin (e.g. OnHit).
I know you refused to implement them so far, because this would require tracking them all the time, even if no Mod is interested in this information.

How about also adding Start/StopTracking-Commands, so you have to activate the commands (for a specific Reference) first, before you're actually able to use them?
This would ensure you're only tracking required information and won't slow down the Performance if it's not nessesary.

Which events are you interested in?
User avatar
TRIsha FEnnesse
 
Posts: 3369
Joined: Sun Feb 04, 2007 5:59 am

Post » Thu Nov 25, 2010 8:43 pm

No, neither. For #1 you might want to check with DragoonWraith and see if his nifScript plugin has support for that.

No, it doesn't, though it might eventually. Also, heh, I changed the name to NifSE.
User avatar
Aman Bhattal
 
Posts: 3424
Joined: Sun Dec 17, 2006 12:01 am

Post » Thu Nov 25, 2010 5:23 pm

The standard library rand().


Thank you very much.

Do they do any thing special with it to a get a figure in a certain range?
User avatar
Averielle Garcia
 
Posts: 3491
Joined: Fri Aug 24, 2007 3:41 pm

Post » Thu Nov 25, 2010 8:10 pm

Thank you very much.

Do they do any thing special with it to a get a figure in a certain range?
You can perform some arithmetic on it to gather values from a range, similar to the CS function getRandomPercent. http://www.cplusplus.com/reference/clibrary/cstdlib/rand/.
User avatar
Leah
 
Posts: 3358
Joined: Wed Nov 01, 2006 3:11 pm

Post » Thu Nov 25, 2010 6:05 pm

You can perform some arithmetic on it to gather values from a range, similar to the CS function getRandomPercent. http://www.cplusplus.com/reference/clibrary/cstdlib/rand/.

Actually, that's how I'm already doing it.
User avatar
Lily Something
 
Posts: 3327
Joined: Thu Jun 15, 2006 12:21 pm

Post » Fri Nov 26, 2010 1:13 am

Actually, that's how I'm already doing it.
um, okay ? :unsure:

Apparently, they did the same.
User avatar
Tamara Primo
 
Posts: 3483
Joined: Fri Jul 28, 2006 7:15 am

Post » Thu Nov 25, 2010 1:59 pm

I have worked out some tricky debug uses with message-box .
I preferred that for debugging as it stops the script at a particular point. Lack of a message-box similar to Oblivion is one of the many reasons I stop doing FO3 mods.

But the last debug session I just did almost confounded my best "message-box" tricks. It took me longer than I would have liked.

Sooooo.....

Is there a tutorial on setting this up understanding it and doing..er.... "what you said"!?


I strongly recommend using PrintC/DebugPrint, and conscribe for your debug. It is just so much simpler than using messages. Especially since conscribe lets you anolyze the entire debug log afterwards.

User avatar
Samantha Pattison
 
Posts: 3407
Joined: Sat Oct 28, 2006 8:19 pm

Post » Thu Nov 25, 2010 3:03 pm

Hi - question on isFormValid.
Using :
scn UDUNcTQUESTscriptset tomeAppr to UDUNcTApprenticeREF	; a *persistent* ref...IF isFormValid tomeAppr == 0	printc "stoooooooooooops"	stopquest UDUNcTQUESTENDIF 
never ever saw "stoooooooooooops" even when UDUNcTApprenticeREF is placed in a container, and even when I use remove all items on the container - shouldn't I ? the docs are rather minimal on this - only found this :
# IsValidReference - returns true if the supplied reference is valid. This would return false, for instance, if a reference to an item is put into an inventory, or if the reference is non-persistent and not in the loaded cell. Avoids issues with calling functions on such references crashing the game. Use IsFormValid
http://cs.elderscrolls.com/constwiki/index.php/OBSE_Wishes_Fulfilled
Actually a function that could differentiate between the cases - item in container || item removed from game - would be quite handy
Is there a way to check the second case in particular ?
User avatar
elliot mudd
 
Posts: 3426
Joined: Wed May 09, 2007 8:56 am

Post » Thu Nov 25, 2010 5:30 pm

Requesting (again) Functions to get information normally only accessible via http://cs.elderscrolls.com/constwiki/index.php/Begin (e.g. OnHit).
I know you refused to implement them so far, because this would require tracking them all the time, even if no Mod is interested in this information.


How about also adding Start/StopTracking-Commands, so you have to activate the commands (for a specific Reference) first, before you're actually able to use them?
This would ensure you're only tracking required information and won't slow down the Performance if it's not nessesary.


Edit:
Maybe this would be sth. for an OBSE-Plugin, but since I don't know that much about programming (yet) I'm not able to create one myself. :(



Which events are you interested in?


Currently I'm only interested in Player.OnHit, but this might change so I'm interested in the OnHit-Information for several NPCs.
Maybe I (or anyone else) will be interested in other Begin-Blocks, but for my current projects OnHit should be enough.
User avatar
Mark
 
Posts: 3341
Joined: Wed May 23, 2007 11:59 am

Post » Thu Nov 25, 2010 6:45 pm

Sooooo.....

Is there a tutorial on setting this up understanding it and doing..er.... "what you said"!?

I agree, I use MessageBox often because it's extremely helpful to be able to pause the script. However, it seems that MessageBoxes get queued for each frame, so you won't see a MessageBox at all until after the script finishes for the frame - which means you can't pause right before a problem and use that to determine where the crash is coming from.

For that, it helps to use Print and/or PrintToConsole (OBSE functions that work similarly to MessageBox but output to the console), but if you're having a crash you won't get a chance to see them in the console. The answer is http://www.tesnexus.com/downloads/file.php?id=26510, which automatically logs everything that prints to the Console to a .log file, and it stores all the logs separately so you don't over-write. It's really, really nice.
User avatar
Prue
 
Posts: 3425
Joined: Sun Feb 11, 2007 4:27 am

Post » Fri Nov 26, 2010 12:32 am

I don't suppose there's any way to tell when all your OBSE mods have finished their "start-up" scripts after a game load?
User avatar
dean Cutler
 
Posts: 3411
Joined: Wed Jul 18, 2007 7:29 am

PreviousNext

Return to IV - Oblivion