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
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!
// Detach from the character so they can do other things while waiting
// Wait for 10 minutes...
// Create Items
CreateItemAtLocation(x, y, z, 0x12, 1);
CreateItemAtLocation(x, y, z, 0x10, 1);
// And we're done!
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...).