Page 1 of 1

Scripting on Webclient

Posted: 28 Nov 2016 06:26
by Orien
I was wrote some scripts on webclient earlier and when I relog, some or all the scripts (or triggers and aliases contain the scripts) didn't saved and reverted back to it's original state - back to old scripts or newly created triggers and aliases are no longer exist although I pressed SAVE button and even <save> in game.

Can someone help me explain how the save mechanic in webclient works? Do I need to wait sometime or do something in order to make new scripts save on database of server?

P.s: A button inside script editor to remove all scripts inside a trigger or alias would be nice since I cannot mass delete scripts on mobile device and webclient system don't have re-order triggers and aliases function... yet!

Thank you!

Re: Scripting on Webclient

Posted: 28 Nov 2016 12:13
by Orien
Found the issue. You need to go Linkdeath then relog again, if you not Linkdeath then login with new tab and push the other tab out the issue will arise.

Also I'm working on some codes and need some help with syntax:

Code: Select all

switch ((true) || (args[2])) {
  case 'Maivia':
      Loot_Maivia;break;
  case (args[2].indexOf('dark elf') > -1):
      Loot_Darkelf;break;
  default:Loot_General;
If (dark elf case:) I need to use (true) condition for the code to work and in (Maivia case:) I need to use (args[2]) for the code to work hench why my switch have 2 conditions but the problem is it only works in either cases, decided by first condition, not both at the same time. Example: I put (true) before (args[2]) so only (dark elf case:) works and (Maivia case:) will be false and return default value and vice versa... Any solutions for this?

Thank you!

Re: Scripting on Webclient

Posted: 04 Dec 2016 16:45
by Zhar
Orien wrote:Found the issue. You need to go Linkdeath then relog again, if you not Linkdeath then login with new tab and push the other tab out the issue will arise.

Also I'm working on some codes and need some help with syntax:

Code: Select all

switch ((true) || (args[2])) {
  case 'Maivia':
      Loot_Maivia;break;
  case (args[2].indexOf('dark elf') > -1):
      Loot_Darkelf;break;
  default:Loot_General;
If (dark elf case:) I need to use (true) condition for the code to work and in (Maivia case:) I need to use (args[2]) for the code to work hench why my switch have 2 conditions but the problem is it only works in either cases, decided by first condition, not both at the same time. Example: I put (true) before (args[2]) so only (dark elf case:) works and (Maivia case:) will be false and return default value and vice versa... Any solutions for this?

Thank you!
You need to change it into an if-else tree. Switch statements don't work like that (case can't be a condition, it has to be a specific value). Also, the switch argument has to be a value, not a condition. Default part of switch will fire if no match is found for any of the cases.

Code: Select all

switch(args[2]) {
    case 'Maivia':
        Loot_Maivia;
        break;
    default:
        if (args[2].indexOf('dark elf') > -1) {
            Loot_Darkelf;
        } else {
            Loot_General;
        }
        break;
}
Edit: Also, true || something will always evaluate to true.

Re: Scripting on Webclient

Posted: 04 Dec 2016 18:03
by Orien
My current script:

Code: Select all

switch (args[2]) {
  case ’name’:case 'description':loot;break;
  default:variable = true;}

if (variable) {
  switch (true) {
    case (args[2].indexOf('description') > -1):loot;variable = false;break;
    default:loot;}}
Did not thinking of using else-if in default!
Thank you for your answer Zhar!

Re: Scripting on Webclient

Posted: 04 Dec 2016 21:49
by Zhar
Please break your code into more lines.

Why would you make a switch for true/false? This is not what switch is used for... And it's very non-optimal performance-wise.
And why the hell would you even use a switch if every single case yields the same result? (unless the actual code you posted is not the actual code...)

This does exactly the same thing that your code does:

Code: Select all

switch (args[2]) {
  case ’name’:
  case 'description':
    loot;
    break;
  default:
    variable = !(args[2].indexOf('description') > -1);
    loot;
    break;
}

Re: Scripting on Webclient

Posted: 05 Dec 2016 07:12
by Orien
Hi Zhar!

It is just an example of my code not the actual one, thanks for your lesson now I know how suck my code is! Already switched back to your version after your first post.