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


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A local variable int bug
Radical Batz Offline
Posting Freak

Posts: 953
Threads: 145
Joined: Dec 2013
Reputation: 25
#1
A local variable int bug

I am doing a script fuction using addlocals!
Now the script is supposed to check that the player got 2 variable locals, and when he got those 2 then a function will occur which i did here OnEnter:

PHP Code: (Select All)
if(GetLocalVarInt("getit") == 2)
 {
    
SetEntityActive("CaveIn_1"true);
    
AddDebugMessage("2globalshavebeenfound"true);
 } 

For the first local, you need to pick up a key which in the callback func of pickup, it will activate this script
PHP Code: (Select All)
void pickkey(string &in asEntitystring &in asType)
{
    
AddDebugMessage("1global"true);
    
AddLocalVarInt("getit"1);  


And for the 2nd local, you need to use an item on an object by using an adduseitem callback which activates this function here
PHP Code: (Select All)
void animation(string &in asItemstring &in asEntity)
{
    
RemoveItem(asItem);
    
AddDebugMessage("1global"true);
    
CompleteQuest("bucket""bucket");
    
CreateParticleSystemAtEntity("splashps""ps_impact_water_low.ps"asEntityfalse);
    
PlayGuiSound("mizu"1);
    
GiveItem("wooden_bucket_filled""wooden_bucket_filled""water""wooden_bucket_filled.tga"1);
    
SetMessage("Messages""bucketss"2);
    
AddLocalVarInt("getit"1);  


I added a debug message everytime a player gets a variable, also when the 2 are called as I shown on enter but it does not work. The debug message also doesn't play when it checks "if(GetLocalVarInt("getit") == 2)"

Is there anything wrong or missing that is causing this mind blowing error? When in game there are no errors and crashes that occur while testing this.
The map updates and the script too, so no worries.

thnx

(This post was last modified: 05-28-2015, 11:10 AM by Radical Batz.)
05-28-2015, 11:09 AM
Find
Kreekakon Offline
Pick a god and pray!

Posts: 3,063
Threads: 70
Joined: Mar 2012
Reputation: 124
#2
RE: A local variable int bug

(05-28-2015, 11:09 AM)Mr. Badcatz Wrote: I am doing a script fuction using addlocals!
Now the script is supposed to check that the player got 2 variable locals, and when he got those 2 then a function will occur which i did here OnEnter:

PHP Code: (Select All)
if(GetLocalVarInt("getit") == 2)
 {
    
SetEntityActive("CaveIn_1"true);
    
AddDebugMessage("2globalshavebeenfound"true);
 } 

This is likely your problem. I remember that OnEnter only runs once when the player enters the map. It does not continue to run forever to check if the state of OnEnter has been fullfilled.

To achieve something that constantly checks if something has been achieved in HPL 2 I think you need to use a very fast timer.

[Image: Tv0YgQb.gif]
Image by BandyGrass
05-28-2015, 11:25 AM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#3
RE: A local variable int bug

First guess is you're missing SetLocalVarInt(), which should be in OnStart();

PHP Code: (Select All)
OnStart()
{
SetLocalVarInt("getit"0)


I'm genuinely unsure if that will fix it, but in most cases, you need to either set or declare a variable before it can be modified.


Orr, as Kreek mentioned, throw that section of code after your AddLocalVarInt(); since then it will check if the var does actually equal 2.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 05-28-2015, 11:26 AM by Romulator.)
05-28-2015, 11:25 AM
Find
Radical Batz Offline
Posting Freak

Posts: 953
Threads: 145
Joined: Dec 2013
Reputation: 25
#4
RE: [Solved]A local variable int bug

Alright, I got it working unexpectedly. So thnx to Rom and u kreek for helping me out with this mind fuck problem. I should learn something from this int he future and thread is now solved.

05-28-2015, 12:08 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#5
RE: A local variable int bug

(05-28-2015, 11:25 AM)(拉赫兰) Romulator Wrote: First guess is you're missing SetLocalVarInt()

Both Set- and Add- LocalVarInt's declare the variable. Add will create it if it doesn't exist, with a default value of 0.

@Badcat: What was it that solved it?

05-28-2015, 03:44 PM
Find
Radical Batz Offline
Posting Freak

Posts: 953
Threads: 145
Joined: Dec 2013
Reputation: 25
#6
RE: A local variable int bug

all I had to do is put the
if(GetLocalVarInt("getit") == 2)
{
SetEntityActive("CaveIn_1", true);
AddDebugMessage("2globalshavebeenfound", true);
}
everytime it adds a localvar

And I guess putting a SetLocalVarInt("getit", 0) on start helped too, so kudos for that guys.

05-28-2015, 05:16 PM
Find




Users browsing this thread: 1 Guest(s)