Author Topic: Any ideas how to shorten this up LOL  (Read 4996 times)

0 Members and 2 Guests are viewing this topic.

Offline Burnhazel88Topic starter

  • Jr. Member
  • **
  • Posts: 15
  • Activity:
    0%
  • Reputation Power: 1
  • Burnhazel88 has no influence.
  • Gender: Male
  • Respect: 0
  • Referrals: 0
    • View Profile
Any ideas how to shorten this up LOL
« on: October 12, 2017, 12:00:12 PM »
0
Working on adding clock to to a script and  wondering if this can be shortened some how.
Not a big fan of the 24 hour format.

Code: [Select]
;========= convert 24hr to 12 hr
if %24hrs = 00
{
  set %HH 12
}
if %24hrs = 01
{
  set %HH #spc , 1
}
if %24hrs = 02
{
  set %HH #spc , 2
}
if %24hrs = 03
{
  set %HH #spc , 3
}
if %24hrs = 04
{
  set %HH #spc , 4
}
if %24hrs = 05
{
  set %HH #spc , 5
}
if %24hrs = 06
{
  set %HH #spc , 6
}
if %24hrs = 07
{
  set %HH #spc , 7
}
if %24hrs = 08
{
  set %HH #spc , 8
}
if %24hrs = 09
{
  set %HH #spc , 9
}
if %24hrs = 10
{
  set %HH 10
}
if %24hrs = 11
{
  set %HH 11
}
if %24hrs = 12
{
  set %HH 12
}
if %24hrs = 13
{
  set %HH #spc , 1
}
if %24hrs = 14
{
  set %HH #spc , 2
}
if %24hrs = 15
{
  set %HH #spc , 3
}
if %24hrs = 16
{
  set %HH #spc , 4
}
if %24hrs = 17
{
  set %HH #spc , 5
}
if %24hrs = 18
{
  set %HH #spc , 6
}
if %24hrs = 19
{
  set %HH #spc , 7
}
if %24hrs = 20
{
  set %HH #spc , 8
}
if %24hrs = 21
{
  set %HH #spc , 9
}
if %24hrs = 22
{
  set %HH 10
}
if %24hrs = 23
{
  set %HH 11
}
if %24hrs = 24
{
  set %HH 12
}
Also the "#spc ," is not working as I thought it would. Gonna have to figure that one out.
« Last Edit: October 12, 2017, 12:12:32 PM by Burnhazel88 »

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • 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: Any ideas how to shorten this up LOL
« Reply #1 on: October 12, 2017, 12:22:02 PM »
0
Here's a quicky one that's untested that I just whipped up:

Code: easyuo
  1. gosub Convert24Hrs 22
  2. display ok #RESULT
  3. stop
  4.  
  5.  
  6. sub Convert24Hrs
  7.   if %1 < 12
  8.      set %ampm AM
  9.   else
  10.      set %ampm PM
  11.   if %1 = 0
  12.     set #RESULT 12
  13.   else
  14.     if %1 = 12
  15.        set #RESULT 12
  16.     else
  17.     {
  18.       set #RESULT %1 % 12
  19.       str len #RESULT
  20.       if #STRRES = 1
  21.          set #RESULT 0 , #RESULT
  22.     }
  23. return #RESULT , #SPC , %ampm
  24.  

Or a tweak:

Code: easyuo
  1.  
  2. gosub Convert24Hrs 22
  3. display ok #RESULT
  4. stop
  5.  
  6.  
  7. sub Convert24Hrs
  8.   if %1 < 12
  9.      set %ampm AM
  10.   else
  11.      set %ampm PM
  12.   if %1 = 0 || %1 = 12
  13.     set #RESULT 12
  14.   else
  15.     {
  16.       set #RESULT %1 % 12
  17.       str len #RESULT
  18.       if #STRRES = 1
  19.          set #RESULT 0 , #RESULT
  20.     }
  21. return #RESULT , #SPC , %ampm
  22.  
« Last Edit: October 12, 2017, 12:52:16 PM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline Burnhazel88Topic starter

  • Jr. Member
  • **
  • Posts: 15
  • Activity:
    0%
  • Reputation Power: 1
  • Burnhazel88 has no influence.
  • Gender: Male
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Any ideas how to shorten this up LOL
« Reply #2 on: October 12, 2017, 01:13:24 PM »
0
Thank you TM
 I have learned a lot from that little whip up.



OK
I had to look up the  % "Modulo Operator" to see how the math worked on that. Would not have thought of that in a million years.
Already had the AM PM figured out.
what I am trying to do now is I remove the 0 in front of 00 - 09 with str del now I want to replace it with a space to keep it lined up in my menu or someway to align it to the right.
is that even possible to have a space in beginning of %Variable

removed
Code: [Select]
      str len #RESULT
      if #STRRES = 1
         set #RESULT 0 , #RESULT

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • 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: Any ideas how to shorten this up LOL
« Reply #3 on: October 12, 2017, 03:34:25 PM »
0
Yes it's possible.  EasyUO string manipulation is a pain in the butt, but it's mostly functional.  Here's a quick example that might work:

Code: easyuo
  1. set %val 09 ; for example
  2. str len %val
  3. if #STRRES > 1
  4. {
  5.   str left %val 1
  6.   if #STRRES = 0
  7.   {
  8.     str del %val 1 1
  9.     set %val #STRRES
  10.   }
  11. }
  12.  

