Difference between revisions of "Manual:DIL Manual/killedit"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
(checked against the compiler and the interpreter; example compiles)
 
Line 1: Line 1:
−
<span id="bpkilledit"></span>
+
= killedit() =
 +
'''Procedure.''' Takes a player out of the text editor.
  
−
  '''Function: '''<i><!--CODE-->killedit ;</i><!--ENDCODE-->
+
  killedit(u : unitptr)
−
This function is used to kill the editor on a PC if it needs to
 
−
stop editing before the PC is done editing.  An example of when this is needed
 
−
is when a player is killed while editing or is transfered away from a place where he was editing.
 
−
You can let them finish but it may be wierd for a person to finish
 
−
posting in one room while in another.
 
−
'''Example'''
 
−
<i><!--CODE-->
 
−
---~---~---~---~---~---~---~---~---
 
  
−
dilbegin editextra (arg:string);
+
Ends the editor that [[Manual:DIL Manual/beginedit()|beginedit()]] started for the player
−
code
+
<code>u</code>, and puts the player back at the normal command prompt. Use it when the player
−
dilend
+
dies, is attacked or is moved away while writing, as the board scripts in boards.zon do.
  
−
---~---~---~---~---~---~---~---~---
+
If the player is still writing, the editor finishes as if the player had ended it: the
 +
<code>SFB_EDIT</code> event goes out as usual, with the text written so far in
 +
<code>argument</code>.
  
−
</i><!--ENDCODE-->
+
== Parameters ==
 +
{| class="wikitable"
 +
! Name !! Type !! Meaning
 +
|-
 +
| u || unitptr || The player.
 +
|}
  
 +
== Notes ==
 +
* The argument is required: <code>killedit;</code> without one is a syntax error.
 +
* Players only. On an NPC, object or room the zone log gets "Type error in not a pc unit" and the program stops.
 +
* With a null unit nothing happens, apart from a line in the zone log ("killedit with no unit").
 +
* A player who isn't connected (link-dead) is left as they are.
 +
* It ends any editor the player is in, also one started by a command such as <code>describe</code>, which then keeps what was written.
  
 +
== Example ==
 +
<pre>
 +
dilbegin write_note(fn : string);
 +
var
 +
  err : integer;
 +
code
 +
{
 +
  interrupt(SFB_DEAD, activator == self, stop);
 +
  interrupt(SFB_COM, activator == self, stop);
  
−
---~---~---~---~---~---~---~---~---
+
  sendtext("Write your note.<br/>", self);
−
<span id="bpkilledit"></span>
+
  beginedit(self);
 +
  wait(SFB_EDIT, activator == self);
 +
  if (argument != "")
 +
  {
 +
      err := savestr(fn, argument, "w");
 +
      sendtext("Note saved.<br/>", self);
 +
  }
 +
  quit;
  
−
'''Function: '''<i><!--CODE-->killedit ;</i><!--ENDCODE-->
+
:stop:
−
This function is used to kill the editor on a PC if it needs to
+
  killedit(self);
−
stop editing before the PC is done editing. An example of when this is needed
+
  sendtext("You stop writing.<br/>", self);
−
is when a player is killed while editing or is transfered away from a place where he was editing.
+
  quit;
−
You can let them finish but it may be wierd for a person to finish
+
}
−
posting in one room while in another.
 
−
'''Example'''
 
−
<i><!--CODE-->
 
−
---~---~---~---~---~---~---~---~---
 
−
 
 
−
dilbegin editextra (arg:string);
 
−
code
 
 
dilend
 
dilend
 +
</pre>
 +
Lets a player write a note to a file, and takes the player out of the editor when attacked or killed, as the reply code in boards.zon does.
  
−
---~---~---~---~---~---~---~---~---
+
== See also ==
−
 
+
* [[Manual:DIL Manual/beginedit()|beginedit()]]
−
</i><!--ENDCODE-->
+
* [[Manual:DIL Manual/editing|editing]]
−
 
+
* [[Manual:DIL Manual/interrupt()|interrupt()]]
−
 
+
* [[Manual:DIL Manual/wait()|wait()]]
−
 
 
−
---~---~---~---~---~---~---~---~---
 

Latest revision as of 23:21, 14 November 2026

killedit()

Procedure. Takes a player out of the text editor.

killedit(u : unitptr)

Ends the editor that beginedit() started for the player u, and puts the player back at the normal command prompt. Use it when the player dies, is attacked or is moved away while writing, as the board scripts in boards.zon do.

If the player is still writing, the editor finishes as if the player had ended it: the SFB_EDIT event goes out as usual, with the text written so far in argument.

Parameters

Name Type Meaning
u unitptr The player.

Notes

  • The argument is required: killedit; without one is a syntax error.
  • Players only. On an NPC, object or room the zone log gets "Type error in not a pc unit" and the program stops.
  • With a null unit nothing happens, apart from a line in the zone log ("killedit with no unit").
  • A player who isn't connected (link-dead) is left as they are.
  • It ends any editor the player is in, also one started by a command such as describe, which then keeps what was written.

Example

dilbegin write_note(fn : string);
var
   err : integer;
code
{
   interrupt(SFB_DEAD, activator == self, stop);
   interrupt(SFB_COM, activator == self, stop);

   sendtext("Write your note.<br/>", self);
   beginedit(self);
   wait(SFB_EDIT, activator == self);
   if (argument != "")
   {
      err := savestr(fn, argument, "w");
      sendtext("Note saved.<br/>", self);
   }
   quit;

:stop:
   killedit(self);
   sendtext("You stop writing.<br/>", self);
   quit;
}
dilend

Lets a player write a note to a file, and takes the player out of the editor when attacked or killed, as the reply code in boards.zon does.

See also