Any way to combine strings for message notifications?

Post » Thu Jun 21, 2012 10:58 am

There has got to be a better way to do this:

if attacker == playerref || me == playerrefif MessageNum == 1debug.Notification("Attacker did a Target Feint.")elseif MessageNum == 2debug.Notification("Attacker did a Flank Feint.")elseif MessageNum == 3debug.Notification("attacker did a Range Feint.")elseif MessageNum == 4debug.Notification("Attacker did a Target-Flank Feint.")elseif MessageNum == 5debug.Notification("Attacker did a Target-Range Feint.")elseif MessageNum == 6debug.Notification("Attacker did a Flank-Range Feint.")elseif MessageNum == 7debug.Notification("Attacker did a Target-Flank-Range Feint!")endifif MessageNum2 == 1debug.Notification("With the Left hand!")endif


In Oblivion we could add strings together then play them as a message:

set StringVar1 to "Hello"
set StringVar2 to "World"

Messagebox"StringVar1 + StringVar2"

Is there a way to do this in Skyrim?
User avatar
Georgine Lee
 
Posts: 3353
Joined: Wed Oct 04, 2006 11:50 am

Post » Thu Jun 21, 2012 2:32 am

String s1 = 'text1'
String s2 = 'text2'
String s3 = s1 + s2

However, from your code, you could try to simplify your process with a formlist with all your messages (in esp, which is better than using debug.notification for player feedback), then pull the right one through the number of your message.
User avatar
Cat
 
Posts: 3451
Joined: Mon Dec 18, 2006 5:10 am

Post » Thu Jun 21, 2012 9:28 am

You could make a custom function...
Function FeintNotification(String asFeintType = "", String asHand = "")	Debug.Notification("Attacker did a " + sFeintType + "Feint" + asHand + ".")EndFunction
...then...
FeintNotification("Target-Flank")
...for "Attacker did a Target-Flank." or...
FeintNotification("Target-Flank", " with the left hand")
...for "Attacker did a Target-Flank with the left hand."

You could declare as many string variables as desired, then pass them instead of the text.
User avatar
Mark Hepworth
 
Posts: 3490
Joined: Wed Jul 11, 2007 1:51 pm

Post » Thu Jun 21, 2012 3:57 pm

This is just what I needed! thanks!

but String s1 = 'text1' did not compile however String s1 = "text1" did compile, (typo?)

So I was able to edit all that down to:


if attacker == playerref || me == playerref
debug.Notification("Attacker used " + Lm + FT)
endif

AWESOME!


String s1 = 'text1'
String s2 = 'text2'
String s3 = s1 + s2
User avatar
Daniel Holgate
 
Posts: 3538
Joined: Tue May 29, 2007 1:02 am

Post » Thu Jun 21, 2012 8:33 am

I am not feeling the love of these user functions yet. Unless they speed up the script if you move the function code outside of the local script (and no one has made that claim yet) I just have not found any reason to use them other than compartmentalization your script.

I did use User Functions a HECK of a lot in Oblivion because I had such massive scripts that I maxed out a my primary AI script. But Skyrim Lag will not allow that kind of thing now. Not for combat scripts anyway.

I may change my mind once I have a script chunk that I use over and over and over again. But so far that has not been the case.


You could make a custom function...
Function FeintNotification(String asFeintType = "", String asHand = "")	Debug.Notification("Attacker did a " + sFeintType + "Feint" + asHand + ".")EndFunction
...then...
FeintNotification("Target-Flank")
...for "Attacker did a Target-Flank." or...
FeintNotification("Target-Flank", " with the left hand")
...for "Attacker did a Target-Flank with the left hand."

You could declare as many string variables as desired, then pass them instead of the text.
User avatar
Richard Dixon
 
Posts: 3461
Joined: Thu Jun 07, 2007 1:29 pm


Return to V - Skyrim