ScriptUO

Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: manwinc on August 14, 2009, 09:09:37 PM

Title: I don't understand.
Post by: manwinc on August 14, 2009, 09:09:37 PM
I see alot of These kind of IF statements in Peoples Scripts


if %SOMETHING
{



}


I don't understand..... TO me its like a joke without a punchline... I don't understand what its function is or where you would actually use it? Without a mathematical comparison.... an IF just seems like a Wire Coat Hanger Unwinder... (Who would Actually use it?)
Title: Re: I don't understand.
Post by: rana70 on August 14, 2009, 09:18:09 PM
Hi,

it is just a possible way to to do something if a var is  #true.
Maybe this will explain it:
Code: [Select]
Set %Something #True

if %Something
{
Display OK Something is true
}

Set %Something #false

if %Something
{
Display OK This will never be displayed
}

halt
Title: Re: I don't understand.
Post by: manwinc on August 14, 2009, 09:25:57 PM
So, its shorthand for

If %Something = #true


Wow, that is worthless to me......
Title: Re: I don't understand.
Post by: 12TimesOver on August 15, 2009, 05:04:53 AM
So, its shorthand for

If %Something = #true


Wow, that is worthless to me......

Manwinc, detail? Being one who appreciates your coding abilities I'd be curious what you're getting at. I'm reading this thread like you feel about IF statements as Cerv feels about Goto statements. Do you not use If? Do you not like If without Else? I'm confused. I use statements such as this a lot - get a value, load a variable with the value, If the variable = value perform action, otherwise don't perform the action. Is this not good code?

How else would you approach this type of logic?

XII
Title: Re: I don't understand.
Post by: manwinc on August 15, 2009, 09:57:50 AM
oh no, Programming without If Statements would be Impossible in My Opinion.

I just think that

if %something
{
Do this
Do that
}

Seems Silly. It should have an = . I know now that when you perform an if Statement without an = It checks to see if its Equal To #True (or -1), but that just seems like something Silly to add to the program itself (easyuo).

Now, I have never taken a programming class, or learned any code other than easyuo( think its called Delphi) , so i'm sure that there are other Programming Languages and environments that use it, but I Wouldn't of Guessed that that's what it does in a Million years.

Heh Heh, and I'm all For Goto's......  ;D Trying to Break Away, But like I just said all my programming experience has been with easyuo so I didn't find out about the "hate" for goto's until about 6 months ago. No More Spaghetti Code For me!
Title: Re: I don't understand.
Post by: 12TimesOver on August 15, 2009, 05:01:48 PM
Gotcha.

Yes, there are plenty of other languages that use the "IF Something" and "If Not Something" syntax so I guess it never really bugged me. ;)

XII
Title: Re: I don't understand.
Post by: Endless Night on August 15, 2009, 07:13:16 PM
To correct something thier ... Easyuo script is not Called Delphi.  The Easyuo program itself was written in a programming language Called Delphi .. which in turn is a version of Pascal.  EasyUo Script is just that EasyUo script.

All conditional statments of any kind break down to  #TRUE or #FALSE .. if an = , <> , ! or other operative exists in the condition then the condition must be evaluated first is all.

Repeat Until <Condition>
If <Condition>
While <condition> Do

In other languges thiers more case <Condition>
Title: Re: I don't understand.
Post by: manwinc on August 15, 2009, 08:27:17 PM
Like I said 0 % Programming Experience.
Title: Re: I don't understand.
Post by: Scrripty on August 15, 2009, 09:35:53 PM
Like I said 0 % Programming Experience.

You don't like this? :)

Code: [Select]
  sub ls
    menu get 13 ;Lightning Strike;Primary:Secondary
    if #menures = #true
    {
      menu get 14 ; WS Mana Check
      if #menures = #true
      {
        menu get specials
        if #menures = 1
        {
          if #mana > ( #maxmana * !LSManaPercentage ) / 10
            gosub lsSpecial
          return
        }
        menu get specials
        if #menures = 2
        {
          if #mana > ( #maxmana * !LSManaPercentage ) / 10 && #mana >= !PrimaryMana
            gosub execPrimary
          return
        }
        menu get specials
        if #menures = 3
        {
          if #mana > ( #maxmana * !LSManaPercentage ) / 10 && #mana >= !SecondaryMana
            gosub execSecondary
          return
        }
      }
      menu get specials
      if #menures = 1
      {
        gosub lsSpecial
        return
      }
     
      if #mana >= !PrimaryMana
      {
        menu get specials
        if #menures = 2
        {
          gosub execPrimary
          return
        }
      }
     
      if #mana >= !SecondaryMana
      {
        menu get specials
        if #menures = 3
        {
          gosub execSecondary
          return
        }
      }
    }
  return
Title: Re: I don't understand.
Post by: rana70 on August 15, 2009, 10:46:57 PM
He guys,

I think this point is done ...
 
The only problem he asked for help was using if's without any < , > , or =.

There is  one case when you test something for #TRUE, so that's it.

He prefers to write it out in full ... so it is OK for me !

I know people who dislike
-if you don't use brakets for Reperat Until's :-)
-some others dislike goto's

As long as it works .. it is ok for me :-)

A good day for all of you !
cu
Title: Re: I don't understand.
Post by: TrailMyx on August 15, 2009, 11:25:43 PM
I agree with Rana; if it works and you understand WHY it works, then why not?  The trick is just making sure you understand the WHY.

There's been a few times I've looked back at my earlier scripts and thought, "now why in the heck did I do it like that?"  But hey, it works so I just don't feel like re-doing it correctly. 
Title: Re: I don't understand.
Post by: manwinc on August 16, 2009, 05:29:18 AM
Yeah, thats all I was really looking for was people use if statements without = < > in them and what it actually does.

Quote
here's been a few times I've looked back at my earlier scripts and thought, "now why in the heck did I do it like that?"  But hey, it works so I just don't feel like re-doing it correctly.

I completely Agree TM, that's the point I'm at with my miner. In my opinion my script is a load of crap that needs to be De-gutted and reworked completely, but that's 1700 Lines of code to go back through and modify to make it more..... "Logical and up to date" with my scripting method now. Way too much hassle for something I don't Even Use.
Title: Re: I don't understand.
Post by: Endless Night on August 16, 2009, 06:30:24 AM
I hear you thier... I look at some of my old scripts .. and embarrassment is not the words... and ill probably feel the same about my current scripts in 4 years from now presuming UO and EUO is still alive then.