Author Topic: TM Journal Subs  (Read 3320 times)

0 Members and 1 Guest are viewing this topic.

Offline The ReaperTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 1
  • The Reaper has no influence.
  • Respect: +14
  • Referrals: 1
    • View Profile
TM Journal Subs
« on: May 01, 2011, 10:42:08 PM »
0
Ok, I'm having problems with the world save on my free-shard. I want the script to pause for the world save so I'm using TM's Journal scanner. But it's not working.

The system message says:
"The world will save in 15 seconds."

The code I'm using at the start of my script is:
Code: [Select]
gosub TM_AdvJournalSync world 100
The code I'm using within the main loop of my script is:
Code: [Select]
gosub TM_AdvJournalScan world VALID_ADVANCE The_world_will
if result =  #true
   {
   sound
   wait 300
   if %debug = 2
      {
      display ok You've sucessfully got TMs sub to work
      }
   }

Any help would be much appreciated

Offline The ReaperTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 1
  • The Reaper has no influence.
  • Respect: +14
  • Referrals: 1
    • View Profile
Re: TM Journal Subs
« Reply #1 on: May 01, 2011, 11:40:02 PM »
0
The problem I'm having is that the journal scanning isn't working, not sure what I've done wrong :S

The journal doesn't contain "The world will save in 15 seconds" by the time the script gets around to reading it, as it all depends on what the script was doing when the server made it's announcement. I was under the impression that TM's sub searched back the last 4 lines of journal entries?? :S

Code: [Select]
;==================================
; Script Name: Reaper's Board Maker
; Author: The Reaper
; Version: 1.0
; Client Tested with: 7.0.8.0
; EUO version tested with: 1.5.186
; Purpose: Making boards the old fashioned way on freeshards.
; Special thanks to TM for the journal scanner subs :D
;==================================
set %debug 2
;==================================
; Set %axe to the value of your axe or script will ask you to select it
set %axe null
;==================================

event Macro 8 2 ;open status bar
wait 20
set #contPosX 850
set #contPosY 400

menu clear
Menu hideEUO
Menu window size 260 100
Menu show
Menu window color black
Menu font bgcolor red
Menu font size 10
menu Window Title Created by: The Reaper
menu text Tboard 5 5 What type of logs will you be cutting today?
menu combo create type 5 50 100
menu combo add type Plain
menu combo add type Oak
menu combo add type Yew
menu combo add type Bloodwood
menu combo add type Heartwood
menu combo add type Frostwood
menu combo add type ALL LOGS
menu button 1 0 80 260 20 GO!
set #menubutton N/A
while #menubutton = N/A
      {
      wait 0
      }
menu get type
menu hide
if %debug = 1
   {
   display ok #menures
   }
if #menures = 0
   {
   display ok You must select a type of wood
   halt
   }
if #menures = 1
   {
   set %log_type ZLK
   set %wood_name Plain
   set %board_type TLK
   }
if #menures = 2
   {
   set %log_type na
   set %wood_name Oak
   set %board_type na
   }
if #menures = 3
   {
   set %log_type na
   set %wood_name Yew
   set %board_type na
   }
if #menures = 4
   {
   set %log_type na
   set %wood_name Bloodwood
   set %board_type na
   }
if #menures = 5
   {
   set %log_type na
   set %wood_name Heartwood
   set %board_type na
   }
if #menures = 6
   {
   set %log_type na
   set %wood_name Frostwood
   set %board_type na
   }
if #menures = 7
   {
   set %log_type ZLK
   set %wood_name All
   set %board_type TLK
   }

