Home   Help Search Login Register  

Author Topic: Wait command for scripts  (Read 690 times)

0 Members and 1 Guest are viewing this topic.

kymandro

  • Guest
Wait command for scripts
« on: 06 Feb 2005, 21:55:57 »
Is there a wait command for scripts like to make it wait 2 secconds befor it dose the next command?

ThAnKs ;D

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Wait command for scripts
« Reply #1 on: 06 Feb 2005, 21:58:05 »
~2


Planck
I know a little about a lot, and a lot about a little.

Offline Roni

  • Members
  • *
  • Play the Game !
Re:Wait command for scripts
« Reply #2 on: 07 Feb 2005, 05:06:15 »
Related tip !

If you have a script that you don't want to see activated too fast (say, a searching script, a reload script or a build object script) then try adding the following lines to the start of the script

? scriptInProgress == true : hint "Not so fast !", exit
scriptInprogress = false



and the following at the end of the script -

~3
scriptInProgress = false



Of course you'de choose your own delay to line up with any associated playmoves or sounds.

Cheers



Roni

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Wait command for scripts
« Reply #3 on: 08 Feb 2005, 22:01:20 »
you don't check booleans like that
it would just be:
?scriptinprogress

Offline Roni

  • Members
  • *
  • Play the Game !
Re:Wait command for scripts
« Reply #4 on: 08 Feb 2005, 22:52:31 »
Sorry, my bad - that should be

scriptInProgress true / false

or scriptInProgress = 1 / 2

 :P

BTW - I've never been to particular about the use of booleans as opposed to simple numeric or string variables - does anyone know just how much CPU you save using booleans ?


Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Wait command for scripts
« Reply #5 on: 08 Feb 2005, 23:30:40 »
Booleans are just switches, they are either on or off.

On means '1' or true

Off means '0' or false.

There are no other values that can be assigned.


Planck
I know a little about a lot, and a lot about a little.

Offline Roni

  • Members
  • *
  • Play the Game !
Re:Wait command for scripts
« Reply #6 on: 08 Feb 2005, 23:41:41 »
I know all about booleans -  FWIW I've got a degree in formal logic !     8)  :P

I just don't know how much CPU/RAM/lag time etc you save by using them rather than a variable with two values instead, eg -

_weaponInUse = "Heck Yeah"
_weaponInUse = "Nah"
if _weaponInUse = "Heck Yeah" then goBananas else takeAnap


I know that to a programming purist you should use booleans as flags rathe than string or numeric variables, I'm just not sure how much it helps lag etc when you're only using a few scripts in a mission.

Anyone ?


Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Wait command for scripts
« Reply #7 on: 09 Feb 2005, 00:15:35 »
Well if you think about it logically, its got to be better to use booleans.  Otherwise why bother having them?   You have to allow numeric variables anyway.

Does anybody know what BIS usually did?
« Last Edit: 09 Feb 2005, 00:16:01 by macguba »
Plenty of reviewed ArmA missions for you to play

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Wait command for scripts
« Reply #8 on: 10 Feb 2005, 05:03:11 »
Quote
I just don't know how much CPU/RAM/lag time etc you save by using them rather than a variable with two values instead
 I would think that boolean variables would take up less RAM than other variables, since they only need one bit (0 or 1). Numbers are stored up to a lot of decimals, so they have to be at least a couple bytes. Strings can be up to like 4000k in length. So if you only need a simple switch, it would be better to use 1 bit instead of 4000k, I would think. With regular amounts of scripting I'm sure it wouldn't make a noticable difference, but with a very large/complex script system (running on a slower system), it might actually matter.

  Of course, I may be wrong about the way OFP stores variables. Obviously you can 'change' a variable into anything you want (i.e. store a boolean in a var holding a string), so perhaps it doesn't store vars in the same way as other programming languages.
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Roni

  • Members
  • *
  • Play the Game !
Re:Wait command for scripts
« Reply #9 on: 11 Feb 2005, 06:10:56 »
Most of my missions use only 10-12 scripts using maybe 30-40 variables (almost all local), tops.  Wherever possible I set my scripts to loop as slowly as possible (eg 2-3 secos per cycle) to minimise CPU drain.

I prefer using string or numeric variables purely for ease of editing.  Having a variable with values of "gunReady" or "gunInUse" is easier for me to understand then 1 or 0.

Of course I am aware that wherever posible one should acqure good habits so that when you get to the 300 line / 50 variable monster scripts those booleans vs string variables really do make  difference.

I'll try to be good from now on . . .   :)



roni

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Wait command for scripts
« Reply #10 on: 11 Feb 2005, 11:15:01 »
Not to try and beat a dead horse here or anything, but you could easily use booleans for something like "gunReady" or "gunInUse".

_gunReady = true
;gun is ready
_guninuse = false
;gun is not in use

As long as you make booleans read somewhat like english sentences, they are easier to handle. Again, not trying to beat a dead horse though :P
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Roni

  • Members
  • *
  • Play the Game !
Re:Wait command for scripts
« Reply #11 on: 11 Feb 2005, 16:09:37 »
All true and all fair.

I stand defeated, and educated.   :)



Roni

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Wait command for scripts
« Reply #12 on: 12 Feb 2005, 01:53:26 »
It probably is better programming practice to use booleans where applicable... but don't underestimate the power of numerical variables ;)

They can be a lot of things besides 1 or 0. I often use things like daytime to insert a timing function into a variable without actually having a separate timing function. eg.

_now = daytime + (60/3600)
@ daytime > _now

So that'd make the script wait for 60 seconds (daytime works in hours, so you have to divide by 3600 to get seconds).
Anyway, my point is there are heaps of cunning tricks you can use with numerical variables as opposed to boolean, but they do use up more resources... ;)