Jump to content

Mod Creation - NVSE Array Assistance Needed


Johnathon

Recommended Posts

I'm working on a mod (or more specifically a script for a mod) that will better randomize songlists more like a normal media player where it won't repeat a song until every song in the playlist has already been played. For some reason, I can't get the NVSE array functions to work and I can't for the life of me figure out why it is.

 

This is the script (not complete, but should function-ish)

ScriptName JSTexasRangersRadioSCRIPT

short nStory;
short bDoTransition;
short NextSonga;
short nTracksPlayed;
short playNextNow;
short RandGen;
short TrackCount;
array_var aPlayedSongs


Begin _GameMode
	if  aPlayedSongs == 0;
		set TrackCount to 92;
		set playNextNow to 1
		let aPlayedSongs := Ar_Construct "array"
		set NextSonga to 1;
	endif
	if playNextNow == 0;                Not time to play the next track yet. Exit the script.
		return
	elseif playNextNow;   Time to randomly select the next track.
		if eval (Ar_Find NextSonga, aPlayedSongs) == Ar_BadNumericIndex; THIS IS THE LINE WITH ISSUES
			; It's not in the array. We need to add it.
			Ar_Append aPlayedSongs, NextSonga
			if eval Ar_Size aPlayedSongs == TrackCount
				Ar_Resize aPlayedSongs 0
			endif
		endif
		; Time to generate a random number.
		set RandGen to rand 1, TrackCount;
		if eval (Ar_Find RandGen, aPlayedSongs) == Ar_BadNumericIndex
			set playNextNow to 0
			set NextSonga to RandGen
		else
			return
		endif
	endif
End

I cannot get this script to compile. When I try to save it, it tells me that line 23 cannot be parsed.

 

Now, if I replace "NextSonga" with a number, then the compiler doesn't complain about the line anymore, but I need it to check if the variable's value exists in the array.

 

Any advice would be greatly appreciated.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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