Jump to content

Fallout New Vegas GECK & Scripting Help 101


Recommended Posts

Posted

Ok simple one for you string guru's,

I'm adding a DebugLog option to SCR pretty much copied straight from Docs script in Spunk, it works other than the VersionNumber for SCRturns into scientific notation for some reason.

 

gSexoutSCRVersion == 20150326.1

 

I get this in debuglogfile instead:

 

SCRStartLog:SCR version: 2.01503e+007

 

code is this:

Print "SCRStartLog:SCR version: " + $gSexoutSCRVersion
Had a moment's inspiration thinking it was so simple and tried this too but it won't compile:

 

Print "SCRStartLog:SCR version: %8.1f" gSexoutSCRVersion
Posted

The automatic tostring in the first example is doing that. NVSE doesn't actually use printf/sprintf to format strings, it uses its own bizarre version. My suggestion is to do like sexout does -- use integers rather than a float. Or use an integer and go to plain YYYYMMDDNN (ditch the decimal).

Posted

$ToString uses scientific notation for printing numbers that are very large, the same way as using "%g" Number.

 

Print accepts string concatanation ("this" + "that" + $this) instead of string formatting, like PrintC and older NVSE functions do. This is usually more convenient/readable, but it is less flexible for printing numbers. So, I would suggest you just use PrintC in this case.

Posted

Aggh... PrintC also rounds off floats by the looks

 

Stupid GECK maths is driving me nuts, spent an hour screwing with this and can't get it to work

 

If I do this:

Set gSexoutSCRVersion to 20150327.1
Set fSCRVer to (gSexoutSCRVersion - 1)
Set iSCRVer to fSCRVer
Set fSCRDecimal to (gSexoutSCRVersion - iSCRVer) * 10
PrintC "SCRStartLog:SCR version: %8.0f.%1.0f " iSCRVer fSCRDecimal
I Get:

SCRStartLog:SCR version: 20150328.0

 

If I do this:

Set gSexoutSCRVersion to 20150327.1
Set fSCRVer to (gSexoutSCRVersion - 2)
Set iSCRVer to fSCRVer
Set fSCRDecimal to (gSexoutSCRVersion - iSCRVer) * 10
PrintC "SCRStartLog:SCR version: %8.0f.%1.0f " iSCRVer fSCRDecimal
I get:

SCRStartLog:SCR version: 20150326.20

Posted

Sweet jesus hal!! :D

 

If we had fixed-point math I'd be with you, but floats aren't fixed point.. they're floating point. Why not just store them separately as integers, or use the bigger integer without the decimal point?

Posted

how about

let iVersion := floor gSexoutSCRVersion

let fVersion := gSexoutSCRVersion - iVersion

let sv_version := sv_construct "%8.0" iVersion

Print "SCRStartLog:SCR version: " + sv_version + "." + $fVersion

Posted

It's still a float though, which means eventually you might run into precision problems.

 

Also of course if you do that with iVersion/floor, you can just use %g -- no need for the sv_construct.

 

Print "SCRStartLog:SCR version %g.%z" iVersion fVersion

 

Though this and yours will both print "wrong". fVersion will be something like 0.1, not 1, without a multiplication. That means it'll print 20150101.0.1 or something like that.

Posted

Ah, true about the multiplication

so let fVersion := (gSexoutSCRVersion - iVersion) * 10

 

the sv_construct is really just to force the formatting specifier, although it's quite possibly not needed for just the 8-digit integer

Posted

You don't need it for any integer. They will all print correctly no matter the value. The format specifier needs a type there, the '%8.0' on it's own won't work by itself -- needs to be '%8.0f' for example, and if you say %f for float (%g doesn't have precision) then you probably just end up with more scientific notation gibberish. ;)

 

Even multiplying that value by 10 will blow up once the fractional part gets to 0.11 and results in a 1.1.

 

All the weird edge cases like that just aren't worth it IMHO. One big integer or a few smaller integers are the way to go. ;)

Posted

I'm only on my second cup of coffee, man! You're right about the integers not needing format specs, and the f. Hal's been using date-based versioning for an age though, and I'm not sure switching to numbers is the best thing for him.

 

Something like

let iInt := floor gSexoutSCRVersion

let iDec := (gSexoutSCRVersion - iInt) * 10

Print "SCRStartLog:SCR version: " + $iInt+ "." + $iDec

 

should be fine, unless he plans on 10+ releases a day (!)

Posted

What I'm thinking of is something along the lines of the version being just an integer (internal).

 

