Jump to content

Doing something wrong


Ranokoa

Recommended Posts

Okay so i'm trying to get this script to work, and I dont really want to tell what it is about yet because when I release the mod I'm going to release the intended use as a modders resource and hopefully it will be original :D Anyways. I have trouble with getting this script to.. well.. save..

 

It won't save, everytime I try, i click it, no prob, I exit scripting, and it asks if I want to save. Well I'm obviously doing something wrong, and remember I'm no master scripter.. especially when I'm custom writing it.. thats when im terrible..

 

scriptname RTWS01ED

Short Fade

Begin GameMode
	if getdistance player < 140
	Enable
ElseIf
	getdistance Player >141
	if fadeFlag == 1		  
if fader >= 0
 set fader to (fader - getSecondsPassed)
endif

if fader < 0
 disable
 set fadeFlag to 0
 endif
endif
Endif
End

 

anyways, anyone have anyidea what i'm doing wrong here?

Link to comment
Share on other sites

scriptname RTWS01ED

Short Fade
Short FadeFlag
Short Fader

Begin GameMode
if Player.getdistance DiramSerethiRef < 140
Enable
ElseIf Player.getdistance DiramSerethiRef >141 
If fadeFlag == 1
If fader >= 0
set fader to (fader - getSecondsPassed)
endif
endif
endif

if fader < 0
disable
set fadeFlag to 0
endif

End

 

This should work, it does for me. I added the short name variable because the CS did not recognize them as functions and niether do I. I also fixed some minor errors in the one you posted. Also, the Refs I used were just a random ref I picked to get the script to save

 

another edit, I just realized that you may want to reverse the player and ref in the getdistance function. If thats the case, you were good on that. Just got to put in the ref to the object you are looking for to get closer or further from the player

Link to comment
Share on other sites

Seems it was already answered, just out of curiosity... oxala all that indentation from the first post is because the BB code, as it is no indentation at all would be so much better...

 

Remember 'ElseIf' works somewhat emulating a 'case' structure, although you can have if-else-endif inside you should grant they do not extend beyond it (modulation) so that indentation should be something like

scriptname RTWS01ED

Short Fade
Short FadeFlag
Short Fader

Begin GameMode
  if ( Player.getdistance DiramSerethiRef < 140 )
  Enable
  ElseIf ( Player.getdistance DiramSerethiRef >141 )
  If ( fadeFlag == 1  )
	 if  fader >= 0
		set fader to (fader - getSecondsPassed)
	 endif
  endif
  endif

 if fader < 0
disable
set fadeFlag to 0
 endif

End

 

Yet, I can't see where those variables are seated and this may be your real problem... having them with same name in another script does not do the trick. If they are in the same script used in other blocks, it should be in the GameMode block they should be managed.

 

The way it was done that code is, in the least, 'unreliable'.

 

PS: since the 'fader' is only modified if 'faderFlag' is 1 AND fader is greater than 0, the 'ifs' could be reduced to only one there:

If ( fadeFlag == 1 && fader >= 0 )

what lead to a cleaner code.

Link to comment
Share on other sites

Thanks. You know I'm not too sure really the purpose of the indentation other than an easier read. I have had a script with no indentation and many else's and elseif's in it and a whole mess load of end(if)'s and it ran smoothly. Wonder if there is a purpose other than easier reading to it, or if it is recognized whatsoever in the script. Anyways, thanks. Hopefully this will work, ill see if it does immediantly and tell you if it does. Looks clean enough, and looking at the good script versus mine well at least i got ALMOST right lol. I don't do good with too highly variabled scripts on my own >_<
Link to comment
Share on other sites

Oh.. and it is supposed to be referanced on self.. Idk much about it but if i set target to self and tell it to do it to target rather than the ref can that work? Cause... It is used too many times to be clean and have it ref'ed.
Link to comment
Share on other sites

Grr.. attempted apparently the wrong way and crashed as soon as I set the script to the object.

 

Basically its on an activator, and I use the same activator multiple times.. I want the activator to be scripted to refer to itself rather than anything specific as I don't want to have to make several different ID's of duplicated activators just so I can have different variabled scripts on each one to correlate to that specific one. It should just be always doing it to the object that is scripted automatically with no need to indicate such through reference Id's.. So.. I got confused on that...

Link to comment
Share on other sites

Thanks. You know I'm not too sure really the purpose of the indentation other than an easier read. I have had a script with no indentation and many else's and elseif's in it and a whole mess load of end(if)'s and it ran smoothly. Wonder if there is a purpose other than easier reading to it, or if it is recognized whatsoever in the script. Anyways, thanks. Hopefully this will work, ill see if it does immediantly and tell you if it does. Looks clean enough, and looking at the good script versus mine well at least i got ALMOST right lol. I don't do good with too highly variabled scripts on my own >_<

You said everything, the only purpose of indentation is being easier to read.

 

But the issue, if persists, would be in the logic and the way those variables are set. Although it's clear to me you want to 'enable' and vanish something when at expected distance from the player, nothing is said about the remaining logic to grant the script works as expected.

 

To all those tests resulting, the variables need to be set before getting there, if it is not done, the entire GameMode block will never works there.

Link to comment
Share on other sites

Coincidentally a fellow modder had a problem similar that yours, he wanted to give an armor to player once he clicked an activator (a model of that armor)

and the troubles are more or less the same. He was setting the variables in the OnActivate block and testing in GameMode.

Link to comment
Share on other sites

Okay well I suppose I'll just come clean with intent to further explain.

 

Its on an activator, a brick, really. In a place where there is nothing but the heavens above and the abyss below, you step on this cloud and these bricks appear below you. Stepping stones. Once you step on em and step off they disappear. So there is no activating required, its just supposed to happen. Thats why its game mode. I want it to happen only to the scripted object itself because I'm using many of those stepping stones.

Link to comment
Share on other sites

Grr.. attempted apparently the wrong way and crashed as soon as I set the script to the object.

 

Basically its on an activator, and I use the same activator multiple times.. I want the activator to be scripted to refer to itself rather than anything specific as I don't want to have to make several different ID's of duplicated activators just so I can have different variabled scripts on each one to correlate to that specific one. It should just be always doing it to the object that is scripted automatically with no need to indicate such through reference Id's.. So.. I got confused on that...

You got me confused now. ReferenceId is always unique, even if you use the same ObjectId in several places in the game, I really don't imagine as you can accomplish duplicating them.

Activators must be activated by some actor, what you mean by they activating themselves?

 

Fallout3 Geck allows for enabling/disabling "ObjectId", a very dangerous function... CS does not allows it, you need to do that enable/disable thing for all and every reference of objects you place in game.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...