[Solved]Creating "text" commands?

Here you can post threads requesting help on the official POL Ultima Online Emulator Core 095. Note: Core 095 is no longer officially supported.
Post Reply
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

[Solved]Creating "text" commands?

Post by Poi »

Solved..
Last edited by Poi on Wed Apr 19, 2006 4:42 am, edited 2 times in total.
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Post by Yukiko »

Under POL 95 the general textcommands (those not specific to a particular package) are located in \pol\scripts\textcmd

If you look in there you will see the various directories "player", "coun"...etc that the commands are located in. So you would place the script in the appropriate directory depending on what command level you wish to have access to your script. Note that the access is progressive. In other words, players may only access scripts in the player directory, councillors those in both the player and coun directories, seers those in the seer, coun and player directory and so on.

Look at some of those for examples of how to write commands if you need to.

POL 96 handles commands as a package it seems.
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Post by Poi »

Well i sort of figured out that much myself, but cannot find a cmd that simply displays text at a targeted area.


Also, i made a sciprt that looks like it should work, but, when i type the .<cmd> it doesnt do anything after i restarted pol
User avatar
tekproxy
Forum Regular
Posts: 352
Joined: Thu Apr 06, 2006 5:11 pm

Post by tekproxy »

You have to recompile the script. When you've compiled it, there will be a .ecl file with the same name as your script in that directory.
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Post by Poi »

Exactly how do you recomple a script, i ecompiled, restarted the server

Haha nevermind i got it, i just cant the the script to print the text :/

My point.src(new script:

Code: Select all

use os;
use uo;

program textcmd_point( who, text )

    var what := Target( who );
    if (what)
        PrintTextAbove( what, "*", who.name,"points here*" );
        PrintTextAbove( who, "*", who.name, "points at that spot*" );
    endif
endprogram
DevGIB
Grandmaster Poster
Posts: 248
Joined: Mon Feb 06, 2006 6:12 am

Post by DevGIB »

what does it do when you type in your command? does it say that the command is unknown or does it just do nothing... also give a directory string of where you have put this file
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Post by Poi »

Pol/scripts/textcmd/player and it brings up a target, i select something and it doesnt do anything, and i think i have it wrong.. the second printtext should be above the player..
DevGIB
Grandmaster Poster
Posts: 248
Joined: Mon Feb 06, 2006 6:12 am

Post by DevGIB »

oh right i see the problem...

REF: UO.EM

Code: Select all

PrintTextAbove( above_object, text, font := _DEFAULT_TEXT_FONT, color := _DEFAULT_TEXT_COLOR );
PrintTextAbovePrivate( above_object, text, character, font := _DEFAULT_TEXT_FONT, color := _DEFAULT_TEXT_COLOR );
youve used printtextabove but with the printtextaboveprivate params :) change it to say

Code: Select all

PrintTextAbove( what, "*"+who.name+"points here*" );
PrintTextAbove( who, "*"+ who.name+ "points at that spot*" ); 
you may also want to add spaces between the beginning of the second text and the word points so rather than saying *joepoints here* it will say *joe points here*...

p.s. + are used to attach to trings not , so thats why you were having trouble
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Post by Poi »

Thanks your the best!

Just wondering though, it works, but you can only point at actual items or players, is there a way to make(i know there is) it so you can point anywhere?

Heres my new code, it will not ecompile, is there an error?

Code: Select all

use os;
use uo;

program textcmd_point( who )

    var what := Target( who );
    if (what)
	PrintTextAbove( what, "*"+who.name+" points here*", font := _DEFAULT_TEXT_FONT, color := 0x33 );
	PrintTextAbove( who, "*"+who.name+ " points at "+what.name+"*", font := _DEFAULT_TEXT_FONT, color := 0x33 );
	PerformAction( who, ACTION_SALUTE );
    endif
endprogram
DevGIB
Grandmaster Poster
Posts: 248
Joined: Mon Feb 06, 2006 6:12 am

Post by DevGIB »

to answer that... yes

Code: Select all

TargetCoordinates( who );
DevGIB
Grandmaster Poster
Posts: 248
Joined: Mon Feb 06, 2006 6:12 am

Post by DevGIB »

im guessing just by looking at it, it will be saying something about the variable font not existing... rather than

Code: Select all

font := _DEFAULT_TEXT_FONT, color := 0x33
just have a simple

Code: Select all

PrintTextAbove( what, "*"+who.name+" points here*", _DEFAULT_TEXT_FONT, 0x33 );
and that should work for you :)
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Post by Poi »

It still does not ecompile

Code: Select all

use os;
use uo;

