Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 3 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Language Reference and Guide
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#13
RE: Script Language Reference and Guide

I tried out your tests, I think I understand from your explanation why this is happening. I changed the test around so it was using my functions to do the same thing, and sure enough, the problem you highlighted was indeed happening - so I went back to the maps I was using to test when I was writing it initially, and sure enough, the problem was there. I don't know why I didn't see it before, cause it only took a few tries before it broke in exactly the way you stated.

So I started changing various things, including updating the functions I was using to make sure they were the latest versions, but starting with replacing the way I was using the function to the way you suggested,
PHP Code: (Select All)
stringpstrArrayInput GetGlobalVarString("glostrName");
        
int inNextPos GetSetNextSpawnRandom(pstrArrayInput); 
Now, I should point out that this implementation is more complicated than the previous tests - it involves the player transporting across 2 maps, each with their own string in global.hps for positions, and the function calls are within other functions, generally timer loops, it can't just be in OnStart. After I tried the above, it all seemed to work, I tested it probably about 20/30 times, and it never failed (wheras the previous method would fail 3/4 times).

So I started writing this reply, then thought about another feature of this mechanic (getting the last position used) that I needed to test out as well, to make sure it didn't get broken - when I loaded it up again, it started failing exactly as it had before.... I checked the script files, the map, everything was exactly how I'd left it, and yet it was breaking again and very often. I'm not sure if the 'working' tests I did before were simply successful due to 'chance', it seems very unlikely given how often it was breaking beforehand. But regardless, it was still sometimes failing to print the string, I went over the scripts for both maps, made the same changes I had before using your method, still wouldn't work

I decided at that point I clearly don't know enough about how strings work in HPL2 & AS to be able to do this effectively, and was all ready to rewrite all the functions to use an altogether different method, but then I though of this far simpler - if less elegant - solution
PHP Code: (Select All)
string strArrayInput GetGlobalVarString("glostrName");
        
int inNextPos GetSetNextSpawnRandom(strArrayInput); 
        
SetGlobalVarString("glostrName"strArrayInput); 
That seems to work (I hesitate to say just 'it works' due to previous experience).

I'm very grateful to you for pointing out this quite serious flaw, hopefully in a couple of months I'll come back to this and be able to figure out WTF I was doing beforehand, and how to make your more elegant solution work for this situation.

(This post was last modified: 01-20-2013, 10:04 PM by Adrianis.)
01-20-2013, 07:39 PM
Find


Messages In This Thread
RE: Script Language Reference and Guide - by Adrianis - 01-20-2013, 07:39 PM



Users browsing this thread: 1 Guest(s)