Scripting on Webclient

General discussion about the Genesis Web Client located at https://www.genesismud.org/play/

Moderator: Eowul

Forum rules
- Use common sense and be respectful towards each other at all times, even when disagreeing.
- Do not reveal sensitive game information. Guild secrets, player seconds are examples of things not allowed.
Post Reply
Orien
Apprentice
Posts: 42
Joined: 10 Jun 2016 17:08

Scripting on Webclient

Post by Orien » 28 Nov 2016 06:26

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!
Image

Orien are cute (Cool too) kender, if ya disagree with Orien, Orien agree with ya, Orien loves all ^bounce^

Orien
Apprentice
Posts: 42
Joined: 10 Jun 2016 17:08

Re: Scripting on Webclient

Post by Orien » 28 Nov 2016 12:13

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!
Image

Orien are cute (Cool too) kender, if ya disagree with Orien, Orien agree with ya, Orien loves all ^bounce^

User avatar
Zhar
Wizard
Posts: 1079
Joined: 17 Apr 2012 12:09

Re: Scripting on Webclient

Post by Zhar » 04 Dec 2016 16:45

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.
Time is precious. Waste it wisely.

Orien
Apprentice
Posts: 42
Joined: 10 Jun 2016 17:08

Re: Scripting on Webclient

Post by Orien » 04 Dec 2016 18:03

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!
Image

Orien are cute (Cool too) kender, if ya disagree with Orien, Orien agree with ya, Orien loves all ^bounce^

User avatar
Zhar
Wizard
Posts: 1079
Joined: 17 Apr 2012 12:09

Re: Scripting on Webclient

Post by Zhar » 04 Dec 2016 21:49

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;
}
Time is precious. Waste it wisely.

Orien
Apprentice
Posts: 42
Joined: 10 Jun 2016 17:08

Re: Scripting on Webclient

Post by Orien » 05 Dec 2016 07:12

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.
Image

Orien are cute (Cool too) kender, if ya disagree with Orien, Orien agree with ya, Orien loves all ^bounce^

Post Reply
http://tworzymyatmosfere.pl/przescieradla-jedwabne-z-gumka/