program textcmd_point( who )

    var what := TargetCoordinates( who );
    if (what)
	PrintTextAbove( what, "*"+who.name+" points here*", _DEFAULT_TEXT_FONT, 0x33 );
   	PrintTextAbove( who, "*"+who.name+ " points at "+what.name+"*", _DEFAULT_TEXT_FONT, 0x33 ); 
	PerformAction( who, SALUTE );
    endif
endprogram
DevGIB
Grandmaster Poster
Posts: 248
Joined: Mon Feb 06, 2006 6:12 am

Post by DevGIB »

give the compile error and i can help
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Post by Yukiko »

PrintTextAbove is looking for an object reference and your "what" is a structure containing coordinates. So first create something invisible at the targetted coordinates using something like this:

Code: Select all

use os; 
use uo; 

program textcmd_point( who ) 

    var what := TargetCoordinates( who ); 
    if (what) 
junkitemm := CreateItemAtLocation( what.x, what.y, what.z, <objtype of an invisible item>, 1 )
   PrintTextAbove( junkitem, "*"+who.name+" points here*", _DEFAULT_TEXT_FONT, 0x33 ); 
DestroyItem(junkitem);
      PrintTextAbove( who, "*"+who.name+ " points at "+what.name+"*", _DEFAULT_TEXT_FONT, 0x33 ); 
   PerformAction( who, SALUTE ); 
    endif 
endprogram 
Please note I don't know any invisible objtype to insert in that createitem function call so maybe someone else can suggest something. Perhaps a rescob would do.
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Post by Poi »

Ok i did that, created (my own) invisible object, and placed the code in there, it still doesn ecompile


Error:

Error compiling statement at E:\pol\scripts\point.src, Line 8
Error in IF statement starting at File: E:\pol\scripts\point.src, Line 7
Error compiling statement at E:\pol\scripts\point.src, Line 7
Error detected in program body.
Error occurred at E:\pol\scripts\point.src, Line 8
Execution aborted due to: Error compiling file

Scipt:

Code: Select all

use os;
use uo;

program textcmd_point( who )

    var what := TargetCoordinates( who );
    if (what)
junkitem := CreateItemAtLocation( what.x, what.y, what.z, 0x709s, 1 )
   PrintTextAbove( junkitem, "*"+who.name+" points here*", _DEFAULT_TEXT_FONT, 0x33 );
DestroyItem(junkitem);
      PrintTextAbove( who, "*"+who.name+ " points at "+what.name+"*", _DEFAULT_TEXT_FONT, 0x33 );
   PerformAction( who, SALUTE );
    endif
endprogram
Last edited by Poi on Tue Apr 18, 2006 1:43 pm, edited 1 time in total.
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Post by Yukiko »

Please post the compiler error that is displayed.
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post by CWO »

junkitem := CreateItemAtLocation( what.x, what.y, what.z, 0x709s, 1 )

0x709s is invalid... maybe mean 0x709a? also put a ; at the end of that line.
User avatar
Tritan
Grandmaster Poster
Posts: 147
Joined: Sat Feb 04, 2006 8:17 am

Post by Tritan »

This is the dot command I use on my shard. It creates a "hand" at the targetted location.

Code: Select all

use uo;
use os;

// These should be in your client.inc file.  If not you can add them there and use the include "client"; call instead.
const FONT_NORMAL       :=  0x03;   // Normal (default).
const ANIM_SALUTE               :=  0x0021; // Salute.


program point (who)
	SendSysMessage( who, "Point at what?" );
	var it := TargetCoordinates ( who );
	
	var itdesc;
	if ( it.item.name )
		itdesc := it.item.name;
		it := it.item;
	elseif ( it.item.desc )
		itdesc := it.item.desc;
		it := it.item;
	elseif ( it.mobile )
		itdesc := it.mobile.name;
		it := it.mobile;
	else
		it := CreateItemAtLocation( it.x, it.y, it.z, 0x706c, 1 );
		it.name := who.name;
		it.graphic := 0x206e;
		it.movable := 0;
		itdesc := "that spot";
		SetObjProperty (it, "destroyme", 1);
	endif		

	if ( it.hidden )
		SendSysMessage( who, "Canceled" );
		return;
	endif

	PerformAction ( who, ANIM_SALUTE );
	PrintTextAbove ( who, "*points at " + itdesc + "*", FONT_NORMAL, 55);
	sleepms (500);
	PrintTextAbove ( it, "*" + who.name + " points here*", FONT_NORMAL, 55);
	sleep (2);
	if ( it.objtype == 0x706c )
		if (GetObjProperty (it, "destroyme"))
			DestroyItem( it );
		endif
	endif
endprogram
This compiles in 95 and works very well. Hope it helps you out.
Post Reply