Mudlet Scripting

1121314151618»

Comments

  • AnetteAnette Member Posts: 789 ✭✭✭
    edited July 5
    Don't really feel like belabouring the point since people might be on a non-current mudlet.  So for those who aren't:
    function toboolean(value)
       if (value==true) then
          -- why are you feeding bools to something named toboolean?
          return true
       elseif (value==false) then
          -- why are you feeding bools to something named toboolean?
          return false
       elseif (tonumber(value)~=nil) then
          if (tonumber(value)>0) then
             return true
          else
             return false
          end
       else
          return false
       end
    end
    

    It was a bit confusing to me we have tostring and tonumber but not toboolean.  It would have been one of the first things I'd've added with booleans when they added a boolean type.

    [edit]: Pet peeve: WSIWYG editors that ... aren't at all what you see is what you get.

    image
  • AysariAysari Member Posts: 152 ✭✭✭
    edited July 28
    I prefer this, personally.
    function toBoolean(s)	
       local st = (type(s) == "string" and string.lower(s) or s)
       if type(st) == "number" and st >= 1 then st = "1" end
       if st == true or st == "true" or st == "on" or st == "1" or st == "yes" or st == "yep" or st == "y" then
          return true
       else
          return false
       end
    end
    If a number greater than (or equal to) 1 is given, then it returns true. If what you pass under toBoolean(whatever) is true, "true" or anything really that's a 'positive answer' then it will return true. Anything else and it'll return false. I can parse pretty much everything my system uses through it, and it'll work perfectly.

    image
    Sarrius
  • VadiVadi Member Posts: 28 ✭✭
    I don't have a toBoolean function in my system at all... there's a reason it's not in Lua's stdlib! Here's how Svof captures balance: https://github.com/svof/svof/blob/master/raw-svo.controllers.lua#L1248
    Rokas
  • GjarrusGjarrus Member, Beta Testers Posts: 456 ✭✭✭✭
    ^repeat(?:| (\d+) (.*))$
    
    
    repeatTheThing = function()
    
    if repeater.active then
    repeater.timer = tempTimer(repeater.time,[[send(repeater.action) repeatTheThing()]])
    end
    
    end
    
    if not repeater then repeater = {} end
    if not repeater.active then repeater.active = false end
    
    if matches[2] then
    
     repeater.time = tonumber(matches[2])
     repeater.action = matches[3]
    end
     
    if not repeater.active then
      send(repeater.action)
      repeater.timer = tempTimer(repeater.time,[[send(repeater.action) repeatTheThing()]])
    	repeater.active = true
    else
      repeater.timer = nil
    	repeater.active = false
    end
    

    repeat time action to do the action every at that interval. repeat to stop and start it. You might want to add echoes.
  • EdonEdon Member Posts: 1
    Could I get someone to point me in the direction of a defenses manager, or is there one that I am somehow missing?

    Just trying to figure this whole defenses-on-queue thing.
  • AnetteAnette Member Posts: 789 ✭✭✭
    Vadi said:
    I don't have a toBoolean function in my system at all... there's a reason it's not in Lua's stdlib! Here's how Svof captures balance: https://github.com/svof/svof/blob/master/raw-svo.controllers.lua#L1248
    The actual reason is probably "they only recently actually added a boolean type and didn't add the support functions like that in when they did."
    image
  • VadiVadi Member Posts: 28 ✭✭
    That might be true too!

    Also, found this interesting tidbit while looking up the history of Lua:

    It turned out that Bret Mogilefsky was the lead programmer on Grim Fandango, the main adventure game LucasArts released in 1997. In another message he told us that "A TREMENDOUS amount of this game is written in Lua" (his emphasis). This first use of Lua in a game attracted the attention of many game developers around the world to the language.



    Wyll
  • AhruizAhruiz Member Posts: 4
    edited October 21
    Do not know if this question has been answered before. I am trying to track purge blood and focus. Both of these sometimes cure afflictions with 3P cure messages. I need a way to have a trigger activate one piece of code if the following line is a 3P cure which I think is easy, just use a chain of length 1 on the general message and code in the two or three 3P cure messages. What I do need help with is finding a way to have a piece of code trigger only if there is no 3P affliction message after it. How can I do that?

    Edit: Can I do something like: Write a multiline AND trigger like this:
    Line 1) ^A look of extreme focus crosses the face of (\w+).$
    Line 2) ^(.*)$

    And then make each 3P affliction message an if conditional, so if none of them are met than the other piece of code for non-3P messages fires?
  • RycRyc Member, Beta Testers Posts: 23 ✭✭
    3p triggers can be tracked directly using the 3p message in a single line trigger. You can then do something like 
    Line 1) ^A look of extreme focus crosses the face of (\w+).$  Perl Regex
    Line 2) return isPrompt() Lua Function
    This trigger only fires if the line immediately after the cure is your prompt, meaning that 3p Triggers don't fire it's curing.
    AhruizAodanVadi
  • AodanAodan Member Posts: 114 ✭✭✭
    edited October 21
    Ryc said:
    3p triggers can be tracked directly using the 3p message in a single line trigger. You can then do something like 
    Line 1) ^A look of extreme focus crosses the face of (\w+).$  Perl Regex
    Line 2) return isPrompt() Lua Function
    This trigger only fires if the line immediately after the cure is your prompt, meaning that 3p Triggers don't fire it's curing.
    Thanks so much for that, seriously. When I get bored at work I like to think about the changes I want to make to my system and the rewrite I want to do, and the problem I was running in to was figuring a way to work around having to remove 2 affs because of the 3ps. The changes I was going to make were to be a little more efficient at non 3ps. This idea will help complete the idea. 
  • AhruizAhruiz Member Posts: 4
    I think that did it for me, thank @Ryc. My code should look like this, correct?
    Trigger for non-3p cured:
    Line 1) ^A look of extreme focus crosses the face of (\w+).$ --Perl Regex-- 
    Line 2) return isPrompt() --Lua Function-

    Trigger for 3p cured - in this case, Stupidity
    Line 1) ^A look of extreme focus crosses the face of (\w+). (\w+)'s expression no longer looks so vacant. --Perl Regex--



  • RycRyc Member, Beta Testers Posts: 23 ✭✭
    The 3p trigger would look like 
    ^(\w+)'s expression no longer looks so vacant\.$ Perl Regex
    There's no need for the focus line, or really any curetype line for a 3p cure, just trigger off of the 3p message itself. (the exception being if you want to track what the last of each curetype cured is)
  • AnetteAnette Member Posts: 789 ✭✭✭
    I wouldn't say there's no need at all, it can rule out illusions and the like, but the last time I saw someone use illusions in combat was a couple IRL years ago.  That said you can get by without it.
    image
  • DimitriDimitri Somewhere coldMember Posts: 219 ✭✭✭
    I'm not sure how you could implement this, but for some lulz on your end.

    http://doom.wikia.com/wiki/Status_bar_face_hysteresis

    Seems like the doomguy status faces could be useful as a visual representation of how you're doing. Or at least entertaining.
Sign In or Register to comment.