Author Topic:  Variables Issue  (Read 1171 times)

0 Members and 1 Guest are viewing this topic.

LB

  • Member
  • ***
  • Posts: 204
  • Creator of Creditland, Infinity and Elzrin
  • Awards Members who have unlocked the robotic avatar 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: Liam Bradbury
Variables Issue
« on: February 13, 2017, 07:53:13 PM »
So I've worked with variables on my worlds quite a lot recently and I've come across a large issue when it comes to saving variables to history. Let me explain.

So in my world, you mine, sell blocks which converts into a virtual currency using history. You input a select amount of blocks and it will multiply the amount that you sell. For example:

Input [Amount]
var [Sell] = [Amount] * [45]

This all works correctly but when the player leaves and joins back, there's a 90% chance that it will have vanished. It's was so much of an issue that I had to go back to the good ol' looping scripts to sell blocks which fixed the issue.

Am I missing something crucial or are vars glitchy?


crazytater94

  • Supreme Member
  • *****
  • Posts: 2588
  • Mastering TM since 2011
  • Awards Awarded to exemplary forum members Members who have unlocked the robotic avatar 3 years on site+600 posts 2 years on site+300 posts Was in the top 10 of the forum stats page as of 4/12/15 Former MotM winners Week 1 members w/25+ posts (4/13/13-4/20/13) 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: crazytater94
  • PSN: crazytater94 (Inactive)
  • Steam: crazytater94
Re: Variables Issue
« Reply #1 on: February 14, 2017, 12:05:23 AM »
By 'it' do you mean the gold they got? Or the currency history?

Craig

  • Developer
  • Extreme Member
  • ******
  • Posts: 6540
  • Dig Deep
  • Awards Developer 4 years on site+1000 posts 3 years on site+600 posts 2 years on site+300 posts Was in the top 10 of the forum stats page as of 4/12/15 Members who have unlocked the robotic avatar 1 year on site+100 posts Day 1 w/25+ posts (4/12/13)
    • View Profile
    • Twitter
    • Awards
  • Steam: tota1miner
Re: Variables Issue
« Reply #2 on: February 14, 2017, 02:07:07 AM »
Can you show us the history command, or better, the entire script?

LB

  • Member
  • ***
  • Posts: 204
  • Creator of Creditland, Infinity and Elzrin
  • Awards Members who have unlocked the robotic avatar 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: Liam Bradbury
Re: Variables Issue
« Reply #3 on: February 14, 2017, 07:34:47 AM »
By 'it' do you mean the gold they got? Or the currency history?

'It' meaning that the history that they've earned through multiplying vars usually resets when they join back.

LB

  • Member
  • ***
  • Posts: 204
  • Creator of Creditland, Infinity and Elzrin
  • Awards Members who have unlocked the robotic avatar 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: Liam Bradbury
Re: Variables Issue
« Reply #4 on: February 14, 2017, 08:02:00 AM »
Can you show us the history command, or better, the entire script?

It's a long script:

Input [Amount]

var [Sell] = [25] * [Amount]

If
   IsVar [Amount] [=>] [1]
   IsVar [Amount] [=<] [500]
   HasInventory [player] [Dacite] [=>] [Amount]
