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 havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  4. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  5. Dismiss Notice
  6. The Highway to Hell has been laid open. Come along and participate in the 5th Special Effect 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
Credits:
* 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?

EASY:
- 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.

[​IMG]

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

- Third enjoy!

- Four bug removed!

[​IMG]

EINSTHEIN:
- 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)



Triggers:

Code (vJASS):

globals

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

endglobals

library SPS

    function SPSSetPrefixArg takes string prefix returns nothing
        set PREFIX_SEPARATOR = prefix
    endfunction

    function SPSSetPrefixGUI takes nothing returns nothing
        set PREFIX_SEPARATOR = udg_SPSPrefix
    endfunction

    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
    endfunction

    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

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

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

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

            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
        endif
    endfunction

endlibrary

 

What is new?

0.0.2
-> 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


0.0.3
-> 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
Contents

Simple Prefix System V0.0.1 (Map)

Simple Prefix System V0.0.2 (Map)

Simple Prefix System V0.0.3 (Map)