Reading the UseScript member

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Reading the UseScript member

Post by Yukiko »

This might be a bug with POL. I don't know. I am getting some peculiar resukts trying to read the script or UseScript member of an item.

Here's my testing on this:

When I use the iteminfo command on an item that has a use script defined in its itemdesc file I don't see one displayed from the "Item" section on the "Script" line. If, however, I assign a use script (item.UseScript := "some_use_script") and then use iteminfo I do see a script name in the item section. Equip scripts are readable. This only seems to be a problem with the "script" member of an item. This isn't just an issue with the iteminfo command. I tried printing the UseScript member from an item prior to assigning one and I get nothing. If I print the errortext I get the "object does not support members" error. I get the same error even if I "manually" assign a UseScript to the item but I can still read the UseScript that I assigned it.

I should note that the item to which I have assigned a different UseScript does in fact use the newly assigned script. I tested it on a viking sword which normally creates kindling when used on a tree. I changed its UseScript to :lumberjacking:lumberjack and it produced logs in my backpack rather than kindling.

As I said this seems rather peculiar. I'm thinking it's a bug.

Here is the test script that I used:

Code: Select all

use uo;

program usescript_test(who, textline)

	var item := target(who, TGTOPT_NOCHECK_LOS);
	// Try this with a blank textline first on an item.
	// Then add a script as the textline to see the difference.
	if (textline)
		item.UseScript := textline;
	endif

	SendSysMessage (who, "The UseScript is " + item.UseScript, color := 88);  
	SendSysMessage (who, "The UseScript is " + item.UseScript.errortext, color := 88);  

endprogram
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Re: Reading the UseScript member

Post by Yukiko »

No comment on this?

Could someone test this and let me know if it is a bug or if I am doing something wrong?
Here is a modified version of my test command showing the ability to read the read the EquipScript. However the errortext still reports that the object doesn't support members even though it reads the EquipScript without any problem.

Code: Select all

use uo;


program usescript_test(who, textline)

	var item := target(who, TGTOPT_NOCHECK_LOS);
	// Try this with a blank textline first on an item.
	// Then add a script as the text line to see the difference.
	if (textline)
		item.UseScript := textline;
	endif
	// Tries to read UseScript member.
	SendSysMessage (who, "The UseScript is " + item.UseScript, color := 88);  
	SendSysMessage (who, "The UseScript error message is " + item.UseScript.errortext, color := 88);  

	// Reads EquipScript member.
	SendSysMessage (who, "The EquipScript is " + item.EquipScript, color := 88);  
	SendSysMessage (who, "The EquipScript error message is " + item.EquipScript.errortext, color := 88);  

endprogram
Post Reply