Jump to content

PSA from a frustrated scripter.


Radioactivelad

Recommended Posts

So, I had a script that wouldn't compile. I assume because of how unfathomably complex it is.

 

Behold:

SCN MESLoyalCustomerRewardScript
Begin Scripteffectstart
Player.addPerk MESPerkDiscount
showmessage MESPerkRewardMessage
end

If you can't see any conceivable reason that this script would not compile... that's because there isn't one! At least not with the Script itself.

 

Turns out that Messages aren't allowed to contain symbols, in my case "%", if you want to use them in a script.

 

I'm not talking about the ID of the message, *the contents of the message* cannot contain those characters, despite the fact the geck will let you create messages with those characters without complaint. Odd, considering that to my knowledge, the only way a message can be displayed is to have it called by a script.

 

This may be common knowledge to more learned modders, but hopefully I'll save someone else the frustration.

Edited by Radioactivelad
Link to comment
Share on other sites

It probably doesn't want the % because it's used in displaying the values of variables from the script in the message.

 

This:

 

http://geck.bethsoft.com/index.php?title=ShowMessage

 

explains how to display variables like that (or, in your case presumably show you what to avoid so that your script will compile).

 

On the other hand, I'm pretty sure I used % to display health and battery charge through a message box on my driving mod, but there's a chance I may have spelled out percent.... Hard to say for sure atm because I wrote it a while back and can't really look in game just now.

Link to comment
Share on other sites

This is because your "message text" content is stored as a "string variable", and (depending upon which function you use to display that text) some special characters are used to format output. Such frustrations are just one of the reasons "string and character functions" were added to NVSE, to provide means to work around those limitations. A quick glance at the linked GECKWiki page will show that the subject is more complicated than one might suspect; but you can express your "%" so it only gets rendered when displayed (e.g. using the 'AsciiToChar' function).

 

But, yeah. This is something many new scripters will trip across. I've added 'TIP: Special Characters in String Variables' to "Scripting" section of the wiki "Getting started creating mods using GECK" article.

 

-Dubious-

Link to comment
Share on other sites

  • Recently Browsing   0 members

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