Mudlet users

Hey figured I would start a thread for mudlet.

any know how I can put target health% in prompt?

Comments

  • IndiIndi Member Posts: 213 ✭✭✭
    If you want to add something to the prompt, create a trigger. Leave the pattern BLANK. Set the type to 'prompt'.

    Then put: cecho('<somecolour>WHATEVER')
    into the script.

    Obviously, adjust that to put useful info into it.
    If you want to replace the existing prompt, there are various ways to do it and you need to be more specific with your question.
  • KariryaKarirya Member Posts: 3
    I'm trying to write a multiline trigger that captures the whohere and sends an alert when a target is seen. I'm also trying to write one to know when a room is empty. I set these up as multiline triggers but they don't seem to fire properly.

    For the second trigger I'm doing:
    You can see these other people here:    [exact match]
    1 [line spacer]
    Health(.*)     [perl regex]

    Multi line and trigger is checked.
  • IndiIndi Member Posts: 213 ✭✭✭
    Would you feel comfortable using gmcp instead? 
    The following code populates a list of names present in the room (whohere.all)
    The 3 functions run when gmcp data is updated.

    The whohere.parse() function is not included as it sorts the names (alliers, enemies, unknowns) and displays them in my UI - not something useful to you. 

    I left it in there though so you can see where you'd put a similar function of your own - in your case testing each name against a list of enemies and then whatever your alert is.

    Also, a table remove tool I use in the whohere script, even though I don't remember why I use it here instead of just table.remove()

    Disclaimer: it's only a couple of days old and I'm not 100% sure I did the remove player function correctly. It seems to work but somehow doesn't seem quite right to me. 
    whohere = whohere or {}
    
    function whohere.players()
    	whohere.all = {}
    	names = gmcp.Room.Players
    	for _,player in ipairs(names) do
    		table.insert(whohere.all, player.name)
    	end
    	whohere.parse()
    end
    
    
    function whohere.addplayer()
    	names = gmcp.Room.AddPlayer
    
    	if not table.contains(whohere.all,names.name) then
    		table.insert(whohere.all, names.name)
    	end
    	whohere.parse()
    end
    
    function whohere.remplayer()
    	
    	table.removeall(whohere.all, gmcp.Room.RemovePlayer)
    	whohere.parse()
    end
    
    registerAnonymousEventHandler('gmcp.Room.Players', function() whohere.players() end )
    registerAnonymousEventHandler('gmcp.Room.AddPlayer', function() whohere.addplayer() end )
    registerAnonymousEventHandler('gmcp.Room.RemovePlayer', function() whohere.remplayer() end )
    --remove all instances of value V from indexed table T
    function table.removeall(t,v)
    	for i,val in ipairs(t) do
    		if v == val then
    			table.remove(t,i)
    		end
    	end
    end

  • KariryaKarirya Member Posts: 3
    thanks Indi!
  • AspieAspie Member Posts: 30 ✭✭
    Mardu said:
    Hey figured I would start a thread for mudlet.

    any know how I can put target health% in prompt?
    You need to use the gmod functions. When you log in, you need to use gmod.enableModule.
    <code>  gmod.enableModule("any_name_you_want", "IRE.Targets")
    end
    --disable first in case you've logged out so when you enable it it works (there may be a proper to do this)<br>function enableIRETargets()<br> gmod.disableModule("any_name_you_want", "IRE.Targets")<br>


    After that, you need to tell the server what you want to target.
    function requestTargetFromServer(targetID)<br>  sendGMCP(string.format([[IRE.Target.Set "%s"]], targetID))<br>end<br>

    Once the server gets back to you, which is typically the prompt following your request, you will have the following table available: gmcp.IRE.Target.Info

    You'll need to make a prompt trigger to have it echo on your prompt. You could simply run the following function on a prompt trigger:
    function echoTargetHealthPercentOnPrompt()<br> local target = gmcp.IRE.Target.Info<br><br> --if the target is still alive<br> if target.id ~= "" then<br>   echo(string.format(": Target: %s (%s%s)", target.id, target.hpperc, "%"))<br> end<br>end<br>

    So, in order:
    1. enableIRETargets() after you log in
    2. requestTargetFromServer(targetID) when you've picked a target
    3. have a prompt trigger run echoTargetHealthPercentOnPrompt()
    You'll of course want to use these in conjunction with aliases, triggers, or events. Whatever you have set up!
  • VadiVadi Member Posts: 51 ✭✭
    There's a very handy right-click Format All option for code - when you're writing new code, try it as a habit to keep your code tidy
  • AtalkezAtalkez Member Posts: 59 ✭✭✭
    Aspie said:
    function echoTargetHealthPercentOnPrompt()<br> local target = gmcp.IRE.Target.Info<br><br> --if the target is still alive<br> if target.id ~= "" then<br>   echo(string.format(": Target: %s (%s%s)", target.id, target.hpperc, "%"))<br> end<br>end
    I made my own, but had a question about this. target.id doesn't clear when the mob dies, so I'm perpetually stuck with the target % it died at on my prompt. Suggestions?
  • AspieAspie Member Posts: 30 ✭✭
    Atalkez said:
    Aspie said:
    function echoTargetHealthPercentOnPrompt()<br> local target = gmcp.IRE.Target.Info<br><br> --if the target is still alive<br> if target.id ~= "" then<br>   echo(string.format(": Target: %s (%s%s)", target.id, target.hpperc, "%"))<br> end<br>end
    I made my own, but had a question about this. target.id doesn't clear when the mob dies, so I'm perpetually stuck with the target % it died at on my prompt. Suggestions?
    You could write an event handler for gmcp.Char.Items.List.Remove.

    function gmcpItemRemoved()<br>  local item = gmcp.Char.Items.Remove<br><br>  if item.location == "room" then<br>    if item.item.id == gmcp.IRE.Target.Set<br>      targetExists = false<br>    end<br>  end<br>end<br>

    You could set targetExists = true when setting a new target and use the above event handler know when the target dies.

    I'm not certain why your target.id isn't being cleared, though. For me, gmcp.IRE.Target.Info.id is equal to "" right after my target dies and I just check against that.

    If you're having trouble, though, I'd definitely recommend implementing an event handler as mentioned above since it's the most reliable way to know if your target has died or left the room.
  • MarduMardu Member Posts: 10
    Thank you both have it running smooth now.
  • JonathinJonathin Member Posts: 18
    edited December 2018
    So, someone asked me how to do a gradual color shift and I honestly have no idea. I come to ask for help. How would I get something to shift colors gradually so that the shift takes about a second to go from (arbitrary colors) blue (0,0,255) to yellow (250, 255, 0)?

  • VadiVadi Member Posts: 51 ✭✭
    See http://doc.qt.io/qt-5/stylesheet-reference.html "Specifies gradient fills. There are three types of gradient fills:" section, you can find examples of gradients to start with there.


  • tysandrtysandr Member Posts: 90 ✭✭✭
    You're probably thinking of this:

    http://doc.qt.io/qt-5/qtquick-animation-example.html

    Seems neat, did not know Qt had animation.
    vote ∘ Explore Nexus mods for Starmourn & Achaeandb for Nexus

  • ekaryekary Member Posts: 85 ✭✭✭
    So I am having troubles with cechoLink().  Let's say I have tables set up like this:

    myTable = {
         entryOne = {
           "some",
           "stuff",
         },
        entryTwo = {
           "another",
           "thing",
         },
    }

    Now if I wanted to write something that would print entryOne and entryTwo as echo links that would display their respective values, how would I do that? The closest I came was to get them all to link to the exact same thing. Now my brain is fried and it's time to seek help!
  • kamyrkamyr Member Posts: 55 ✭✭
    Just wanted to note that I could not get the sendGMCP method of setting IRE.Target to work, but enabling the gmod then using the settarget (blah) server alias did the trick.

  • IndiIndi Member Posts: 213 ✭✭✭
    ekary said:
    So I am having troubles with cechoLink().  
    ...
     print entryOne and entryTwo as echo links that would display their respective values, 

    Not entirely sure what you're after, nor where you're going wrongm but a little tip when playing around with echoLink (and other instances where you need to define a function as a string) is to use string.format to keep it much more readable, and obvious when you're missing quotes, or have too many.

    The other gotcha in a script like this is to remember that local vars in the loop structure will not be available to the clickable link function thingy. So you can't use display(list) in the following piece of code, you need to reference myTable directly, as it is global.

    The following works when I paste it into my own scripts folder.
    myTable = {
         entryOne = {
           "some",
           "stuff",
         },
        entryTwo = {
           "another",
           "thing",
         },
    }
    
    for tname,list in pairs(myTable) do
      local cmd = string.format([[display(myTable['%s'])]], tname)
      cechoLink('\nmyTable.' .. tname, cmd, 'Click to display the table.', true)
    end

Sign In or Register to comment.