1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  3. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  4. Fill your cup and take your pick among the maps best suited for this year's Hive Cup. The 6th Melee Mapping Contest Poll is up!
    Dismiss Notice
  5. Shoot to thrill, play to kill. Sate your hunger with the 33rd Modeling Contest!
    Dismiss Notice
  6. Do you hear boss music? It's the 17th Mini Mapping Contest!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Simple Prefix System V 0.0.3

Submitted by iam20842
This bundle is marked as pending. It has not been reviewed by a staff member yet.
Simple Prefix System V 0.0.3
* Allknowledge aka iam20842 [port gui idea to jass]
* Templarfaker aka aple [original idea: [GUI] Simple Name Prefixes]

Why i need?

Because you want get better organization in your object editor (units only for now) adding custom prefix like: T1_archer, T1_knigth, T2_archer and go on and dont wanna see this prefix in-game

With this system you can add a prefix to the unit in object editor (for organization) and get this prefix removed in-game

Who it works?

- First you need in your object editor a prefix over the unit name like this:
- In this case the separator is !, this mean, the prefix is KA or ME.


- Second you need to call the SPSSetRealName function to that unit, see SPSTest for an example

- Third enjoy!

- Four bug removed!


- The system check if the unit got the real name previously (checking if in group PREFIX_OFF_GROUP)
- IF NOT the system look in the unit name the separator defined in SPSSetPrefix with GUI or SPSSetPrefix with Arg
- Thein IF find the separator will set to true hasFindPrefix (bug: prevent change the 2nd ocurrency)

- Thein create a new string without the string after the separator
- Thein change the unit name to the real name
- Thein add this unit to a group (bug: prevent unit with nameSEPARATOR that cause crash)


Code (vJASS):


    string PREFIX_SEPARATOR = "!"
    group PREFIX_OFF_GROUP = CreateGroup()


library SPS

    function SPSSetPrefixArg takes string prefix returns nothing
        set PREFIX_SEPARATOR = prefix

    function SPSSetPrefixGUI takes nothing returns nothing
        set PREFIX_SEPARATOR = udg_SPSPrefix

    function SPSGetRealName takes string unitName, integer separatorPosition returns string
        local integer stringLength = StringLength(unitName)
        local string prefix
        local string remainString
        local string newUnitName

        set prefix = SubString(unitName, 0, separatorPosition)
        set remainString = SubString(unitName, separatorPosition+2, stringLength)

        call BJDebugMsg("|cffffff00Prefix|r: " + prefix)
        call BJDebugMsg("|cffffff00Separator|r: " + PREFIX_SEPARATOR)
        call BJDebugMsg("|cffffff00Real Name|r: " + remainString)

        return remainString

    function SPSGetSeparatorPosition takes string unitName returns integer
        local integer i = 0
        local integer stringLength = StringLength(unitName)
        local boolean hasFindPrefix = false
        local string tempString
        local integer separatorPosition

            set tempString = SubString(unitName, i, i + 1)
            if (tempString == PREFIX_SEPARATOR) then
                if (hasFindPrefix == false) then
                    set separatorPosition = i
                    set hasFindPrefix = true
            set i = i + 1
            exitwhen i == stringLength
        return separatorPosition

    function SPSSetRealName takes unit u returns nothing
        local string unitName
        local integer separatorPosition
        local string unitRealName

        if (IsUnitInGroup(u, PREFIX_OFF_GROUP) == true) then

            set unitName = GetUnitName(u)
            set separatorPosition = SPSGetSeparatorPosition(unitName)
            set unitRealName = SPSGetRealName(unitName, separatorPosition)

            call BlzSetUnitName(u, unitRealName)
            call GroupAddUnit(PREFIX_OFF_GROUP, u)
            set u = null



What is new?

-> GUI Friendly option
-> Rename new units, rename starting units
-> Set prefix function with or without parameters
-> Starting and Entering units get renamed inmediatly!, get examples in: SPSMapBegin and SPSUnitEnterMap triggers

-> GUI Now works better
-> Select unit, Mapbegin, UnitEnter options for the implementation of the systemd :D

PD: The other triggers are only instructions dont need to publish

Simple Prefix System V0.0.1 (Map)

Simple Prefix System V0.0.2 (Map)

Simple Prefix System V0.0.3 (Map)