Jump to content
ℹ️ Intermittent Download History issues ×

Script: Float * Integer = Kaboom


Recommended Posts

Well it seems some makes very complex lines of code in Skyrim but we can also make them easier to understand really.

 

One thing I did learn is that we define variables inside each event and that they loose their values when the event is over. When we make a spell script or an OBSE function in Oblivion CS, than the same happens, the variables loose their values as fast as the spell ends or the intpreter in game leaves the OBSE function. Quest and object scripts in Oblivion keeps their values that we define at the top and you define variables the same way in C++, at the top.

 

As the variables are only used inside a event, it can be define at the same line as when we start to use it and that looked ridicules the first time I saw it as it did look awful to me, as I am so used with our way of trying to make a script fomated in a way that makes it easy for anyone to read it an it does not seems like they do that often in Skyrim, not the ones I debated it with. Lets try to make an example, well if I can recall it, that is: :wink:

;Skyrim
Int iVariable = GetThisFunction

;Oblivion
Short iVariable
Set iVariable to GetThisFunction

It is a month since I made a Skyrim script now or 2 months, so I might recall wrong. I do not feel any need to make more really.... :wink:

 

Here is one of my scripts I managed to make and not only that, I also made it to work :D I managed to make this to work after a lot of debating it with the Skyrim community and it took them 3 weeks to make me understand how to code Papyrus at all. I do feel I get the hang of it now, well it sure made me a bit more wise at least.

Scriptname PekMarkTargetRef extends ActiveMagicEffect  

Quest Property PekRefsQST  Auto   
Message Property PekMarkReference  Auto  

PekRefsSCR PekQuestScript


Event OnEffectStart(Actor akTarget, Actor akCaster) 
	PekQuestScript = PekRefsQST as PekRefsSCR
	ObjectReference Testactor

	MiscUtil.PrintConsole ("Caster is: " + akCaster as String)
	MiscUtil.PrintConsole ("Target is: " + akTarget as String)

	;PekQuestScript.SummonAbleRefARR[0] = akTarget
	Menu(akTarget)
	
EndEvent


Function Menu(ObjectReference TargetREF)
	int Button = PekMarkReference.Show()

	If Button == 0
	Else
		PekQuestScript.SummonAbleRefARR[Button] = TargetREF
	EndIf

	TargetREF = PekQuestScript.SummonAbleRefARR[Button]
	MiscUtil.PrintConsole ("Target in Quest is: " + TargetREF as String)	
	
	Debug.MessageBox("Testing\nTesting")

EndFunction


What the purpose of this script will end up as, is to mark NPC, so I can later move them to me, in case I loose them, which I managed to do twice now, by using Mark and recall spells, instead of fast travelling. One big difference is that Quests are placed in the Object window, and act as any Objects, or rather Properties, as that is what they seems to be called and also Forms. Well, it is all confusing. :wink:

 

I will also focus at Oblivion scripting only, as I feel I have full control in Oblvion. Skyrim is soooo different.

 

When it comes to the name CK? I think they renamed it to CK as it differ so much from CS. CS is also called CS for Morrowind, and they do not differ much, well Oblivion and Morrowind CS but Skyrim CK does. But that is just a wild guess.

Edited by Pellape
Link to comment
Share on other sites

When there are this validation issues on runtime, MEssageLogger should give some reports that something went wrong in a script in it's log. There are quite the extensive debug facilities inside Oblivion.

 

Honestly I wonder if it's better to add this kind of checks inside the Script compiler of the CS. ShadeMe's CSE do add already some strictier compiler checks.

Link to comment
Share on other sites

But why we must use special commands in OBSE to access settings? I can understand that Bethesda didn't want to change them via scripting so easily to avoid chaos in mods, but I find usefull to read them if I want use them in calculations. Is there some way to access them through vanilla scripting?

Link to comment
Share on other sites

It's a mini-game in itself trying to figure out their scripting language.

 

GetGameSetting is a vanilla command. OBSE added the command to set it. Who can even imagine what they were thinking there? "No one will ever want to change those by script!"?

Edited by GamerRick
Link to comment
Share on other sites

Before OBSE came, it was a pure hell really to make proper coding at all. OBSE makes life so much easier and it have 2 "simple" parts I really love.

  • Arrays
  • Functions

I do recall I did try to make a big script 2008 and failed to make it work and I could not figure out what the problem was. With OBSE, well if we use OBSE specific commands, we at least get so called offset error messages in the console, that mostly is very very helpful, specially when I fail to get anything useful from an array to any other sort of Variable with LET, as that do happen sometimes, I at least get a hunch, so I can narrow down some debug info into the right spot in the script.

 

CSE is very very cool Ilde and the editor is great now.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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