Sorry I didn't explain the modulo operator.  It's a more obscure part of most languages.  Not alot of people know how to use it or what it does.  But hey, at least you learned something new today!  :)
« Last Edit: October 12, 2017, 03:40:47 PM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline BobOzarius

  • Full Member
  • ***
  • Posts: 103
  • Activity:
    0%
  • Reputation Power: 2
  • BobOzarius has no influence.
  • Respect: +26
  • Referrals: 0
    • View Profile
Re: Any ideas how to shorten this up LOL
« Reply #4 on: October 13, 2017, 08:24:52 PM »
0
Can you shorten this up while you're at it?  Thanks. hehe

Code: [Select]
  if %belfry <> #true
  {
    finditem * g_ , %distance . #charid
    if #findcnt > 0
    {
      set %area |
      set %charposx #charposx
      set %charposy #charposy
      set %charposz #charposz
      for #findindex 1 #findcnt
      {
        if ( #findrep = 2 && #findid notin %safeIds && #findid notin *pvmSafeIds ) 3 ;|| ( #findrep < 1 || #findrep > 6 ) 5     ; < CHECK THIS CODE COMMENTED! TO SEE IF TILES WORK WHEN IGNORED
          if #findrep = 2 2
          set %safeIds %safeIds , #findid , _
        set *pvmSafeIds %pvmSafeIds , #findid , _
        if #findtype <> yfm && #findtype <> bwe && #findtype <> asc && #findtype <> faj && #findtype <> qaj && #findtype <> xui && #findtype <> zui && #findtype <> jbc && #findtype <> kxb && #findtype <> wwb && #findtype <> ssb && #findtype <> avi && #findtype <> uwgc && #findtype <> fxgc && #findtype <> pac && #findType <> sac && #findtype <> gbc && #findtype <> paj && #findtype <> gaj && #findtype <> iaj
          set %area %area , #findx , _ , #findy , |
      }
      for %w 1 #clicnt
      {
        if ( %charposx . %w , _ , %charposy . %w notin %area ) && ( %charposx . %w < %charposx + 11 && %charposx . %w > %charposx - 11 && %charposy . %w < %charposy + 11 && %charposy . %w > %charposy - 11 ) && ( %w <> #clinr )
          set %area %area , %charposx . %w , _ , %charposy . %w , |
      }
      set %x #charposx %symbol1 . #charid %x . #charid
      set %y #charposy %symbol2 . #charid %y . #charid
      set %check 0
      set %checkingShit |
      set %checkingShit1 |
      set %impassable #false
      for %i 1 4
      {
        for %o 0 4
        {
          if %cursKind . #charid = 4 || %cursKind . #charid = 3 || %cursKind . #charid = 2 || %cursKind . #charid = 1 || %cursKind . #charid = 0
          {
            set %impassable #false
            tile get %x %y 1 #curskind
            tile cnt %x %y #curskind
            set %tileZ #tilez
            set %tileType #tileType
            if impassable in #tileFlags || wall in #tileFlags || tree in #tilename 2
              set %impassable #true
              goto _skipTileCheckYo
            if #tileCnt > 1 && %impassable = #false 7
              for %tileIndex 2 #tileCnt
              {
                tile get %x %y %tileIndex #curskind
                if impassable in #tileFlags || wall in #tileFlags 2
                  set %impassable #true
                  break
              }
          }
          if %impassable = #false && | , %x , _ , %y , | notin %area && ( %x <= #charposx + 10 && %x >= #charposx - 10 && %y <= #charposy + 10 && %y >= #charposy - 10 ) && ( #tilez <= #charposz + 20 && #tilez >= #charposz - 20 ) 7
            set %check %check + 1
            set %checkX . %check %x
            set %checkY . %check %y
            if #cursKind >= 0 && #cursKind < 5 2
              set %checkZ . %check %tileZ
            set %checkT . %check %tileType
            set %checkingShit %checkingShit , %x , _ , %y , |
          else
            set %checkingShit1 %checkingShit1 , %x , _ , %y , |
_skipTileCheckYo:
          set %x %x + 1
        }
        set %y %y + 1
        set %x %x - 4
      }
    }
  }
  set %random #random % %check + 1
  set #ltargetx %checkX . %random
  set #ltargety %checkY . %random
  if #cursKind >= 0 && #cursKind < 5 2
    set #ltargetz %checkZ . %random
    set #ltargettile %checkT . %random
  if #cursKind > 4
    set #ltargetz #charposz
  if %belfry = #true
    gosub belfryTargetSet
  set #ltargetkind 2
  event macro 22
  set %wait . #charid #sysTime + %spellWait
  set #ltargetkind 1
  set %casting . #charid #false
  set %alreadyTargetted #true

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • 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: Any ideas how to shorten this up LOL
« Reply #5 on: October 14, 2017, 09:05:04 AM »
0
Can you shorten this up while you're at it?  Thanks. hehe

You're on your own me-bucko!
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: Any ideas how to shorten this up LOL
« Reply #6 on: October 14, 2017, 09:38:37 AM »
0
Twinkle McNugget giving out code for the belfry?

Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline BobOzarius

  • Full Member
  • ***
  • Posts: 103
  • Activity:
    0%
  • Reputation Power: 2
  • BobOzarius has no influence.
  • Respect: +26
  • Referrals: 0
    • View Profile
Re: Any ideas how to shorten this up LOL
« Reply #7 on: October 14, 2017, 09:48:45 AM »
0
That's a tiny portion of a script of his to do that. That portion there does a lot more than Belfry I think. The portion for the Belfry was an after thought according to him. I just asked. He is in vent. Want me to tell him you said hello?

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: Any ideas how to shorten this up LOL
« Reply #8 on: October 14, 2017, 02:21:36 PM »
0
Nah, that's okay.

*Returns to the shadows*
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Tags: