Scripts / Market script problems

Author
Message
Mortt
7
Years of Service
User Offline
Joined: 16th May 2016
Location:
Posted: 3rd Apr 2017 20:18
I am trying out marketing in game guru.
In the game the player buys and sells items. These items are valued according to supply and demand.
In this test I have 77 items and each item is for sale in 77 markets. ( This is just the numbers I set for the testing)

So for each item there are 77 market prices which reflect the demmand price.

The script that I am useing is set out below.
I could do this with tables but I am tryin gout this way to see if it can be done.



Another script handles the count for each section.
Just a simple centreon X type thing.

The problem is that the first sections counts to 7
the second section counts to 508
and the third section counts to 508.

It should count to 5929 in the third section. 77x77= 5929

Why does the first section stop counting at 7?
Why does second and third stop counting at 508?

I can't fathom this one out. Perhaps it can't be done, but then it partly works and it works if the first number is a single number and not a for loop.

Any ideas would be great.
(Custom) Intel i7 3.3 Mhz. 16 GB fast ram. EVGA Nvidia 560 Ti 4GB. Dell US27 2560 x 1440. AOC 24 1920 x 1080. Awesome.
Next G. Card EVGA GeForce GTX 970 Superclocked ACX 2.0 Gaming 4GB GDDR5 PCIe3.0 Graphics Card.
Would Like EVGA NVIDIA GeForce GTX 1080 8GB GDDR5X PCIe3.0 Graphics Card
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 3rd Apr 2017 22:18 Edited at: 3rd Apr 2017 22:19
for firstno = 1, 77, 1 do
      accumprod = accumprod + 1
      firstno = file:read("*n", "*l")
^^^^^^

That's not gonna work in any language!

It's difficult to work out what you are trying to do without knowing what is actually in the files you are attempting to read but it is usually best to read in any files once in the init function and store the contents in a list, then simply read the list in the main function.
Been there, done that, got all the T-Shirts!
PM
Mortt
7
Years of Service
User Offline
Joined: 16th May 2016
Location:
Posted: 4th Apr 2017 19:05
The files are numbers, prices for the items for sale and the second list is the market calculation based on the demand and supply ratios.
This then increses the price of the items or decreaes the price of the items on the markets.

As the game will have NPC actions on the numbers, doing this through a disk file is going to save massive ram and cpu usage, where as, if this was all held in a file in ram it will be active all the time and not just when the player uses the markets.

My intention is to have a massive market covering a huge game area. With hundreds of NPC players. But trying to save on ram and cpu usage is the biggest problem. So using disk files this will reduce this by several hundred MB, which if it was active all the time then cpu and ram usage would pose a fundamental problem to users of lower end machines.

And as stated, it does work to a point. Well to the first 7 X 77 calculations anyway.

I was thinking of using tables, where they are updated with the new game data, but then this would be always running to update them in real time.
where in the disk file the data is only updated when the player goes to market.

the line : accumprod = accumprod + 1
these are to see if this part of the count is working.

IT might not be able to push Game Guru and LUA to the max, but it is fun trying.
(Custom) Intel i7 3.3 Mhz. 16 GB fast ram. EVGA Nvidia 560 Ti 4GB. Dell US27 2560 x 1440. AOC 24 1920 x 1080. Awesome.
Next G. Card EVGA GeForce GTX 970 Superclocked ACX 2.0 Gaming 4GB GDDR5 PCIe3.0 Graphics Card.
Would Like EVGA NVIDIA GeForce GTX 1080 8GB GDDR5X PCIe3.0 Graphics Card
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 4th Apr 2017 20:11 Edited at: 4th Apr 2017 20:13
i think he means you can't alter the variable used for the 'for' loop while it inside the loop like that, i've never actually tried it so no idea if you can or not but i would assume not, seems a bit weird.

in your script you are opening 3 files but only closing 1, unless using the same variable (file) and closing it later will close all 3 at once? not sure.

also accumdmnd and accummrktv are being updated at the same time so they will read the same values but i would guess it's simply opening the file too many times and that is just when it runs out of memory, put in a toggle to check the file is open and it might fix it

lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Mortt
7
Years of Service
User Offline
Joined: 16th May 2016
Location:
Posted: 8th Apr 2017 15:05
Hi all
Thank you so much AmenMoses and smallg for the help.

Didn't quite understand what AmenMoses meant untill smallg explained.

Script works perfectly now.
My pick axes and other items are now updating with demand and supply. Awesome stuff. Thank you so much guys.

Now to get the NPC players sorted out.
Cool.
(Custom) Intel i7 3.3 Mhz. 16 GB fast ram. EVGA Nvidia 560 Ti 4GB. Dell US27 2560 x 1440. AOC 24 1920 x 1080. Awesome.
Next G. Card EVGA GeForce GTX 970 Superclocked ACX 2.0 Gaming 4GB GDDR5 PCIe3.0 Graphics Card.
Would Like EVGA NVIDIA GeForce GTX 1080 8GB GDDR5X PCIe3.0 Graphics Card
PM

Login to post a reply

Server time is: 2024-04-24 19:39:54
Your offset time is: 2024-04-24 19:39:54