iSexoutSCRVersion := 2015031505

 

This will fit in a signed integer until 2147.

 

Then for display, to reintroduce the decimal..

 

printC "%g.%g" floor(iSexoutSCRVersion / 100), iSexoutSCRVersion & 63

 

I'm not suggesting he switch away from the date format, just that it be stored as an integer rather than a float to get away from all this floating point and printing stuff. ;)

 

 

 

--------

 

Err the "& 255" is wrong, it should be "& 63" which is as large as it can be without overlapping any of the date part, allowing for releases from yyyymmdd(0..63).

Posted

@Halstrom:

 

From GECK wiki, "String Formatting"

 

%X.Yf - This formats a number with minimum width X and maximum decimal points Y, replacing X and Y with that desired.

 

In your example Y is 0, so no decimal point. Try this:

 

PrintC "SCR Version: %.1f" gSexoutSCRVersion

Yeah I tried that earlier, it still comes out as scientific notation.

 

My other option is to go back to DebugPrint which works fine, it just means I need to turn SetDebugOn and add a condition block the few debugging messages in SCR, there's only 3 or 4 off them to block.

Guest tomm434
Posted

Any way to insert custom text into dialogue? (Player prompt).

 

I tried to change player name and inserting "&Pcname; in prompt" and it worked but what if I need multiple dialogue choices?

 

Also new NVSE version has new Events about player prompt but I couldn't get it to work. Does someone have test esp for new event?

  • 2 weeks later...
Posted

Hey guys, just a simple question, I'm having problems trying to import a custom nif I made inside GECK, and I created a post about it on the technical support general but It didn't gather much attention there, so may I put this kind of thing here as well or is it against the rules? Newbie question...

Posted

Hey guys, just a simple question, I'm having problems trying to import a custom nif I made inside GECK, and I created a post about it on the technical support general but It didn't gather much attention there, so may I put this kind of thing here as well or is it against the rules? Newbie question...

 

Well here's mainly for scripting. I'm going to take a look at your nif.

Posted

 

Hey guys, just a simple question, I'm having problems trying to import a custom nif I made inside GECK, and I created a post about it on the technical support general but It didn't gather much attention there, so may I put this kind of thing here as well or is it against the rules? Newbie question...

 

Well here's mainly for scripting. I'm going to take a look at your nif.

 

 

Thanks! I made a new version in blender this time that is not on the original post so I'll put it here

exportEDITED.nif

 

The post I've mentioned is http://www.loverslab.com/topic/45532-invisible-body-on-custom-armor/

Guest tomm434
Posted

Somebody knows why NPC can ignore EquipItem  command?

 

First time bug was fixed by restarting the game. It might be connected with alternate start mod but it's not confirmed.

Posted

Assuming you've already handled any "same frame" issues (don't add the item in the same frame you equip it or remove another item -- usually does work, sometimes does not) are you sure the previous item in that slot wasn't set with the nounequip flag? Was there possibly a script running that reequipped the old item?

Guest tomm434
Posted

My initial script made NPC equip that item only once in same frame but it

 

But I sent another esm where I made NPC equip that item with 0.1 sec delay and issue still stands (it happened to one of the user, today I got the same report from another user).

 

 

are you sure the previous item in that slot wasn't set with the nounequip flag?

yep that might be the reason. But I just tried that case in my game and reequipping works fine.

 

 

 

Was there possibly a script running that reequipped the old item?

Don't think there s any.

Guest tomm434
Posted

Hm  I just tried doing the same manually via console and I couldn't - I think that's the reason - thanks a lot!

Guest tomm434
Posted

I've got a problem  - I have 2 medium armors - one is vanilla (Combat armor), second is from one of the Courier packs (Lightweight metal armor). Both are set as "medium" in GECK. But ingame this script behaves differently:

            let BitMask := GetEquipmentBipedMask Item
            Print "Equipment bit mask is " +$BitMask

            if  BitMask == (SetBit BitMask, 3)
           PrintC "Medium armor"

It returns "Meium armor" for lightweight metal armor but for Combat armor it doesn't do anything.

Here are pictures of their formIDs in GECK and how Print "Equipment bit mask is " +$BitMask shows up ingame.

 

post-187071-0-85569900-1429434437_thumb.jpg

post-187071-0-25403600-1429434438_thumb.jpg

 

Any ideas?

 

Guest tomm434
Posted

Not any of them are affected by other plugins and they both have "medium" tags ingame

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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