Scripts / Problem with start, text and write script then game crash.

Author
Message
Mortt
8
Years of Service
User Offline
Joined: 16th May 2016
Location:
Posted: 10th Jul 2016 13:09
I have a problem with game crashing when I play this out.
The start script is just the set up at start marker, nothing but init and main
Next script is in a big rock. This is the script for text on screen for Rank, Level Score and Total Score
Then when level is complete, player walks over a trigger zone and the players Rank is then written to a file.

Problem. When player does walk over trigger zone, file is written but then game freezes and crashes and reloads previous saved.

Running the write script with the text script not placed then the game does not crash.
So I guess that the textscore script must be causing the crash some how.
Completely stuck on this.

Hope the scripts show OK. Never used the thingy before.

The Start Script


KillCountLVL = 0
KillCountTotal = 0
Rank = "SecondLieutenant"


function kcstart_init(e)

end

function kcstart_main(e)


end




The text Score script



function paneltext_init(e)

end

function paneltext_main(e)
TextCenterOnXColor(90,86,4,KillCountTotal, ("KillCountTotal"),240,157,40 ) -- The colour for text is not rgb but green, red, blue grb.
TextCenterOnXColor(95,86,4,KillCountLVL,("KillCountLVL"),40,240,157) -- This shows Dark BLUE.
TextCenterOnXColor(92,80,4,Rank, ("Rank"),240,40,157) -- This shows GREEN.
-- Panel(86,83,94,90)
TextCenterOnXColor(90,85,3, "Total Score", 240,157,40) -- This colour is rgb
TextCenterOnXColor(96,85,3, "Level Score", 40,240,157) -- This is rgb.
TextCenterOnXColor(89,79,3, "Rank", 240,40,157) -- This shows RED
end




The write to file script


function writetodisk_init(e)

end

function writetodisk_main(e)
-- PlayerDist = GetPlayerDistance(e) -- Try this on a Barrel
-- if PlayerDist < 180 then -- Try this on a Barrel
if g_Entity[e]['plrinzone']==1 then -- Do not use on a Barrel
Prompt ( "You are in Zone." ) -- This Prompt does not show.
file = io.open("C:\\Users\\Public\\mortt\\Games\\TKEW\\EP1\\rank.txt", "w")
Rank = file:write("It does write, but game then freezes and then crashes and reloads to previous saved." .. "\n")
file:close()
else
-- ActivateIfUsed(e)
-- Destroy(e)


end
end


(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
Pirate Myke
Forum Support
14
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 10th Jul 2016 15:13
May I direct your attention to this thread with some examples of working save and load functions.

https://forum.game-guru.com/thread/213084
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit, Screen resolution 1680 x 1050.

Mortt
8
Years of Service
User Offline
Joined: 16th May 2016
Location:
Posted: 10th Jul 2016 16:35
Hello.
I have a working save load system to save game scores, totals etc etc,. But for some strange reason this script set up does not work when the paneltext script is working.
Taking the paneltext script out of the game then it works well. But then the info is not on screen but still works in back ground. So problem seems to be with the CenterOnXColor.
(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
Pirate Myke
Forum Support
14
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 10th Jul 2016 18:19
ok, Can you email me the scripts and the map file. I will take a look at it.
email address in the button below.

Thanks
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit, Screen resolution 1680 x 1050.

smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 10th Jul 2016 18:43
it seems like file:write() doesnt return a value so you can't have
Rank = file:write()
just use
file:write("It does write, but game then freezes and then crashes and reloads to previous saved." .. "\n")
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
PartTimeCoder
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location:
Posted: 10th Jul 2016 19:05
Quote: "Taking the paneltext script out of the game then it works well."


Quote: "TextCenterOnXColor(90,86,4,KillCountTotal, ("KillCountTotal"),240,157,40 ) -- The colour for text is not rgb but green, red, blue grb.
TextCenterOnXColor(95,86,4,KillCountLVL,("KillCountLVL"),40,240,157) -- This shows Dark BLUE.
TextCenterOnXColor(92,80,4,Rank, ("Rank"),240,40,157) -- This shows GREEN."


you can not have function string parameters in brackets like that arguments in brackets are expected to be number of mathematical equations, I'm pretty sure thats whats making GG crash!
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 10th Jul 2016 20:29 Edited at: 10th Jul 2016 20:31
i thought that at first but actually that script works fine, must be another way to do the ..

the reason it seemed to work once he removed the text prompt script i guess is because that's the script actually using Rank and as his save is setting Rank = file:write() it was causing issues.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
PartTimeCoder
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location:
Posted: 11th Jul 2016 00:01
yeah I see it now, overwriting the global with a nil
PM
Mortt
8
Years of Service
User Offline
Joined: 16th May 2016
Location:
Posted: 11th Jul 2016 19:31
I did forget to paste the "ranking.lua" script. That might have helped if I had.
It was that script that was causing the problems.
After many hours of brain scratching, I thought copy it from my score and levels save script and try that.
That didnt work either.

But then came up with this below.
New var for writing the rank code to file
Put in the start script
it then decodes the rank code "number" as aposed to "text"
and it all works wonderful.

This little bit of scripting then set my imagination wild.
Could have a whole screen of data.


Script Code

function ranking_main(e)
if g_Entity[e]['plrinzone']==1 then
Prompt ( "You have been promoted." )
if KillCountLVL > 580 then
if Rank == "Second Lieutenant" then
RankWrt = 2
local file = io.open("C:\\Users\\Public\\mortt\\Games\\TKEW\\EP1\\rank.txt", "w")
file:write(RankWrt .. "\n")
file:close()


Now have level 3 of game almost ready to post as a demo.
(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
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 11th Jul 2016 21:20
I'm not sure about io.open using "\\" in the file path.


3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM

Login to post a reply

Server time is: 2024-12-22 18:42:59
Your offset time is: 2024-12-22 18:42:59