Questions about ModifyAttribute()

Topics regarding Scripting with Reality Factory
Post Reply
User avatar
Fallen
Posts: 36
Joined: Mon Jul 17, 2006 3:41 pm
Location: Waxhaw, NC

Questions about ModifyAttribute()

Post by Fallen »

I gotta question about the ModifyAttribute() function.

I thought it would be what I used if my player had an attibute and I wanted to increase of decrease the amount of that item through a script.

So I have:

Code: Select all

ModifyAttribute("lighter_heat" ,- 1 , "player");
I assumed since I have my "lighter_heat" attribute is displayed on my HUD, that everytime the above ran, it would minus one from the number of my Numeric Display on my HUD. This it does not do. It simply does nothing 'til suddenly the number on my hud jumps to zero. I can change the amount of time this takes by changing my timing variables, but same results in the end.

Also:

Code: Select all

ModifyAttribute("lighter_heat" ,+ 1 , "player");
That seems to simply crash my script, which makes me assume it is simply improper syntax for increasing the attribute number. Should it just be:

Code: Select all

ModifyAttribute("lighter_heat" , 1 , "player");
Thank you for all of yoru patience with me.
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis »

I believe it doesn't matter if its "+1" or "1".
You should also have "Player" instead of "player" in the last parameter.

Could you post the whole script here? That way it would be a lot easier to solve.
Pain is only psychological.
User avatar
Fallen
Posts: 36
Joined: Mon Jul 17, 2006 3:41 pm
Location: Waxhaw, NC

Post by Fallen »

Well, I wrote the script again and it seem to work now ... go figure. Who knows what idiotic typo I had in it the first time. I'll post it anyhow.

What I wanted to do was a lighter system simular to that in the new XBOX 360 game "Prey." I saw the idea in the demo of the game and liked it ... so decided to "Borrow" the idea. Basically this is what happens.

You turn you lighter on and it starts heating up. Once the heat reaches maxium heat the lighter goes out cause you can't hold it anymore, and you can't relight it until it drops past a certain heat mark.

I used the flashlight script posted here in these forums to start me off and so the code looks a lot like that code with a few more if statements thrown in. Was a good learning experience for me.

Code: Select all

{
	KNUM [29]
	ISON [false]
	TRIG [flash]
	CLCK [0] 
	INTV [25] 

	Spawn[()
	{
		LowLevel("setup");
	}]

	setup[()
	{
		SetNoCollision();
		PawnRender(false);
		self.think = "update";
	}]

	update[()
	{
		self.ThinkTime = 0.2;
		self.think = "fll";
	}]

	fll[ ()
	{
		if(ISON)
		{
			PositionToPlayer(0, 30, 10, true);
			if(GetAttribute("lighter_heat","Player") < 100){
				CLCK = CLCK + 1;
				if(CLCK > INTV){
					ModifyAttribute("lighter_heat",1,"Player");
					CLCK = 0;
				}
			}else{
				SetEventState(TRIG, false);
				ISON = false;
			}
		}

		if(ISON = false)
		{
			if(GetAttribute("lighter_heat","Player") > 0){
				CLCK = CLCK + 1;
				if(CLCK > INTV){
					ModifyAttribute("lighter_heat",-1,"Player");
					CLCK = 0;
				}
			}
		}
		if(GetAttribute("lighter_heat","Player") < 75){

			if(self.key_pressed=KNUM)
			{
				if(ISON = false)
				{
					SetEventState(TRIG, true);
					ISON = true;
				}
				else 
				{
					SetEventState(TRIG, false);
					ISON = false;
				}
			}
		}
	}]
} 
Post Reply