Beginner modded using SE
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
Beginner modded using SE
Hello, I am a junior modded that wants to learn, problem is, my best way of learning is to see a detailed overlay of a mod then reverse engineer it, so wth that in mind, can someone tell me what is wrong with this script I wrote?
Intention: find relation of a selected race to myself or vice versa, then a message is to be sent with the results.
Results so far: I get a blank message.
001. $racerelation = [playership] -> get notoriety to race split
002. [playership] -> send incoming message: text = $racerelation temporary = [false]
003. Return null
Ps. Took picture but using phone, can't seem to upload it.[/img]
Intention: find relation of a selected race to myself or vice versa, then a message is to be sent with the results.
Results so far: I get a blank message.
001. $racerelation = [playership] -> get notoriety to race split
002. [playership] -> send incoming message: text = $racerelation temporary = [false]
003. Return null
Ps. Took picture but using phone, can't seem to upload it.[/img]
Try:
Code: Select all
$racerelation = [Playership] -> get notoriety to race [Split]
[Playership] -> send incoming message: text = $racerelation temporary = [false]
return null
... look into Ur script folder: there U´ll find a file named "x2script.xsl"Akalay wrote:Or is that to the displaying of code on this site?
... if you create a script and open it with internet explorer AND the file above is in the same folder, then U´ll get Ur script code displayed in the browser
... and to post code you have to post 2 so-called "tags" (in this case:
Code: Select all
-tags)
... everything you write between both [code]-tags will be displayed in those code-"frame"
// the second [code]-tag (= so-called "closing tag") must have a "/" in it before "code"
(code)... here some text etc.(/code)
// but the brackets must be "[" and "]"
Last edited by Guest on Sat, 15. Feb 14, 02:03, edited 1 time in total.
As the relation is an integer you might need to format it into a string first (e.g. $msg = sprintf '%s' $racerelation,null, null,null,null). Note that in X sprintf always uses %s regardless of datatype.
Last edited by Shimrod on Sat, 15. Feb 14, 02:47, edited 1 time in total.
This worked for me:
I recommend X-Studio rather than the ingame editor. The best intro to scripting is the MCSI handbook in the x2 bonus material download.
http://www.egosoft.com/download/x2/bonu ... ownload=97
Code: Select all
$notoriety = [Playership] -> get notoriety to race [Split]
$msg = sprintf: fmt='Relation=%s', $notoriety, null, null, null, null
[Playership] -> send incoming message: text = $msg temporary = [false]
return 0
http://www.egosoft.com/download/x2/bonu ... ownload=97
Via the ingame editor after selecting sprintf, I entered 'msg' to its first prompt. Select the first null and push enter, select <string> and enter 'Relation=%s'. Seriously, try X-Studio, its much easier. You can either free type it or double click the command from a menu to auto insert it.
Last edited by Shimrod on Sat, 15. Feb 14, 03:14, edited 1 time in total.
Only that you need to specify from race [Split] to race [Player] rather than vice versa. I use this same code in Custom Start to populate the notoriety menu so it demonstrably works.
Code: Select all
while $idx < $Amount
$Race = $Choice.Relations.Races[$idx]
$Notoriety = get notoriety from race $Race to race [Player]
append $Notoriety to array $Choice.Relations.Notorieties
inc $idx
end