Thread: A Question of Templates
-
January 8th, 2013, 05:47 #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"...
endAliens.... Go fig?
-
January 8th, 2013, 05:50 #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?
-
January 8th, 2013, 17:22 #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?
-
January 9th, 2013, 17:05 #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?
-
January 9th, 2013, 17:07 #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?
-
January 9th, 2013, 17:08 #106
Sorry for the repeat. Glitch on user's end .
Aliens.... Go fig?
-
January 9th, 2013, 18:06 #107
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!
-
January 9th, 2013, 18:14 #108
O.K. Should it be in it's own function or not?
Aliens.... Go fig?
-
January 9th, 2013, 18:19 #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?
-
January 9th, 2013, 18:23 #110Originally Posted by S FergusonPrivate 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