FG Spreadshirt Swag
Page 11 of 28 First ... 91011121321 ... Last
  1. #101
    If I was to turn the snippet into a function (it is rather handy) would I write:

    function(type, notHereThenAdd)

    ...insert code here with type taking the place of "alignment" and notHereThenAdd in the place of "Neutral"...

    end
    Aliens.... Go fig?

  2. #102
    If I was to turn the snippet into a function (it is rather handy) would I write:

    function(type, notHereThenAdd)

    ...insert code here with type taking the place of "alignment" and notHereThenAdd in the place of "Neutral"...

    end

    with two string arguments?
    Aliens.... Go fig?

  3. #103
    There is one thing I've noticed. The right-hand icons (the ones we all love and adore ) don't give much room to put anything else in there while the window is minimized; when it's maximized it almost looks vacant. Drawing new icons isn't really a problem, save that it interferes with more data from the ruleset than I'm willing to make. Is there an option for scaling the size of icons (I assume the code for placement is somewhere in the campaign section), or will I just have to do it manually?
    Aliens.... Go fig?

  4. #104
    Alright I've got an alterState function, that whips through an NPC's children. unfortunately I can't get it to recognize lists, ir to insert items, within them. the code is:

    function alterType(type, notHereAdd)

    -- alters type searched for in an NPC. If the type isn't present, add it
    -- Set nodeNPC to the top of the NPC database & set intial type to the empty == -- -- string.
    l
    ocal nodeNPC = window.getDatabaseNode();
    local nType = "";


    -- cycle through nodeNPC looking for type

    for vKey,vNode in pairs(nodeNPC.getChildren()) do

    if vNode.getValue() ~= nil then
    -- Start Looping through the children of the current NPC
    local msg = {text = "Key value = " .. vKey .. ". node value " .. vNode.getValue()};
    console(msg);

    -- Scored a hit on type looked for so get value. Otherwise fall through to catch-all.

    if vKey == type then
    if vNode.getValue() == "" or " " then
    vNode.setValue(notHereAdd);
    end
    nType = vNode.getValue();
    break;
    end
    end
    end

    -- Catch-all. Haven't run into type so add it.

    if type == "" then
    local nodeAlignmnent = nodeNPC.createChild(type, notHereAdd);
    nodeAlignment.setValue(notHereAdd);
    end
    end


    Is there any way of altering this so instead of turning the type into a value, (it currently if encountering "Large Animal" will override it with "Undead" as it's coded to do) find a way of adding the result to a list (say, "Large Undead Animal"). I also need a way of changing stat values by means of modifiers (+1, -1, etc.) Am I asking too much of this function or can it be tweaked some more to give me the functionality I need.
    Aliens.... Go fig?

  5. #105
    Alright I've got an alterState function, that whips through an NPC's children. unfortunately I can't get it to recognize lists, ir to insert items, within them. the code is:

    function alterType(type, notHereAdd)

    -- alters type searched for in an NPC. If the type isn't present, add it
    -- Set nodeNPC to the top of the NPC database & set intial type to the empty == -- -- string.

    local nodeNPC = window.getDatabaseNode();
    local nType = "";


    -- cycle through nodeNPC looking for type

    for vKey,vNode in pairs(nodeNPC.getChildren()) do

    if vNode.getValue() ~= nil then
    -- Start Looping through the children of the current NPC
    local msg = {text = "Key value = " .. vKey .. ". node value " .. vNode.getValue()};
    console(msg);

    -- Scored a hit on type looked for so get value. Otherwise fall through to catch-all.

    if vKey == type then
    if vNode.getValue() == "" or " " then
    vNode.setValue(notHereAdd);
    end
    nType = vNode.getValue();
    break;
    end
    end
    end

    -- Catch-all. Haven't run into type so add it.

    if type == "" then
    local nodeAlignmnent = nodeNPC.createChild(type, notHereAdd);
    nodeAlignment.setValue(notHereAdd);
    end
    end


    Is there any way of altering this so instead of turning the type into a value, (it currently if encountering "Large Animal" will override it with "Undead" as it's coded to do) find a way of adding the result to a list (say, "Large Undead Animal"). I also need a way of changing stat values by means of modifiers (+1, -1, etc.) Am I asking too much of this function or can it be tweaked some more to give me the functionality I need.
    Aliens.... Go fig?

  6. #106
    Sorry for the repeat. Glitch on user's end .
    Aliens.... Go fig?

  7. #107
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    You're going to have to use LUA string handling techniques to do this.

    See the final section of the example code I gave in post #31 - this uses "string.find" to see if "amorphous" is in the string of the DB node and then concatenates (using "..") amorphous to the end of the string if it is not found.

    There are lots of different ways to split up string, replace, concatenate, etc. - check the LUA documentation for string handling techniques.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  8. #108
    O.K. Should it be in it's own function or not?
    Aliens.... Go fig?

  9. #109
    Also, when it adds a value that isn't there such as the Always Neutral case, you have to close the window and open it again to see the added alignment. Whereas in non-functionally it updates the display. Any help on why?
    Aliens.... Go fig?

  10. #110
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    Quote Originally Posted by S Ferguson
    O.K. Should it be in it's own function or not?
    Doesn't matter - it depends how you want to design it; if the code will be used by other functions and if you don't need access to local variables in the function you call it from.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
STAR TREK 2d20

Log in

Log in