[Scripters] How to use SpewStat Events
Posted: 17 Aug 2024, 10:27
Made a new super easy way to get a return from any spewstat value, even if it takes "time" to process (such as faction, currency etc).
You can attach to event named "OgreEvent_SpewStats", which provides 1 parameter of jsonvalue with all the details.
Lets look at a super simple example.
Now, you SHOULD always be using objects... however, this example includes how to use it in an object, and how to not use an object (using an atom). Pick your preferred way (should be object).
Now, any time a spewstat is issued, you'll get responses. This is done over the uplink.
For example: Lets say we want to look at dungeon marks.
(I have two characters online, Toon1 and Toon2)
(It's only showing each person twice because we have attached to the event twice, once via atom and once via event)
Examine 2: Looking at resolve
Same two characters
Just keep in mind, everything will take "time" to be processed and results sent back to you. Specifically faction/currency/etc. Things that have to open the persona window. Things like resolve that are very fast, still technically take time (measured in mili-seconds, but you still have to account for it).
Note: If it would not have an output normally, it won't have an output here.
This is checking to see if anyone does NOT have a reset item (notice the ! before item) (Both of mine do, so there is no output)
Whereas if we check if we DO have the item
We get a results
Finally, some outputs (at the time of writing this, only faction) have some additional data.
Results: Notice the FactionStanding
Lastly, if you do not want these to output anywhere (all the above examples would output to OgreConsole or IRC), you can use the word "event" to send them exclusively to the event. For example:
Has no output to the console, but the OgreEvents still trigger.
You can attach to event named "OgreEvent_SpewStats", which provides 1 parameter of jsonvalue with all the details.
Lets look at a super simple example.
Now, you SHOULD always be using objects... however, this example includes how to use it in an object, and how to not use an object (using an atom). Pick your preferred way (should be object).
- Code: Select all
function main()
{
variable Object_SpewStatsEvent Obj_SpewStatsEvent
Event[OgreEvent_SpewStats]:AttachAtom[OgreEvent_SpewStats]
while 1
waitframe
}
atom OgreEvent_SpewStats(jsonvalue _JSONValue)
{
echo ${Time}: atom OgreEvent_SpewStats: ${_JSONValue.AsJSON} Character: ${_JSONValue.Get["Character"]}
}
objectdef Object_SpewStatsEvent
{
method Initialize()
{
Event[OgreEvent_SpewStats]:AttachAtom[This:OgreEvent_SpewStats]
}
method OgreEvent_SpewStats(jsonvalue _JSONValue)
{
echo ${Time}: method OgreEvent_SpewStats: ${_JSONValue.AsJSON} Character: ${_JSONValue.Get["Character"]}
}
}
Now, any time a spewstat is issued, you'll get responses. This is done over the uplink.
For example: Lets say we want to look at dungeon marks.
- Code: Select all
!c -SpewStat auto "currency_Dungeon Mark"
(I have two characters online, Toon1 and Toon2)
- Code: Select all
11:15:41: atom OgreEvent_SpewStats: {"Character":"Toon1","Command":"Currency","Label":"Dungeon Mark","Value":"24412"} Character: Toon1
11:15:41: method OgreEvent_SpewStats: {"Character":"Toon1","Command":"Currency","Label":"Dungeon Mark","Value":"24412"} Character: Toon1
11:15:43: atom OgreEvent_SpewStats: {"Character":"Toon2","Command":"Currency","Label":"Dungeon Mark","Value":"724207"} Character: Toon2
11:15:43: method OgreEvent_SpewStats: {"Character":"Toon2","Command":"Currency","Label":"Dungeon Mark","Value":"724207"} Character: Toon2
(It's only showing each person twice because we have attached to the event twice, once via atom and once via event)
Examine 2: Looking at resolve
- Code: Select all
!c all -spewstats auto resolve irc
Same two characters
- Code: Select all
11:17:30: atom OgreEvent_SpewStats: {"Character":"Toon2","Command":"resolve","Label":"Resolve:","Value":"10,330"} Character: Toon2
11:17:30: method OgreEvent_SpewStats: {"Character":"Toon2","Command":"resolve","Label":"Resolve:","Value":"10,330"} Character: Toon2
11:17:30: atom OgreEvent_SpewStats: {"Character":"Toon1","Command":"resolve","Label":"Resolve:","Value":"10,360"} Character: Toon1
11:17:30: method OgreEvent_SpewStats: {"Character":"Toon1","Command":"resolve","Label":"Resolve:","Value":"10,360"} Character: Toon1
Just keep in mind, everything will take "time" to be processed and results sent back to you. Specifically faction/currency/etc. Things that have to open the persona window. Things like resolve that are very fast, still technically take time (measured in mili-seconds, but you still have to account for it).
Note: If it would not have an output normally, it won't have an output here.
- Code: Select all
11:20:12: !c -SpewStat auto "!item_Instance Lockout Reset: 7 Day Reuse" irc
This is checking to see if anyone does NOT have a reset item (notice the ! before item) (Both of mine do, so there is no output)
Whereas if we check if we DO have the item
- Code: Select all
!c -SpewStat auto "item_Instance Lockout Reset: 7 Day Reuse"
We get a results
- Code: Select all
11:21:23: atom OgreEvent_SpewStats: {"Character":"Toon2","Command":"item_Instance Lockout Reset: 7 Day Reuse","Label":"has item:","Value":"Instance Lockout Reset: 7 Day Reuse"} Character: Toon2
11:21:23: method OgreEvent_SpewStats: {"Character":"Toon2","Command":"item_Instance Lockout Reset: 7 Day Reuse","Label":"has item:","Value":"Instance Lockout Reset: 7 Day Reuse"} Character: Toon2
11:21:23: atom OgreEvent_SpewStats: {"Character":"Toon1","Command":"item_Instance Lockout Reset: 7 Day Reuse","Label":"has item:","Value":"Instance Lockout Reset: 7 Day Reuse"} Character: Toon1
11:21:23: method OgreEvent_SpewStats: {"Character":"Toon1","Command":"item_Instance Lockout Reset: 7 Day Reuse","Label":"has item:","Value":"Instance Lockout Reset: 7 Day Reuse"} Character: Toon1
Finally, some outputs (at the time of writing this, only faction) have some additional data.
- Code: Select all
!c -SpewStat auto "faction_The city of Qeynos"
Results: Notice the FactionStanding
- Code: Select all
11:23:27: atom OgreEvent_SpewStats: {"Character":"Toon1","Command":"Faction","Label":"The City of Qeynos","Value":"13,000","FactionStanding":"amiably"} Character: Toon1
11:23:27: method OgreEvent_SpewStats: {"Character":"Toon1","Command":"Faction","Label":"The City of Qeynos","Value":"13,000","FactionStanding":"amiably"} Character: Toon1
11:23:27: atom OgreEvent_SpewStats: {"Character":"Toon2","Command":"Faction","Label":"The City of Qeynos","Value":"40,000","FactionStanding":"ally"} Character: Toon2
11:23:27: method OgreEvent_SpewStats: {"Character":"Toon2","Command":"Faction","Label":"The City of Qeynos","Value":"40,000","FactionStanding":"ally"} Character: Toon2
Lastly, if you do not want these to output anywhere (all the above examples would output to OgreConsole or IRC), you can use the word "event" to send them exclusively to the event. For example:
- Code: Select all
!c -SpewStat auto "currency_City Token" event
Has no output to the console, but the OgreEvents still trigger.