scripting - number value increase?

Post your scripting questions / solutions here

Moderator: Moderators

lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

right, the fan will increase it's rotation by 20 every 5 seconds, and once it hits 360, it'll stop totally, if you wanted to change it's speed, it's either replace

Code: Select all

$fan3 rotateY local.fanSpeed 
with

Code: Select all

$fan3.time = local.fanSpeed 
or repl;acing it with
$fan3.speed = local.fanSpeed
not sure.

and yet again, i see you did this :P

Code: Select all

$fan1 time 1 
$fan2 time 1 
$fan3 time 1 
it's got to be

Code: Select all

$fan1.time 1 
$fan2.time 1 
$fan3.time 1 
always use a . with something you'd put in key/value. thing.targetname, enemy.target, fan.speed. anything :P
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

Post by HDL_CinC_Dragon »

ok ty
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

backwards

Post by tltrude »

You have these backwards--set the variables before you start the threads.

This:
----------------------------------
thread lift
$lift time 3

thread fans
$fan1 time 1
$fan2 time 1
$fan3 time 1

thread blastdoor
$blastdoor time 3.13
$wheels time 3.13
----------------------------------

Should be:
----------------------------------
$lift time 3
$fan1 time 1
$fan2 time 1
$fan3 time 1
$blastdoor time 3.13
$wheels time 3.13

thread lift
thread fans
thread blastdoor
----------------------------------
Tom Trude,

Image
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

Post by HDL_CinC_Dragon »

ok, would this work?

Code: Select all

main:

level waittill prespawn

thread fan_ops
$local.rotationdegree = 1
$fan1 time 1

level waittill spawn

fan_ops:
while(1)
      {
               $trigger_01 waittill trigger
               $trigger_01 nottriggerable

               wait 1

               $fan1 rotateY local.rotationdegree++
               wait 360
               $fan1 rotateY 0              // to stop the increase
               $fan1 rotateY 360          // to keep it going at 360

               wait 1

               $trigger_01 triggerable
               $trigger_01 wattill trigger
               $trigger_01 nottriggerable

               wait 1

               $fan1 rotateY local.rotationdegree--
               wait 360
               $fan1 rotateY 0             // to make sure it dosnt go into the negatives

               $trigger_01 triggerable
               wait 1
      }
end

any changes at all that need to be made or any comments you have PLEASE post!
Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

This thread is long an messy by now... could you explain what it is that you want to do?

I dont want code, I want a description in words.

Do you want a fan to start when triggered, then accelerate, then decelerate until it stops and then become triggerable again?
Admin .MAP Forums
Image
Head above heels.
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

Post by HDL_CinC_Dragon »

well sorta,

I want the player to press the trigger, then the fan starts at rotation 1 per second on the Y (or other) axis and then slowly increases by 1 degree every second until it hits 360 (so it would take 360 seconds to get to 360? rotation per second) then I want it to stay at 360? until the player triggers it again. when he/she triggers it a second time, I want it to decrease by 1 every second until it hits 0 (so it would take 360 seconds to get to 0? rotation pre second) then when its at 0 again, I just want the thread to start over so the player can press the trigger again and again to turn on and off the fan.


Better? I thought itd be clear what I need by the thread I wrote... but I guss thats just how I work...
Image
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

Post by HDL_CinC_Dragon »

help my pitiful self! pleaaaaaaaaaaaaase!
Image
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post by Grassy »

then the fan starts at rotation 1 per second on the Y (or other) axis and then slowly increases by 1 degree every second until it hits 360 (so it would take 360 seconds to get to 360? rotation per second) then I want it to stay at 360? until the player triggers it again
?? This is hurting my brain... :shock: let me break down what you said..

"1 rotation per second"? yeah ok.. then.....
"increase by 1 degree" ?? increase what by one degree, it's already done one revolution..
"until it hits 360" ?? what 360 rotations per second or 360 degrees??
but then you say " 360 seconds per rotation" ??? very slow rotation speed now.
and then.....
"stay at 360 degrees" ???? I'm confused man...
An ambiguous question will get a similar answer...
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post by Grassy »

Ok I think something like this might be what you were after.
Version update
Update: I just tested this in one of my maps with a fan in it, works like a charm! :)

Code: Select all

level.fanready = 0
thread fan_ops 


//-----------------------
fan_ops:
//-----------------------
// modified ver 1.01

while(1)
{
	$trigger_01 waittill trigger
	local.player = parm.other
	
	if(level.fanready == 0)
	{
		local.player iprint "Starting up fan...."
		local.fanspeed = 0
		local.finalspeed = 360

			while(local.fanspeed < local.finalspeed) 
    		{ 
				local.fanspeed++
				// $fan1.time = local.fanspeed  //don't think we need time for rotate
				$fan1 rotateY local.fanspeed   //speed variable
				wait 1
			}
		level.fanready = 1
		local.player iprint "Fan has reached operating speed...."
	}
	else
	{
		local.fanspeed = 360
		local.finalspeed = 0
		
		local.player iprint "Switching off fan now...."

			while(local.fanspeed > local.finalspeed) 
    		{ 
				local.fanspeed--
				// $fan1.time = local.fanspeed  //don't think we need time for rotate
				$fan1 rotateY local.fanspeed   //speed variable
				wait 1
			}
		level.fanready = 0
		local.player iprint "Fan has now stopped...."
	}
	waitframe
}
		
