MWSFD Question on variables

Post » Sat Jan 23, 2010 1:53 pm

when i say, "before a fix", i mean immediately preceding one of these - "->"

i freely admit my ignorance on how MW compiles its scripts, but i do find it quite odd, with my rudimentary knowledge of compiling and related tasks, that quotes around a reference take up room for pointers. yet, according to the results of my experience, this is the only conclusion that i can draw.

if you can find some other reason for this behavior, i'll gladly revise my work, it bugs me i had to write my MWSE scripts in a different "style" than my usual scripts.

They shouldn't, which makes the whole thing highly unusual. I know for a fact that using "player"->Stuff works in regular and MWSE scripts. It's possible it was interacting with something else and breaking the VM or MWSE, but how... odd odd.

Slightly OT. But Pythons nonsense?

Not a fan of its syntax. ;)

Remember, OnActivate is a function, not a variable. Unlike a variable you cannot set a functions value. Also the value of OnActivate is 1 for exactly one frame when the player actives the object.

If you want to use OnActivate more than once or store it for some odd reason, just do:
Set wasActivated To OnActiiveif ( wasActivated )    ...

That will store the value and let you work with it as you like (including resetting it part way through your script).

Edit: Oh, and there's also a bug with the default MWScript compiler (CS), where you can start a block with elseif (or possibly else) and it won't give any errors, but can break in the game. Be careful with that.
User avatar
Tina Tupou
 
Posts: 3487
Joined: Fri Mar 09, 2007 4:37 pm

Post » Sat Jan 23, 2010 7:42 pm

So, this is right then?

Try it out. I think the structure would work, but as I explain later, I think the activate is the problem. RAK's examples would work fine, but I want to point out that you can use else after and endif. Anything after an else will only be executed if all previous conditions are false. MWSE has a good explanation of it.

And no, this is crashing my game, the book just wouldn't pick up. I'll try it that way to though.

I mean that the problem seems to lie with activate and adding the item to inventory in both cases.

So, this would work better?

It should. You should try it. I don't see much reason to use activate unless it isn't going to go into your inventory. I suspect the problem is that the item is added to inventory and then tried to activate from within the inventory. I think activate doesn't work within the inventory, but I could be wrong.
User avatar
ruCkii
 
Posts: 3360
Joined: Mon Mar 26, 2007 9:08 pm

Post » Sat Jan 23, 2010 8:40 pm

Try it out. I think the structure would work, but as I explain later, I think the activate is the problem. RAK's examples would work fine, but I want to point out that you can use else after and endif. Anything after an else will only be executed if all previous conditions are false. MWSE has a good explanation of it.


I mean that the problem seems to lie with activate and adding the item to inventory in both cases.


It should. You should try it. I don't see much reason to use activate unless it isn't going to go into your inventory. I suspect the problem is that the item is added to inventory and then tried to activate from within the inventory. I think activate doesn't work within the inventory, but I could be wrong.

That makes sense, how can it activate it when it's already in your inventory? (hypothetical question). But Everything seem's to run smoothly now, of course I'll probably be back in an hour with some new horrendous over simplified problem. Oh well, I'm trying to learn atleast haha =p
User avatar
Everardo Montano
 
Posts: 3373
Joined: Mon Dec 03, 2007 4:23 am

Post » Sat Jan 23, 2010 2:10 pm

There is no really easy way to measure distance that I know.

It's quite silly that I did not think of this, especially since I should know this. If you still need, you can just click on something with the console open, and type "getdistance, player".
So obvious... :facepalm:
User avatar
Peetay
 
Posts: 3303
Joined: Sun Jul 22, 2007 10:33 am

Post » Sat Jan 23, 2010 10:39 pm

It's quite silly that I did not think of this, especially since I should know this. If you still need, you can just click on something with the console open, and type "getdistance, player".
So obvious... :facepalm:

:facepalm: Thanks for the tip though, that will be useful :D
User avatar
Oceavision
 
Posts: 3414
Joined: Thu May 03, 2007 10:52 am

Previous

Return to III - Morrowind