Jump to content
Alloder.pro: about Allods with love
Search In
  • More options...
Find results that contain...
Find results in...

New program for writers

We turn from quantity to quality and tell you how we will supplement the Allods Team program with rewards in rubles.

More

The new Updater

Let us to introduce the new addon updater software and to share the details

Read more

Alloder 2.0

We have started the process of project evolve, and this relates not only, and not even primarily of the site's view

Read more

We can made WString functions


Guest Tycere
 Share

Recommended Posts

I have looked in the last weekend in the moddingdocuments for 2.0.9 (i think its the same like 2.0.8) and 3.0. I have found new functions for the EditLine. There are InsertTextAtCursorPos, DeleteCharAtCursorPos and BackspaceCharAtCursorPos. I tested it now on the russian client (3.0.00. 25), it works.

I created a function substring and an other named concat. With substring you can get a part of a given WString. With concat you can merge WStrings.

I create a copy of an existing EditLine, for example the ChatInput and use it for the functions. I tested it with an own EditLine, but i noticed that the TextStyle "multiline" is not working. Tabulator is also not working. I think the reason is the standard TextFilter on it.

Code:
-- ChatInput/ChatInput/Field/Input

local copyEditLine = mainForm:CreateWidgetByDesc(

stateMainForm:GetChildChecked("ChatInput", false)

:GetChildChecked("ChatInput", false)

:GetChildChecked("Field", false)

:GetChildChecked("Input", false)

:GetWidgetDesc())

copyEditLine:Show(false)

--- s: WString - The text that will be used for substring

--- index: number - The start index of the text

--- length: number - The maximum length of the result

--- example: Substring(userMods.ToWString("Hello World"), 6, 5)

---          This returns a WString like userMods.ToWString("World")

---          Substring(userMods.ToWString("Hello World"), 0, 5)

---          This returns a WString like userMods.ToWString("Hello")

function Substring(s, index, length)

  -- check input parameters

  if not s and not command.IsWString(s) then

    return nil

  end

  if index < 0 then

    index = 0

  end

  if length < 1 then

    return common.GetEmptyWString()

  end

  -- set the text to the copied editline

  copyEditLine:SetText(s)

  -- get the length of the given text

  local slength = copyEditLine:GetPosObjectCount()

  -- calculate resulting string size

  local resultLength = slength - index

  if resultLength > length then

    resultLength = length

  end

  -- if resultLength smaller than 1, give empty wstring

  if resultLength < 1 then

    return common.GetEmptyWString()

  end

  -- set position of copiesEditLine to begin

  copyEditLine:SetCursorPos(0)

  -- delete chars

  for i = 0, index-1 do

    copyEditLine:DeleteCharAtCursorPos()

  end

  -- calculate amount of chars to be deleted at the end of the text

  local charsToDelete = slength - index - resultLength

  -- set position to the length, then we can delete all chars at the end

  copyEditLine:SetCursorPos(resultLength) 

  for i = 0, charsToDelete-1 do

    copyEditLine:DeleteCharAtCursorPos()

  end

  return copyEditLine:GetText()

end

--- merging an array of wstring to one wstring

--- example: Concat(userMods.ToWString("A"), userMods.ToWString("b"), userMods.ToWString("C"))

---          This returns a WString like userMods.ToWString("AbC").

function Concat(...)

  copyEditLine:SetText(common.GetEmptyWString())

  for k, v in arg do

    if v and common.IsWString(v) then

      copyEditLine:InsertTextAtCursorPos(v)

end

  end

  return copyEditLine:GetText()

end

We can made more functions, that are only two examples.

Also I have found the common.ExtractWStringFromValuedText function. I think, it is possible to copy text from the chat, for example.

Link to comment
Share on other sites

I saw the common.ExtractWStringFromValuedText function, from the 3.0 test API that I was given, as well. I was very excited about this function, since it should allow us to fetch ValuedTexts that were "off-limits" before. Like description texts and the map texts (different means than my current FullMap methods). This'll allow us to rewrite the color/size/shadowing/outline and so on of (possibly even add to) pre-existing ValuedTexts without having to recreate them entirely or instinctively knowing the fields required.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

By using our site you agree to the Terms of Use