start_script help please

Here you can post threads requesting help on the official POL Ultima Online Emulator Core 096.
Note: Core 096 is no longer officially supported.

Moderator: POL Developer

Post Reply
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

start_script help please

Post by Poi » Sun May 29, 2011 4:07 pm

Okay so here is my script to start off with:

Code: Select all

use os;
use uo;

include "include/attributes";

program seed(who, item)
var x := who.x;
var y := who.y;
var z := who.z;


	var parms := {};
	parms[1] := who;
	parms[2] := "0x12";
	if(start_script("seedling", parms))

	var parms1 := {};
	parms1[1] := who;
	parms1[2] := "0x10";
	if(start_script("seedling", parms))
SendSysMessage(who, "Success");
endif
else
SendSysMessage(who, "Failure");
exit;
endif
SubtractAmount(item, 1);
endprogram

and the seedling script:

Code: Select all

use os;
use uo;

program seedling(parms)

	var where := parms[1];
	var what := parms[2];

	var x:= where.x;
	var y:= where.y;
	var z:= where.z;

	sleep(600);

	CreateItemAtLocation(x, y, z, what, 1);

endprogram

Now for some reason, when the script is called(the first script) it just says failure which should indicate something is wrong with how I have my Start_Script set up, anything look wrong to you guys?

The debug.txt says:
Script Error in 'scripts/items/seed.ecl' PC=70:
Call to function SendSysMessage:
Parameter 1: Expected datatype String, got datatype Error
Bittiez/Syp/Taz

Yukiko
Distro Developer
Posts: 2524
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: start_script help please

Post by Yukiko » Sun May 29, 2011 4:53 pm

How is the first script getting called? If it is from another script how does it know the reference value of "who" in the SendSysMessage? In a use script such as that attached to a hammer POL passes the reference value for "who" (ie. the one using the item) to the use script. So if that first script is being started from a start_script call then you'll have to pass the reference for the player you want the SysMessage send to.
Sincerely,
Yukiko

I would tell you a UDP joke but you might not get it.

Titus 2:13

Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Re: start_script help please

Post by Poi » Sun May 29, 2011 4:57 pm

The first script is being called by an item(double click)

And I don't think its the sendsysmessage that is causing the problem because I still get the second sysmessage ingame when I run the script

Updated, same problems:

Code: Select all

use os;
use uo;

include "include/attributes";

program seed(who, item)
var where := who;

	var parms := {};
	parms[1] := where;
	parms[2] := "0x12";
	var create := start_script("seedling", parms);
	if(create)
		var parms1 := {};
		parms1[1] := who;
		parms1[2] := "0x10";
		var create1 := start_script("seedling", parms1);
		if(create1)
		SendSysMessage(who, "Success");
		endif
	else
	SendSysMessage(who, "Failure");
	exit;
	endif

SubtractAmount(item, 1);
endprogram
Bittiez/Syp/Taz

Yukiko
Distro Developer
Posts: 2524
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: start_script help please

Post by Yukiko » Sun May 29, 2011 5:08 pm

So you get the "Failure" message but the "Success" message is erroring out?

The error message is giving you a Program Counter number of 70. Have you tried compiling with the -l option set and looked at the .lst file to verify where line (PC) 70 is? Sorry I can't find anything else to look at.
Sincerely,
Yukiko

I would tell you a UDP joke but you might not get it.

Titus 2:13

Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Re: start_script help please

Post by Poi » Sun May 29, 2011 5:14 pm

I haven't tried that, is there any possibility it could be script locations? I have both scripts in scripts/items/ folder because I wasn't sure where start_script would call from, I assumed it would call from the directory the original script is in, correct?

I tried ecompile.exe -l scripts\items\seed.src but nothing came too, how exactly do I use -l?
Last edited by Poi on Sun May 29, 2011 5:29 pm, edited 1 time in total.
Bittiez/Syp/Taz

Yukiko
Distro Developer
Posts: 2524
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: start_script help please

Post by Yukiko » Sun May 29, 2011 5:28 pm

I don't think it's a location issue and start_script should assume the script you want started is in the directory the calling script is in. I'd try a couple of things. First, get a new error report showing the new PC location since it looks like you've made a few changes from the first script. Set the -l compile option and look at the list file and see what statement the error is pointed at. Sometimes POL gets confused and reports errors in an odd way and the error is actually not what the verbage says it is or it wasn't reported in a human readable sentence : ) The next thing I would do is probably dumb sounding but I'd comment out all but the two SendSysMessage statements and begin addind back stuff til you get an error.

