Difference between revisions of "Message Spam"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Wrye
(Rewrite.)
imported>QQuix
(Updated information on OBSE spamless functions)
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__NOTOC__[[Category: Useful Code]]
__NOTOC__[[Category: Useful Code]]
Tes4 displays messages to the player whenever: 1) spells are added to, 2) items are added to or removed from the player. For some scripts such messages are very undesirable (e.g. for an alchemical sorters which adds/removes many items). Hence, message "spam". There are several techniques for avoiding this spam.
Tes4 displays messages to the player whenever: 1) spells are added to, 2) items are added to or removed from the player. For some scripts such messages are very undesirable (e.g. for an alchemical sorters which adds/removes many items). Hence, message "spam". There are several techniques for avoiding this spam.
===AddItem - aTemp Container===
When adding items to the player, spam can be avoided by first adding the item to a container, and then removing the contents from the container to the player. This works because unlike addItem, [[RemoveAllItems]] is silent.
<pre>
tempContainerRef.addItem deathDagger 1
tempContainerRef.removeAllItems player</pre>
If you're using [[Glossary#C|Cobl]], you can use '''cobGenXFerRef''' for the temporary container -- it's defined for just this sort of use.
'''Note:''' Do ''not'' wait a frame to remove the item to the player. If you do, you run the chance of running the item's script, which in rare circumstances can cause problems.


===Message Queue Overloading===
===Message Queue Overloading===
Simplest technique is to overload the message queue by sending the exact same message twice in a row. I.e.
Simplest technique is to overload the message queue by sending the exact same message twice in a row <i>before</i> the offending add or remove line, <i>i.e.</i>
<pre>;--No messages.
<pre>;--No messages.
message " "
message " "
message " "
message " "
addItem myItem, 1


;--OR... Covering message...
;--OR... Covering message...
message "[You've been pickpocketed!]"
message "[You've been pickpocketed!]"
message "[You've been pickpocketed!]"</pre>
message "[You've been pickpocketed!]"
addItem myItem, 1</pre>


There's no obvious reason why this does or should work, but it does. :shrug: The message that is sent (including a blank message) will still display for the usual time, but messages that would ordinarily appear after it seem to be discarded -- i.e. they never enter the queue.
There's no obvious reason why this does or should work, but it does. :shrug: The message that is sent (including a blank message) will still display for the usual time, but messages that would ordinarily appear after it seem to be discarded -- i.e. they never enter the queue.


'''Con:''' The downside of this approach is that it may block more messages than you want to block. It basically nukes the queue for several frames -- any message sent by any script or action during that period will be lost.
'''Con:''' The downside of this approach is that it may block more messages than you want to block. It basically nukes the queue for a second or two -- any message sent by any script or action during that period will be lost.
 
'''Con:''' Some UI mods add an Oblivion icon for all messages. This icon will still appear for the duration of the message - defeating the purpose of the blank message.


===OBSE Commands===
===OBSE Commands===
As of version 0.15, [[:Category:Oblivion Script Extender|OBSE]] has commands for adding/removing objects that do not generate spam.
OBSE provides the following spam free versions as alternatives for vanilla functions that generate spam messages and sound:
 
 
These two functions do not span messages when adding and removing spells:
*[[AddSpellNS]]
*[[RemoveSpellNS]]
 
 
These two functions do not span messages when equipping and unequipping:
*[[EquipItemNS]]
*[[UnequipItemNS]]
 
 
These functions do not span messages and do not generate the corresponding sound:
*[[AddItemNS]]
*[[RemoveItemNS]]
*[[EquipItemSilent]]
*[[UnequipItemSilent]]


See: [[AddItemNS]], [[RemoveItemNS]]


===Temp Container===
When adding items to the player, spam can be avoided by first adding the item to a container, and then removing the contents from the container to the player. This works because unlike addItem, [[RemoveAllItems]] is silent.
<pre>
tempContainerRef.addItem deathDagger 1
tempContainerRef.removeAllItems player 1</pre>


If you're using [[Glossary#C|Cobl]], you can use '''cobGenXFerRef''' for the temporary container -- it's defined for just this sort of use.


===Item Activate===
===Item Activate===

Latest revision as of 08:17, 17 November 2012

Tes4 displays messages to the player whenever: 1) spells are added to, 2) items are added to or removed from the player. For some scripts such messages are very undesirable (e.g. for an alchemical sorters which adds/removes many items). Hence, message "spam". There are several techniques for avoiding this spam.

AddItem - aTemp Container[edit | edit source]

When adding items to the player, spam can be avoided by first adding the item to a container, and then removing the contents from the container to the player. This works because unlike addItem, RemoveAllItems is silent.

tempContainerRef.addItem deathDagger 1
tempContainerRef.removeAllItems player

If you're using Cobl, you can use cobGenXFerRef for the temporary container -- it's defined for just this sort of use.

Note: Do not wait a frame to remove the item to the player. If you do, you run the chance of running the item's script, which in rare circumstances can cause problems.

Message Queue Overloading[edit | edit source]

Simplest technique is to overload the message queue by sending the exact same message twice in a row before the offending add or remove line, i.e.

;--No messages.
message " "
message " "
addItem myItem, 1

;--OR... Covering message...
message "[You've been pickpocketed!]"
message "[You've been pickpocketed!]"
addItem myItem, 1

There's no obvious reason why this does or should work, but it does. :shrug: The message that is sent (including a blank message) will still display for the usual time, but messages that would ordinarily appear after it seem to be discarded -- i.e. they never enter the queue.

Con: The downside of this approach is that it may block more messages than you want to block. It basically nukes the queue for a second or two -- any message sent by any script or action during that period will be lost.

Con: Some UI mods add an Oblivion icon for all messages. This icon will still appear for the duration of the message - defeating the purpose of the blank message.

OBSE Commands[edit | edit source]

OBSE provides the following spam free versions as alternatives for vanilla functions that generate spam messages and sound:


These two functions do not span messages when adding and removing spells:


These two functions do not span messages when equipping and unequipping:


These functions do not span messages and do not generate the corresponding sound:



Item Activate[edit | edit source]

When adding items whose "activate" action results in being added to inventory (e.g. armor, but not books), you can use activate in a script.

someItemRef.activate player

Pro/Con: Requires that you have a ref for the item. On the plus side,this means that if you want the player to pick up a specific pre-existing, placed item, you can do that.