Scripting OBSE18 Coolness

From the Oblivion ConstructionSet Wiki
Revision as of 15:26, 9 May 2010 by imported>Demolishun
Jump to navigation Jump to search
Tools used in this tutorial

Required


OBSE Coolness

I am so jazzed about OBSE 18 that I wanted to create a page to share its coolness.

An array of functions

Now that OBSE v18 supports functions you can do some really cool things with it. You could probably do this before with regular functions on objects with OBSE. However functions do not have to be attached to anything.

First lets build some functions:

scn TestFunction1

begin Function {}
  PrintC "TestFunction1 called"
end

scn TestFunction2

begin Function {}
  PrintC "TestFunction2 called"
end

scn TestFunction3

begin Function {}
  PrintC "TestFunction3 called"
end

Obviously those would be independent scripts.

Now lets have some fun with them:

; This would be in some persistent location like a quest script.
array_var functList
...
; This would be in the gamemode part or something.
if(functList == 0)
  let functList := ar_Construct StringMap
  let functList["TestFunction1"] := TestFunction1
  let functList["TestFunction2"] := TestFunction2
  let functList["TestFunction3"] := TestFunction3
endif
...
; Now somewhere else you can call your functions from the array.
; Arguments work too.
ref functRef
let functRef := functList["TestFunction2"]
Call functRef

I am using this feature for my current mod. I use it to apply standardized effects of variable value to an object. I will be able to have my mod cycle through all effects of varying types and functions to operate on those types with a bunch of conditions to control execution. This allows for later mods to add functionality too!