Looking at the script again, the seedling script isn't returning a value. If the seedling is created it should return a 1 and if not a 0. The if(create) statement would not get called I believe unless seedling returns a 1. You can put a return 1; statement just before the endprogram line to accomplish that.

That's about all I can offer ATM. I'm off to work soon but good luck. I'll pop back on tomorrow and see if anyone else has offered some actual help or if you fixed the issue.
Sincerely,
Yukiko

I would tell you a UDP joke but you might not get it.

Titus 2:13

Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Re: start_script help please

Post by Poi » Sun May 29, 2011 5:41 pm

I added return 1 before the endprogram, but the problem with that is that it waits 10 minutes before creating the item, so it shouldn't return 1 until 10 minutes later correct?

I checked the debug again and found nothing for the script now, everything compiles fine, so I took out the if statements (I commented out the sendsysmessage too) and commented out the wait time in the seedling too, and it still isn't creating the item =S

I have added a sendsysmessage to the seedling script, and it does not get sent(which tells me the seedling script isn't being called correctly)
Bittiez/Syp/Taz

Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Re: start_script help please

Post by Poi » Sun May 29, 2011 7:18 pm

So I'm using this code now for the seed file(first one, called by the item):

Code: Select all

var x := who.x;
	var parms := {};
	parms[1] := x;
	parms[2] := "0x12";
SendSysMessage(who, x);
exit;
and cannot get anything from who.x, no matter how I do it for some reason =S

i have also tried:

Code: Select all

var parms := {};
	parms[1] := who.x;
	parms[2] := "0x12";
SendSysMessage(who, who.x);
exit;

however, if I put CreateItemAtLocation(who.x, who.y, who.z, item, 1);
that creates the item at my feet perfectly :S
but for some reason who.x will not return a value =S
Bittiez/Syp/Taz

User avatar
CWO
POL Expert
Posts: 1142
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA
Contact:

Re: start_script help please

Post by CWO » Sun May 29, 2011 8:06 pm

OK First of all, I'm assuming this script is a "Use Script" so someone uses something (a seed) and in 10 minutes, it grows into a plant in the start_script... There really isn't a reason to start_script from this though. You can do this within the script if you detach it from the character. Here's how I would do it...

Code: Select all

use os;
use uo;

include "include/attributes";

program seed(who, item)

     // Start by saving the current location...
     var x := who.x;
     var y := who.y;
     var z := who.z;

     // Consume the object and ensure we have consumed it.
     If (!SubtractAmount(item, 1))
          SendSysMessage(who, "Failure to consume the seed!");

          // The seed wasn't consumed so stop because of the failure!
          return 0;
     endif

     // Detach from the character so they can do other things while waiting
     Detach();

     // Wait for 10 minutes...
     Sleep(600);

     // Create Items
     CreateItemAtLocation(x, y, z, 0x12, 1);
     CreateItemAtLocation(x, y, z, 0x10, 1);

     // And we're done!
endprogram

Some notes...
in your declaration for the variable parms, you have "0x10" and "0x12"... you're using hex numbers as a string? This may cause an error in CreateItemAtLocation...
SendSysMessage will NOT print who.x unless you CStr it... - SendSysMessage(who, CStr(who.x)); <--- who.x is an INTEGER and the message can only be a STRING otherwise it fails...
Yukiko wrote:Looking at the script again, the seedling script isn't returning a value. If the seedling is created it should return a 1 and if not a 0. The if(create) statement would not get called I believe unless seedling returns a 1. You can put a return 1; statement just before the endprogram line to accomplish that.
The return value of a script run by start_script is ignored because the start_script function doesn't wait for the script it started to complete... You're thinking of Run_Script_To_Completion (Runs the script as critical) or (in 097+) Run_Script (non-critical)... var create := start_script("seedling", parms); would instead return 1 if the script is successfully started (regardless of what it does within the script) and 0 if there was an error (script not found, invalid parameter, ect...).

Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Re: start_script help please

Post by Poi » Sun May 29, 2011 10:08 pm

Absolutely perfect! Thank you!
Bittiez/Syp/Taz

Yukiko
Distro Developer
Posts: 2524
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: start_script help please

Post by Yukiko » Sun May 29, 2011 10:22 pm

Ah yes CWO. Sorry Poi for the mistake. I'm glad someone smarter than I came along. Thanks CWO
Sincerely,
Yukiko

I would tell you a UDP joke but you might not get it.

Titus 2:13

Post Reply