;Weight Setup
set %no_logs ( ( 550 - #weight ) / 2 )
if debug = 1
   {
   set %no_logs 2
   }
set %no_boards ( %no_logs * 2 )
;Axe Setup
if %axe = null
   {
   display ok Select your axe
   set #ltargetID null
   set #targcurs 1
   while #targcurs = 1
         {
         wait 0
         }
   set %axe #ltargetID
   }
   
;Secure or Bank box (Bank if Yes, Secure if no)
display yesno Logs will be dragged from: Bank=Yes, Secure=No
if #dispRes = yes
   {
   msg Bank $
   display ok Target your storage bag inside your bank now
   set #ltargetid null
   set #targcurs 1
   while #targcurs = 1
         {
         wait 0
         }
   set %secure_cont #ltargetID
   set %storage_method bank
   }
if #dispRes = no
   {
   display ok Target your secure now
   set #ltargetid null
   set #targcurs 1
   while #targcurs = 1
         {
         wait 0
         }
   set %secure_cont #ltargetID
   set %storage_method Secure_cont
   }
;=======
; Testing Only
;=======
if %debug = 1
   {
   display ok Storage method is: %storage_method   With #ID: %secure_cont $ With axe #ID: %axe $ This script will move: $ %wood_name Boards: %no_boards Logs: %no_logs $ on each cycle.
   }
;=======
wait 30
gosub TM_AdvJournalSync world 100

if %storage_method = bank
   {
   gosub open_bank
   goto Bank_loop
   }
else
    {
    gosub open_secure
    goto Secure_loop
    }

Bank_loop:
gosub drag_to_backpack
gosub cut
gosub drag_to_secure
gosub TM_AdvJournalScan world ADVANCE The_world_will
if result =  #true
   {
   sound
   wait 300
   if %debug = 2
      {
      display ok You've sucessfully got TMs sub to work
      }
   }
goto Bank_loop

Secure_loop:
gosub drag_to_backpack
gosub cut
gosub drag_to_secure
gosub TM_AdvJournalScan world ADVANCE The_world_will
if result =  #true
   {
   sound
   wait 300
   if %debug = 2
      {
      display ok You've sucessfully got TMs sub to work
      }
   }
goto Secure_loop


sub open_bank
msg Bank$
wait 10
set #lobjectid %secure_cont
event macro 17 0
wait 10
gosub Find_logs
return

sub open_secure
set #lobjectid %secure_cont
event macro 17 0
wait 10
gosub Find_logs
return


sub Find_logs
finditem %log_type C_ , %secure_cont
if #findkind = -1
   {
   display ok You do not have any of that type of log in your secure. $ Halting!
   halt
   }
set %log_stack #findid
if %debug = 1
   {
   display ok You have #findstack %wood_name logs in your secure, these will now be chopped into boards.
   }
return

sub drag_to_backpack
finditem %log_type C_ , %secure_cont
if #findkind = -1
   {
   display ok Ohhh no, you've run out of logs to chop :D
   halt
   }
Exevent Drag #findid %no_logs
wait 16
Exevent Dropc #backpackID
wait 20

return

sub cut
finditem %log_type C_ , #backpackid
if #findkind = -1
   {
   display ok Ohhh no, somethings gone wrong, restart the script.
   pause
   }
set #lobjectid %axe
event macro 17 0
target 2s
wait 5
set #ltargetid #findid
event macro 22 0
wait 20
return

sub drag_to_secure
finditem %board_type C_ , #backpackid
if #findkind = -1
   {
   display ok Ohhh no, somethings gone wrong, restart the script.
   pause
   }
Exevent Drag #findid #findstack
wait 16
Exevent Dropc %secure_cont
wait 20
return

sub TM_AdvJournalSync
  namespace push
  namespace local TM_AdvJS_ , %1
  set !_jindex #jindex + 1
  if %0 > 1
    set !lpc_set %2
  namespace pop
  set !TM_FunctionCalled #TRUE
return

sub TM_AdvJournalScan
  namespace push
  namespace local TM_AdvJS_ , %1
  set !args %2
  set !temp_lpc #LPC
  if !lpc_set = N/A
    set #LPC 1000
  else
    set #LPC !lpc_set
  set !num_args %0
  set !first_arg 3
  set !sampled_jindex #JINDEX
  if !_jindex = N/A
    set !_jindex !sampled_jindex
  if !charname = N/A
  {
    set !charname #CHARNAME
    AdvJournalScan_loop1:
      str pos !charname #SPC
      if #STRRES <> 0
      {
        set !val #STRRES - 1
        str left !charname !val
        set !left #STRRES
        set !val !val + 1
        str del !charname 1 !val
        set !charname !left , _ , #STRRES
        goto AdvJournalScan_loop1
      }
  }
  set !index !first_arg
  repeat
    set !temp_jindex !_jindex
    set !text % . !index
    while !temp_jindex <= !sampled_jindex
    {
      scanjournal !temp_jindex
      str pos #JOURNAL !charname 1
      set !namepos #STRRES
      str count #JOURNAL !charname
      set !namecnt #STRRES
      str pos #JOURNAL :_ 1
      set !smcpos #STRRES
      str pos #JOURNAL !text 1
      set !textpos #STRRES
      if !textpos < !smcpos && !smcpos <> 0 || !smcpos = 1 || :_ notin #JOURNAL || VALID notin !args
        set !pass #TRUE
      else
        set !pass #FALSE
      if ( !text in #journal && ( ( !namepos = 1 && !namecnt <= 1 ) || !pass ) )
      {
        set !temp_jindex !temp_jindex + 1
        if ADVANCE in !args
          set !_jindex !temp_jindex
        set #LPC !temp_lpc
        namespace pop
        set !TM_FunctionCalled #TRUE
        return #TRUE
      }
      set !temp_jindex !temp_jindex + 1
    }
    set !index !index + 1
  until !index - !first_arg > !num_args - !first_arg
  set %10 !sampled_jindex - !_jindex
  set %10 %1 , _ , %10 ; for debugging purposes
  set #LPC !temp_lpc
  namespace pop
  set !TM_FunctionCalled #TRUE
return #FALSE

   

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13304
  • Activity:
    0.6%
  • 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: TM Journal Subs
« Reply #2 on: May 02, 2011, 07:41:24 AM »
0
You'll kick yourself....

Inspect this line and tell me what's wrong:

Code: [Select]
if result =  #true

Also, you should be able to use valid_advance without issue.
« Last Edit: May 02, 2011, 07:42:57 AM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline _C2_

  • AFK FtW
  • Global Moderator
  • *
  • *
  • Posts: 4077
  • Activity:
    0%
  • Reputation Power: 48
  • _C2_ has great potential!_C2_ has great potential!_C2_ has great potential!_C2_ has great potential!_C2_ has great potential!_C2_ has great potential!_C2_ has great potential!_C2_ has great potential!_C2_ has great potential!
  • RIP Pen Trick
  • Respect: +254
  • Referrals: 4
    • View Profile
Re: TM Journal Subs
« Reply #3 on: May 02, 2011, 07:44:09 AM »
0
ouch that is a good one.  that will kill a script fast.

tm was the valid_advance also messing it up.  i thought that was an issue too.

Offline Paulonius

  • Elite
  • *
  • *
  • Posts: 2040
  • Activity:
    0%
  • Reputation Power: 29
  • Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.
  • Respect: +162
  • Referrals: 1
    • View Profile
Re: TM Journal Subs
« Reply #4 on: May 02, 2011, 07:49:34 AM »
0
#Result

Nice editing catch TM.
This coin declares Caesar is "Dictator for Life." He did serve as Dictator for the remainder of his life, but his life would end only a few weeks after this issue. For Caesar to put his image on coins and essentially declare himself king was too much for Brutus and his republican allies.

"If everything seems under control, you're not going fast enough'
-Mario Andretti

"If everyone is thinking alike, someone isn't thinking."
- General George Patton Jr

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13304
  • Activity:
    0.6%
  • 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: TM Journal Subs
« Reply #5 on: May 02, 2011, 07:58:19 AM »
0
tm was the valid_advance also messing it up.  i thought that was an issue too.

valid_advance is OK in that case.  If you don't either use "advance" or a sync, the journal sub will "run away" and take longer and longer to run.  Since he's only using one scan, you won't need to worry about missing another statement.

You can catch run away conditions by monitoring the variable %10.  This will include the name of the journal scanner (world in this case) and the depth of the search.  If this number starts to get too big, then you probably are missing a "sync" or and advance.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline The ReaperTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 1
  • The Reaper has no influence.
  • Respect: +14
  • Referrals: 1
    • View Profile
Re: TM Journal Subs
« Reply #6 on: May 02, 2011, 12:15:59 PM »
0
There's also a double space in there that shouldn't be. FFS, written completely without testing, then tested completed article. And only 2 mistakes were in the same line. Thanks guys.

Feel stupid now :(

Scrripty

  • Guest
Re: TM Journal Subs
« Reply #7 on: May 02, 2011, 12:38:46 PM »
0
Just wait until you do that after writing 2k lines of code without testing...  And you will.  Just watch. :)

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13304
  • Activity:
    0.6%
  • 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: TM Journal Subs
« Reply #8 on: May 02, 2011, 01:27:15 PM »
0
Typically I'll take a problem section and trim it down.  That's what I did with your code, and viola it popped out.  Also I loaded it into ScriptUO; the coloration is much clearer so I immediately noticed the issue.  Syntax check doesn't help, however.  It's just a valid typo.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: TM Journal Subs
« Reply #9 on: May 02, 2011, 01:33:19 PM »
0
There's also a double space in there that shouldn't be. FFS, written completely without testing, then tested completed article. And only 2 mistakes were in the same line. Thanks guys.

Feel stupid now :(

Don't feel stupid, for me personally 80% of the time i spend coding is debugging and 80% of the debugging time is debugging typos.
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Scrripty

  • Guest
Re: TM Journal Subs
« Reply #10 on: May 02, 2011, 01:39:36 PM »
0
I spend most of my debugging time debugging logical errors in flow, or execution, not really typing errors or code problems.  Although I have my share too.  I try to find the worst spots in a script and I'll play with them until my brain hurts to make them the best they can be. :)  I recommend you go read my tutorial on the site for journal scanning, it's a little old, but will help you to understand the basics of journal scanning, write your own journal scan from scratch so you get a better idea of how TM's subs work.  It's really very simple how it works.  Just getting that basic understanding of it is hard at first.

Tags: