Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
chris123zugg
Adept


Joined: 23 Aug 2013
Posts: 227

PostPosted: Sun Sep 27, 2026 2:17 pm   

Found a way to change ALL priorities to a range you want!
 
You have to close the cmud using this xml, then open powershell and paste this block into it
Be sure to add your file path to the script below or it wont work.



$source = 'C:\Users\"Your file path to the xml"
$backup = 'C:\Users\"Your file path to the xml, for the backup"
$encoding = [System.Text.Encoding]::GetEncoding('ISO-8859-1')

if (Test-Path -LiteralPath $backup) {
throw "Backup already exists: $backup"
}

Copy-Item -LiteralPath $source -Destination $backup

$text = [System.IO.File]::ReadAllText($source, $encoding)
$values = [regex]::Matches($text, 'priority="(\d+)"') |
ForEach-Object { [int]$_.Groups[1].Value }

$minimum = ($values | Measure-Object -Minimum).Minimum
$maximum = ($values | Measure-Object -Maximum).Maximum

$evaluator = [System.Text.RegularExpressions.MatchEvaluator]{
param($match)

$old = [int]$match.Groups[1].Value
$new = 1 + [math]::Floor((($old - $minimum) * 99) / ($maximum - $minimum))

'priority="' + $new + '"'
}

$updated = [regex]::Replace($text, 'priority="(\d+)"', $evaluator)

[System.IO.File]::WriteAllText($source, $updated, $encoding)

$check = [regex]::Matches($updated, 'priority="(\d+)"') |
ForEach-Object { [int]$_.Groups[1].Value }

"Updated $($check.Count) priorities. Range: $(($check | Measure-Object -Minimum).Minimum)-$(($check | Measure-Object -Maximum).Maximum)"



i chose this for 1-100 because at some point there will be several triggers (upwards of 40) firing in the same round but starting at 1-100 gives these an alot faster immediacy and will reduce lag, at least in my addled brain it will
whelp, hope this is useful!
Code:
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net