Then
   History [Mines\Dacite] [player] [+Amount]   //This is a track record of how many of these blocks the player has sold.
   History [Bolts] [player] [+Sell]   //This is the currency that I use in the world.
   Inventory [player] [Dacite] [Amount]
   Notify [[Sell[ Bolts received.] [local] [0,0,0]


The rest of the script is unnecessary as it doesn't involve vars.

So when the player sells any block, it goes through this script and gives the player the amount of Bolts they should be given. It all works until they rejoin.

Curmescius

  • Supreme Member
  • *****
  • Posts: 4265
  • What's yours is mine. ~TM's Resident Master Thief~
  • Awards Members who have unlocked the robotic avatar Awarded to exemplary forum members 2 years on site+300 posts 3 years on site+600 posts Site art contributions/TPs in-game/Contest winners 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: dryym
Re: Variables Issue
« Reply #5 on: February 14, 2017, 08:18:08 AM »
Can you show us the history command, or better, the entire script?

It's a long script:

Input [Amount]

var [Sell] = [25] * [Amount]

If
   IsVar [Amount] [=>] [1]
   IsVar [Amount] [=<] [500]
   HasInventory [player] [Dacite] [=>] [Amount]
Then
   History [Mines\Dacite] [player] [+Amount]   //This is a track record of how many of these blocks the player has sold.
   History [Bolts] [player] [+Sell]   //This is the currency that I use in the world.
   Inventory [player] [Dacite] [Amount]
   Notify [[Sell[ Bolts received.] [local] [0,0,0]


The rest of the script is unnecessary as it doesn't involve vars.

So when the player sells any block, it goes through this script and gives the player the amount of Bolts they should be given. It all works until they rejoin.

This is probably just a mistake, But the notify has two opening brackets surrounding the variable name.

Also, I would add the line var [Amount] = [int:Amount] immediately after the input. If someone was smart and patient, They could sell 1.9999999 of a block to get double price while only selling one block.

Creator of the term "Deathmine "
Jared [19|Oct 07:12 PM]: "It changes everything" Dryym

Craig

  • Developer
  • Extreme Member
  • ******
  • Posts: 6540
  • Dig Deep
  • Awards Developer 4 years on site+1000 posts 3 years on site+600 posts 2 years on site+300 posts Was in the top 10 of the forum stats page as of 4/12/15 Members who have unlocked the robotic avatar 1 year on site+100 posts Day 1 w/25+ posts (4/12/13)
    • View Profile
    • Twitter
    • Awards
  • Steam: tota1miner
Re: Variables Issue
« Reply #6 on: February 14, 2017, 05:44:06 PM »
I'm 100% sure vars at not at fault here, you're just using them as a calculator and they have no bearing on the persistent storage of history.

The fault may be in your player joins script. Can you post that?

LB

  • Member
  • ***
  • Posts: 204
  • Creator of Creditland, Infinity and Elzrin
  • Awards Members who have unlocked the robotic avatar 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: Liam Bradbury
Re: Variables Issue
« Reply #7 on: February 14, 2017, 05:55:54 PM »
I'm 100% sure vars at not at fault here, you're just using them as a calculator and they have no bearing on the persistent storage of history.

The fault may be in your player joins script. Can you post that?

I don't know what you mean by "no bearing on the persistent storage of history."

The Join script is nothing more than resetting histories and a teleport to the spawn, but I can still post it soon if you really need it. I cannot post it right now since I'm not on my world.

Craig

  • Developer
  • Extreme Member
  • ******
  • Posts: 6540
  • Dig Deep
  • Awards Developer 4 years on site+1000 posts 3 years on site+600 posts 2 years on site+300 posts Was in the top 10 of the forum stats page as of 4/12/15 Members who have unlocked the robotic avatar 1 year on site+100 posts Day 1 w/25+ posts (4/12/13)
    • View Profile
    • Twitter
    • Awards
  • Steam: tota1miner
Re: Variables Issue
« Reply #8 on: February 14, 2017, 05:59:22 PM »
The Join script is nothing more than resetting histories
That's what I suspected and am wondering if the problem lies there.

I don't know what you mean by "no bearing on the persistent storage of history."
I mean the problem you're describing appears to be a problem with history values being reset or lost. That's to do with history, not vars.

LB

  • Member
  • ***
  • Posts: 204
  • Creator of Creditland, Infinity and Elzrin
  • Awards Members who have unlocked the robotic avatar 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: Liam Bradbury
Re: Variables Issue
« Reply #9 on: February 14, 2017, 06:06:18 PM »

But I've never had this problem since I've changed the selling system back to the looping method, that doesn't use the Input calculator or vars. The problem was really bad when I used the calculator and vars only.

Craig

  • Developer
  • Extreme Member
  • ******
  • Posts: 6540
  • Dig Deep
  • Awards Developer 4 years on site+1000 posts 3 years on site+600 posts 2 years on site+300 posts Was in the top 10 of the forum stats page as of 4/12/15 Members who have unlocked the robotic avatar 1 year on site+100 posts Day 1 w/25+ posts (4/12/13)
    • View Profile
    • Twitter
    • Awards
  • Steam: tota1miner
Re: Variables Issue
« Reply #10 on: February 14, 2017, 06:17:09 PM »
Did you change the PlayerJoins script when changing from the vars to looping method? Or does it remain unchanged regardless of which method you use?

If you change this notify:
 Notify [[Sell] Bolts received.] [local] [0,0,0]
to:
Notify [[Sell] Bolts received. You now have [history:bolts] Bolts.] [local] [0,0,0]

Does the 'you now have x bolts' part of the notification always show the correct quantity?
If it does, then the history has the correct quantity and the problem is with the history, not vars.

LB

  • Member
  • ***
  • Posts: 204
  • Creator of Creditland, Infinity and Elzrin
  • Awards Members who have unlocked the robotic avatar 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: Liam Bradbury
Re: Variables Issue
« Reply #11 on: February 14, 2017, 06:21:23 PM »
The Join script hasn't changed since I first made the world.


If you change this notify:
 Notify [[Sell] Bolts received.] [local] [0,0,0]
to:
Notify [[Sell] Bolts received. You now have [history:bolts] Bolts.] [local] [0,0,0]

Does the 'you now have x bolts' part of the notification always show the correct quantity?
If it does, then the history has the correct quantity and the problem is with the history, not vars.

I will try this method out when I get on my world next.

Curmescius

  • Supreme Member
  • *****
  • Posts: 4265
  • What's yours is mine. ~TM's Resident Master Thief~
  • Awards Members who have unlocked the robotic avatar Awarded to exemplary forum members 2 years on site+300 posts 3 years on site+600 posts Site art contributions/TPs in-game/Contest winners 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: dryym
Re: Variables Issue
« Reply #12 on: February 14, 2017, 06:24:42 PM »
Is it possible that the problem lies in networking the history change to the host?

Perhaps he isn't always receiving the history change due to a networking problem.

Since he changed it to a looping sell script, It means there are more history changes that are being sent out. Since there are more pings being sent out, If a few of them don't make it through, It won't make as much of an impact as if the entire history change didn't make it through.

Creator of the term "Deathmine "
Jared [19|Oct 07:12 PM]: "It changes everything" Dryym

LB

  • Member
  • ***
  • Posts: 204
  • Creator of Creditland, Infinity and Elzrin
  • Awards Members who have unlocked the robotic avatar 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: Liam Bradbury
Re: Variables Issue
« Reply #13 on: February 14, 2017, 06:27:30 PM »
Is it possible that the problem lies in networking the history change to the host?

Good thing you mentioned that. I've noticed this problem as I have the HUD set up to show the Bolts count and sometimes when they sell, it doesn't update.

Craig

  • Developer
  • Extreme Member
  • ******
  • Posts: 6540
  • Dig Deep
  • Awards Developer 4 years on site+1000 posts 3 years on site+600 posts 2 years on site+300 posts Was in the top 10 of the forum stats page as of 4/12/15 Members who have unlocked the robotic avatar 1 year on site+100 posts Day 1 w/25+ posts (4/12/13)
    • View Profile
    • Twitter
    • Awards
  • Steam: tota1miner
Re: Variables Issue
« Reply #14 on: February 14, 2017, 06:34:47 PM »
Is it possible that the problem lies in networking the history change to the host?

Perhaps he isn't always receiving the history change due to a networking problem.

Since he changed it to a looping sell script, It means there are more history changes that are being sent out. Since there are more pings being sent out, If a few of them don't make it through, It won't make as much of an impact as if the entire history change didn't make it through.

Yes if there is no problem with the scripts themselves (i.e. history being reset accidently with bad logic), then the problem lies with networking. The best way to confirm that is showing the history values on the screen on both the remotes and host and seeing if they differ.