end
Grassy
Last edited by Grassy on Mon Apr 11, 2005 10:57 am, edited 3 times in total.
An ambiguous question will get a similar answer...
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

That scrip look OK, except for one thing:

Code: Select all

            local.fanspeed++
            $fan1.time = local.fanspeed
            $fan1 rotateY 360
...think that should be

Code: Select all

            local.fanspeed++
            $fan1 rotateY local.fanspeed
( same change in the deceleration part )

Dont think you need a $fan1 move command for this... but if thie script dont rotate it, try adding $fan1 move after the rotateY command.
Admin .MAP Forums
Image
Head above heels.
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post by Grassy »

That scrip look OK, except for one thing:
Thanks mate, your correct, script modified... see above.
Grassy
An ambiguous question will get a similar answer...
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

Post by HDL_CinC_Dragon »

uhhhh i think thats what I want but ummmm what the crap am i lookin at...? whats this parm.other thing mean? thats all scaring me...

I know and im sorry i know im not the quickest learner of this magnitude of scripting and im also frustrated that you guys are trying but im just not getting it which is just wasting your time. And im sure you guys are 10 times more frustrated. I will in fact try out this script youve given me and Im sure that ill be able top learn from it by tweaking it and messin around with it. But while im doing that, here is a refined explaination of what im looking for just in case I cant do it:


Real Life Connection: ok, you know how when you flip a switch, the fan will turn on and start spinning faster and faster until it hits its maximum RPM. Then when you flip it again, it slowly stops until comming to a complete halt. Then you can turn the fan on again and off again time after time? that is what im looking for. Now im sure the example uve given me is at least 90% what im looking for but, is there any way that script can be written more simple? I mean, kind of like the one I used as an example when first asking for help on this particular try?


This is the one I mean, could it be written similar to this? you know with out all the "parm.others" and "if(level.this and that == 0)" and things like that?:

Code: Select all

main: 

level waittill prespawn 

thread fan_ops 
$local.rotationdegree = 1 
$fan1 time 1 

level waittill spawn 

fan_ops: 
while(1) 
      { 
               $trigger_01 waittill trigger 
               $trigger_01 nottriggerable 

               wait 1 

               $fan1 rotateY local.rotationdegree++ 
               wait 360 
               $fan1 rotateY 0              // to stop the increase 
               $fan1 rotateY 360          // to keep it going at 360 

               wait 1 

               $trigger_01 triggerable 
               $trigger_01 wattill trigger 
               $trigger_01 nottriggerable 

               wait 1 

               $fan1 rotateY local.rotationdegree-- 
               wait 360 
               $fan1 rotateY 0             // to make sure it dosnt go into the negatives 

               $trigger_01 triggerable 
               wait 1 
      } 
end
Again, sry for being kinda dense on this... I know you guys are trying and I thank you for that but please, dont give up on me. Ill get it eventually (hopefully soon)

but now its really late and I must get to bed or ill die of fatigue. Been running on 1/10 batteries for about 1.5 weeks now. g'night guys
Image
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

Well, u could do it without the parm.other. It was responsible for giving the messages to the player using the switch. Without, every player gets the message :wink:
The if(this and that) stuff, well, is a must. The fan or rather the script must "be told" what to do when the switch is used: Turn the fan on or off.
Maybe u like this version better:

Code: Select all

fan_ops: 
while(1) 
{ 
	$trigger_01 waittill trigger 
	$trigger_01 nottriggerable
	if(local.fanspeed == 0) //if fan is off...
	{ 
		iprintln_noloc "Switching on fan now...." 
		while(local.fanspeed < 360) 
		{ 
			local.fanspeed++ 
			$fan1 rotateY local.fanspeed 
			wait 1 
		} 
		local.fanspeed = 360
		iprintln_noloc "Fan now is at full speed."
		$trigger_01 triggerable		
	} 

	if(local.fanspeed == 360)   //if fan is at full speed...
	{
		iprintln_noloc "Switching off fan now...." 
		while(local.fanspeed > 0) 
		{ 
			local.fanspeed-- 
			$fan1 rotateY local.fanspeed 
			wait 1 
		} 
		local.fanspeed = 0
		iprintln_noloc "Fan now is off." 
		$trigger_01 triggerable
	} 
	waitframe 
} 
end
didn't test that, so there might be some typos...
What I dislike in this (and all other versions before) is, that the fan can't be switched on or off while it's gettin faster or slower, just in the full speed or off status. But u never said anything against that :wink:
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

parm.other is a way to store the player that caused the trigger to be triggered.

Read about the parm object and its use in the "Predefined objects" section in my scripting tutorial.

http://gronnevik.se/rjukan/index.php?n= ... uage#toc24
Admin .MAP Forums
Image
Head above heels.
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post by Grassy »

Now im sure the example uve given me is at least 90% what im looking for but, is there any way that script can be written more simple? I mean, kind of like the one I used as an example when first asking for help on this particular try?
Erm well I thought it was simple :)
And I tested my example, it works as per your design specs.
Grassy
An ambiguous question will get a similar answer...
Post Reply