Author Topic: Hrm, am I going about this situation the right way?  (Read 2803 times)

0 Members and 1 Guest are viewing this topic.

Offline silentsentinelTopic starter

  • Jr. Member
  • **
  • Posts: 31
  • Activity:
    0%
  • Reputation Power: 0
  • silentsentinel has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Hrm, am I going about this situation the right way?
« on: April 26, 2009, 08:15:26 PM »
0
Hey all,

Alrighty, so I'm running into a bit of a logical issue in my script. Basically, to make this as simple as possible to explain, I have a sub, alertCheck, that is called from many places in my script to scan for player death, certain system messages, and GM's. Let's say this is it:

Code: [Select]
set %jStart #jindex + 1
set %jTimeout #scnt2 + 5
while #scnt2 < %jTimeout
{
set %jEnd #jindex
if %jEnd >= %jStart
{
for %ji %jStart %jEnd
{
scanjournal %ji
if gm in #journal
set %gmDetected #true
}
set %jStart %jEnd + 1
        }
}

My problem is this. Basically there are points where this sub is called, where there has been spam, and it's possible a flag could be on a line that is not #jindex + 1. It could be, say, 5 lines up due to the journal spam.

I thought this would be simple to account for, and I set %jStart to #jindex + 5 in the 2 applicable spots in the code, this did not work as I thought it would... no matter how long you give it to scan, apparently #jindex + [Anything other than 1] is an illegal statement.

Basically, is there any way to force the journal scan to start a few lines up? What I'm doing just seems to break it. Need some way of retro-scanning a few lines if it's possible.

Anyone have any ideas on what I might try? Thanks much
« Last Edit: April 26, 2009, 08:18:17 PM by silentsentinel »

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Hrm, am I going about this situation the right way?
« Reply #1 on: April 26, 2009, 10:01:41 PM »
0
Did you take a look at my journal scanner?  There's some logic in there that might help you, but basically I just maintain a version of the #jindex that I always update.  The jindex copy only changes once a line is scanned after new journal entries come in.

I recommend you look at my logic flow for some ideas.  It works pretty well.

http://www.scriptuo.com/index.php?topic=33.0
« Last Edit: April 26, 2009, 10:10:55 PM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline silentsentinelTopic starter

  • Jr. Member
  • **
  • Posts: 31
  • Activity:
    0%
  • Reputation Power: 0
  • silentsentinel has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Hrm, am I going about this situation the right way?
« Reply #2 on: April 26, 2009, 10:52:56 PM »
0
Hey TrailMyx, checking out your journal sub. One quick question though which will help in my understanding this... which direction does the statement "#jindex + 1" count? Does it go towards the old lines, or, is it counting one line AHEAD of the current bottom line?

Why do people use #jindex + 1 instead of just setting #jindex, that is? Thanks a ton

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Hrm, am I going about this situation the right way?
« Reply #3 on: April 26, 2009, 11:20:17 PM »
0
Hey TrailMyx, checking out your journal sub. One quick question though which will help in my understanding this... which direction does the statement "#jindex + 1" count? Does it go towards the old lines, or, is it counting one line AHEAD of the current bottom line?

Why do people use #jindex + 1 instead of just setting #jindex, that is? Thanks a ton

It definitely goes from older to newer.  The reason for the #jindex + 1 in my subs is that as #jindex advances, it will become equal to or greater than the recorded version of #jindex, telling you that there are new items to be scanned.

So the #jindex + 1 just tells the script, "I know I haven't seen anything new, but when I do, I want to know about it."

Perhaps it would be a good idea to single step through the script and add a few watched variable so you can see the mechanics.  Typically that what I do when I write these kinds of things.  I spend a LOT of time single stepping.  ;)
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline silentsentinelTopic starter

  • Jr. Member
  • **
  • Posts: 31
  • Activity:
    0%
  • Reputation Power: 0
  • silentsentinel has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Hrm, am I going about this situation the right way?
« Reply #4 on: April 27, 2009, 08:27:54 AM »
0
That makes sense.

I tried, in my GM check, using Jindex - 5, to retroscan the old lines, and it seems to work as intended. (5 lines is probably too much of a margin, just using it for testing.)

Now I think I understand a bit more of the logic. Thanks much!

Offline silentsentinelTopic starter

  • Jr. Member
  • **
  • Posts: 31
  • Activity:
    0%
  • Reputation Power: 0
  • silentsentinel has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Hrm, am I going about this situation the right way?
« Reply #5 on: April 27, 2009, 10:05:26 AM »
0
Ugh, hell.

