Page 1 of 1

Print and Broadcast do not work in this method.

Posted: Mon Feb 17, 2020 11:03 pm
by Yukiko
i have been trying to get the following method to print to the console or possibly broadcast in game. It doesn't. I tested Printing from a simple method that just Prints and that worked fine. I need help with this issue. I have already consulted withe Turley and he couldn't figure it out. So here is the function. If anyone has any idea why the TurnOn() method will not send any output (Print or Broadcast), please let me know.

Code: Select all

use uo;
use os;

include ":itemutils:itemdesc";

program Install()

	return 1;
endprogram

exported function IsLight( light )

        light := light;

	return 1;
endfunction

exported function IsOn( light )

	return GetItemDescInfo( light.graphic ).IsOn;
endfunction

exported function TurnOn( light )

	Broadcast("I want to broadcast this as a test.");

	if( IsOn( light ))
		Broadcast("There was an error");
		return error{"errortext":="Light is already turned on."};
	endif

	var cfg_info := GetItemDescInfo( light.graphic );
	light.graphic := CInt( cfg_info.ChangeTo );
	cfg_info := GetItemDescInfo( light.graphic );
	light.facing := CInt(cfg_info.Facing);
	Print("Facing " + light.facing);
	return 1;
endfunction

exported function TurnOff( light )

	if( !IsOn( light ))
		return error{"errortext":="Light is already turned off."};
	endif

	var cfg_info := GetItemDescInfo( light.graphic );
	light.graphic := CInt( cfg_info.ChangeTo );

	return "Done";
endfunction

exported function Toggle( light )

	if( IsOn( light ))
		return TurnOff( light );
	else
		return TurnOn( light );
	endif
endfunction

Re: Print and Broadcast do not work in this method.

Posted: Thu Feb 20, 2020 7:54 am
by Yukiko
Problem solved. It was a cfg file error.