Author Topic: Interesting discovery  (Read 2801 times)

0 Members and 1 Guest are viewing this topic.

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Interesting discovery
Axem and I figured something interesting out about the engine today.

Let's say you're using a when-argument to track how many ships from Beta wing have arrived in the battle.

EVERY-TIME-ARGUMENT (just using an every-time here for neatness, trigger count high with interval 0 works too)
any-of
Beta 1
Beta 2
Beta 3
Beta 4
Beta 5
Beta 6
has-arrived-delay 0, <argument>
modify variable (numBeta), (numBeta) + 1
invalidate-argument

You'd expect this variable to go from 0 to 6 when Beta wing arrives, right?

WRONG

It will go to 1. The engine does not count the individual arrival of ships in a wing; it simply checks whether the wing has arrived.

Funny stuff.

edit: also totally wrong, see below  :cool:
« Last Edit: October 30, 2010, 01:45:38 pm by General Battuta »

 
Re: Interesting discovery
Interesting. Not entirely unexpected however.

What happens if you make 6 events, one for every member of Beta wing? Or you could just check if Beta wing arrives and +6 to the variable.

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Interesting discovery
Actually your description of what is happening is off.  It does count each individual ship; however, since they all arrive in the same frame the variable is only incremented once.  This is one of the reasons for the do-for-valid-arguments sexp. 
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Interesting discovery
Actually your description of what is happening is off.  It does count each individual ship; however, since they all arrive in the same frame the variable is only incremented once.

Are you sure? We discussed this as a possibility but because these type of event can normally handle things that at least seem to happen in the same frame we thought it unlikely.

I could be wrong though.

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Interesting discovery
Any-of, every-of,etc only do things once unless they contain <argument> in which case every item that becomes true that frame is processed.  So if you do say

any-of
<list>
has-arrived-delay
<argument>
change-iff
traitor
<argument>
send-message
chg to traitor

it will change all 6 ships to traitor but only send one message.  Same with the modify variable in your example.
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Interesting discovery
Also interesting. So everything that happens in one frame is treated as a single...thing? Whatever you're counting?

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Interesting discovery
I wouldn't say everything.  There are always exceptions.  Can't think of one at the moment.
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Interesting discovery
FUBAR's got the handle on the cause of this one.

The other thing to remember with the argument SEXPs is the order they work in. If all 6 ships have arrived you would expect any SEXP containing <argument> to happen 6 times and you'd be right. What you might not expect is that if you have this

change-iff
-<argument>
-Hostile
Modify-variable
-StringVariable[None]
-<argument>

what will happen is that all 6 ships will have their iffs modified and then modify-variable will be called 6 times in a row ending up with the name of the last ship on the list. So if later in the event you have this

self-destruct
-StringVariable[None]

You wouldn't blow up all six ships. You'd self destruct the 6th one 6 times. :D
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Mobius

  • Back where he started
  • 213
  • Porto l'azzurro Dolce Stil Novo nella fantascienza
    • Skype
    • Twitter
    • The Lightblue Ribbon | Cultural Project
Re: Interesting discovery
I've experienced something similar to this a few days ago, but in a completely different scenario. I had to switch to plan B. :)
The Lightblue Ribbon

Inferno: Nostos - Alliance
Series Resurrecta: {{FS Wiki Portal}} -  Gehenna's Gate - The Spirit of Ptah - Serendipity (WIP) - <REDACTED> (WIP)
FreeSpace Campaign Restoration Project
A tribute to FreeSpace in my book: Riflessioni dall'Infinito

  

Offline Scotty

  • 1.21 gigawatts!
  • 211
  • Guns, guns, guns.
Thanks in part to this thread, and also in part due to Battuta, I can now use variables in a rudimentary fashion. :D