I thought I had it. :(

It seems to at least scan backwards like I need.... but it only works about half the time. It also fails to catch any new speech, despite the new speech being spammed (spamming GM with another char) to make SURE it fell between %jstart (5 lines up) and %jend, being continually set to the index.

I have no idea why it's skipping lines like this.

I tried with and without the if %jEnd >= %jStart statement (it seemed redundant given where I'm setting %jStart and #jindex/%jEnd) - made no difference.

Here's the sub. I tried checking out your other journal script, the problem is, I really at this point don't see a logical issue with this code. It works some of the time, other times it completely misses the flag. Plus I really learn by doing in the end. Even if I somehow patched it together I am more concerned with why this isn't working. :/

Thanks for any advice guys, as always.

Code: [Select]
sub alertCheck
{
set %wrongText #false
set %wrongTextException #false
set %textFlag none
set %jStart #jindex - 5
set %jTimeout #scnt2 + 50
while #scnt2 < %jTimeout
{
set %jEnd #jindex
if %jEnd >= %jStart
{
for %ji %jStart %jEnd
{
scanjournal %ji
if you_see:_admin in #journal || you_see:_counselor in #journal || you_see:_game in #journal || you_see:_gm in #journal || you_see:_staff in #journal
set %wrongTextException #true
if %wrongTextException = #false && ( ,_ , #charname , ! in #journal || #charname , :_ in #journal || afrodite in #journal || botan in #journal || bottle in #journal || can_page_for_vendor in #journal || guildmaster in #journal || i_seem_to_have_lost_my_master in #journal || samantha in #journal || samirah in #journal || samson in #journal || samuel in #journal || spell_fizzles in #journal || staff_message_from_gm in #journal || steal in #journal || you_see: in #journal || wishmaster in #journal )
set %wrongText #true
if %wrongText = #false && ( #charname in #journal || admin in #journal || afk in #journal || answer in #journal || bot in #journal || counselor in #journal || game in #journal || gm in #journal || greetings in #journal || hello in #journal || hey in #journal || macro in #journal || master in #journal || page in #journal || respond in #journal || script in #journal || speak in #journal || talk in #journal )
{
if #charname in #journal
set %textFlag #charname
if admin in #journal
set %textFlag admin
if afk in #journal
set %textFlag afk
if answer in #journal
set %textFlag answer
if bot in #journal
set %textFlag bot
if counselor in #journal
set %textFlag counselor
if game in #journal
set %textFlag game
if gm in #journal
set %textFlag gm
if greetings in #journal
set %textFlag greetings
if hello in #journal
set %textFlag hello
if hey in #journal
set %textFlag hey
if macro in #journal
set %textFlag macro
if master in #journal
set %textFlag master
if page in journal
set %textFlag page
if respond in #journal
set %textFlag respond
if script in #journal
set %textFlag script
if speak in #journal
set %textFlag speak
if talk in #journal
set %textFlag talk
wait 40
event macro 1 0 ...
event macro 13 21
display ok Alert: #charname being watched! Flag: %textFlag - Script halted!$
halt
}
if is_attacking_you in #journal
{
wait 20
event macro 1 0 ...
wait 20
event macro 13 21
display ok Alert: #charname being attacked! Script halted!$
halt
}
if more_reagents_are_needed_for_this_spell in #journal
{
wait 20
event macro 13 21
display ok Alert: #charname is out of reagents! Script halted!$
halt
}
if i_see_you_already_have_an_escort in #journal
{
wait 20
event macro 13 21
display ok Alert: #charname has an escort stuck! Script halted!$
halt
}
if world_will_save in #journal
{
wait 20
event macro 13 21
event exmsg #charid 0 175 World saving! Pausing script for 1 minute, 30 seconds!
event exmsg #charid 0 175 ...
event exmsg #charid 0 175 ...
event exmsg #charid 0 175 ...
event exmsg #charid 0 175 ...
event exmsg #charid 0 175 ...
wait 1800
}
}
set %jStart %jEnd - 5
}
}
if #charghost = yes
{
display ok Alert: #charname died! Script halted!$
halt
}
return
}

Here's alertcheck in all it's glory.
« Last Edit: April 27, 2009, 10:11:55 AM by silentsentinel »

Offline silentsentinelTopic starter

  • Jr. Member
  • **
  • Posts: 31
  • Activity:
    0%
  • Reputation Power: 0
  • silentsentinel has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Hrm, am I going about this situation the right way?
« Reply #6 on: April 27, 2009, 10:22:15 PM »
0
Ok so my last question in understanding this completely is basically: Why is the
Code: [Select]
if %jEnd >= %jStart"
{

}
set %jStart %jEnd + 1 (or set %jStart %jEnd)
even used?

It seems redundant, but maybe I'm missing something in the logic. Basically it seems as if %jEnd/#jindex will never NOT be >= whatever you set %jStart to, right?

For whatever reason the script seemed to process a bit faster with that statement in place... but I totally don't see why it's used, if someone could explain it a bit.

I think I understand the rest, just wanna figure out this last piece. Thanks all.  ;)

Tags: