Hi there, and welcome to the forums! Great to see that you are getting stuck in with Grimrock modding, it's a lot of fun.
1. SPAWNER SCRIPT
There are just a few problems in your script I think that are preventing it from working as expected. First of all, math.randomNumber does not exist, the method call should be math.random(3). This means that 'randomnum' is actually being assigned 'nil' and then nothing else is being called (if it even runs at all).
I would update your script as follows;
Code: Select all
function randomSpawn()
local random = math.random(3);
local spawnerId = "spawner_" .. random;
local spawner = findEntity(spawnerId);
if ( spawner == nil ) then
print("Could not find spawner:", spawnerId);
return;
end
spawner:activate();
end
To break this down, you get a random number from the set [1, 2, 3] and then you generate the desired spawnerId by concatenating the string "spawner_" with the number you generated (so spawnerId will be either spawner_1, spawner_2 or spawner_3). Then you find the entity in the level based on that id and store a reference to that entity in the local variable 'spawner'. Next up we just do a check to make sure that the spawner actually exists. This prevents a crash if something goes wrong at release, and prints a friendly error message when debugging. If the spawner exists, we activate it.
IMPORTANT: Note that you must also have a timer object with an interval of '3' that connects to your script. Remember to set the initial state of the timer to 'running' (or set it running via a pressure plate when you enter the room) otherwise your script will never be called.
2. CHAMPION TRAITS
Instead of 'setting' and 'unsetting' traits, think of it more as a list of traits that each individual champion has. So, instead of using setTrait you would actually use the methods addTrait()/removeTrait()/hasTrait(). They are all described on this page here:
http://www.grimrock.net/modding/scripting-reference/
You also need to call them using : instead of . like so...
Code: Select all
local champ = party:getChampion(1);
champ:addTrait("head_hunter");
3. ADDING MORE CHARACTERS
I don't know this one off the top of my head, but I think all 4 champions always exist in a party, it's just a case of enabling them or not. So, if you know that champion 2 is turned off, you should be able to do something like the following;
Code: Select all
local champ = party:getChampion(2);
if ( champ:getEnabled() == false ) then
champ:setName("Some Name");
-- Set Everything Else here
champ:setEnabled(true);
end
Hope this helps. Be sure to check out the scripting reference:
http://www.grimrock.net/modding/scripting-reference/, it's really useful!