
Ask a simple question, get a simple answer
- AndakRainor
- Posts: 674
- Joined: Thu Nov 20, 2014 5:18 pm
Re: Ask a simple question, get a simple answer
Is it possible to change the size of a 3D model via script (without creating any new model in blender) ? I just tried to use setWorldRotation with a matrix 4x4 containing a scaling factor, and did it on a tiny spider to make it grow slowly. Seems it does not work as the engine overrides frequently the values I set. Is there a simplier method to do it ? (Does it really fit as a "simple question" ???
)

Last edited by AndakRainor on Fri Jul 17, 2015 2:28 pm, edited 1 time in total.
Re: Ask a simple question, get a simple answer
AFAIK it is not possible to grow/shrink monsters in that way. The animations resizes them to their former dimensions. Also every animation wouldn't work because in a shrinked version the animation wouldn't lead the monster from square-center to square-center (where all animations have to start/end).
Re: Ask a simple question, get a simple answer
I am trying to script a function, that spawns several items randomly on the map.
My aim: I have 12 defined spots and 4 items. The items should be spread out randomly on random spots.
Sadly I cannot figure out, how to do that. I am sure, I am doing it far too complicate, but thats the only way I know how to do. (or better "don't know how to...")
All I get are several error messages and the preview doesn't start. Can anyone help me, please?
That's what I have:
My aim: I have 12 defined spots and 4 items. The items should be spread out randomly on random spots.
Sadly I cannot figure out, how to do that. I am sure, I am doing it far too complicate, but thats the only way I know how to do. (or better "don't know how to...")
All I get are several error messages and the preview doesn't start. Can anyone help me, please?
That's what I have:
Code: Select all
function AddQuestItem()
local tMap = spawn("treasure_map");
tMap.scrollitem:setScrollImage("mod_assets/textures/note_pic/asia_tiger.tga")
-- decide which item is spawned
local x = math.random(1,4)
if x == 1 then
local itemA = spawn("ancient_apparatus");
local itemB = tMap;
local itemC = spawn("globe_spherical_map");
local itemD = spawn("telescope");
end
if x == 2 then
local itemB = spawn("ancient_apparatus");
local itemC = tMap;
local itemD = spawn("globe_spherical_map");
local itemA = spawn("telescope");
end
if x == 3 then
local itemC = spawn("ancient_apparatus");
local itemD = tMap;
local itemA = spawn("globe_spherical_map");
local itemB = spawn("telescope");
end
if x == 4 then
local itemD = spawn("ancient_apparatus");
local itemA = tMap;
local itemB = spawn("globe_spherical_map");
local itemC = spawn("telescope");
end
-- decide where item is spawned
local spotA = math.random(1,5)
local spotB = math.random(1,7)
local spotC = math.random(1,7)
local spotD = math.random(1,7)
if spotA == 1 then
sx_barrel_chest_8.surface:addItem(itemA.item);
end
if spotA == 2 then
sx_barrel_chest_02_9.surface:addItem(itemA.item);
end
if spotA == 3 then
ratling1_5.monster:addItem(itemA.item);
end
if spotA == 4 then
ratling1_4.monster:addItem(itemA.item);
end
if spotA == 5 then
ratling1_2.monster:addItem(itemA.item);
end
if spotB == 1 then
spawn(itemB.item, 9, 23, 10, 2, 0) -- behind barrels
end
if spotB == 2 then
spawn(itemB.item, 9, 6, 18, 0, 0) -- under bush
end
if spotB == 3 then
spawn(itemB.item, 9, 26, 17, 3, 0) -- in water
end
if spotB == 4 then
spawn(itemB.item, 9, 3, 11, 2, 0)-- upper left
end
if spotB == 5 then
spawn(itemB.item, 9, 17, 15, 0, 0) -- under table
end
if spotB == 6 then
ratling3_6.monster:addItem(itemB.item);
end
if spotB == 7 then
ratling2_1.monster:addItem(itemB.item);
end
if spotC == 1 then
spawn(itemC.item, 9, 23, 10, 2, 0) -- behind barrels
end
if spotC == 2 then
spawn(itemC.item, 9, 6, 18, 0, 0) -- under bush
end
if spotC == 3 then
spawn(itemC.item, 9, 26, 17, 3, 0) -- in water
end
if spotC == 4 then
spawn(itemC.item, 9, 3, 11, 2, 0)-- upper left
end
if spotC == 5 then
spawn(itemC.item, 9, 17, 15, 0, 0) -- under table
end
if spotC == 6 then
ratling3_6.monster:addItem(itemC.item);
end
if spotC == 7 then
ratling2_1.monster:addItem(itemC.item);
end
if spotD == 1 then
spawn(itemD.item, 9, 23, 10, 2, 0) -- behind barrels
end
if spotD == 2 then
spawn(itemD.item, 9, 6, 18, 0, 0) -- under bush
end
if spotD == 3 then
spawn(itemD.item, 9, 26, 17, 3, 0) -- in water
end
if spotD == 4 then
spawn(itemD.item, 9, 3, 11, 2, 0)-- upper left
end
if spotD == 5 then
spawn(itemD.item, 9, 17, 15, 0, 0) -- under table
end
if spotD == 6 then
ratling3_6.monster:addItem(itemD.item);
end
if spotD == 7 then
ratling2_1.monster:addItem(itemD.item);
end
end
- AndakRainor
- Posts: 674
- Joined: Thu Nov 20, 2014 5:18 pm
Re: Ask a simple question, get a simple answer
Does it work better ?
PS: you had local variables not declared at the level you used them in your script, that would crash the preview. My script should do exactly what you wanted to if your variables were declared at the right place. But may be it is still a little too complicated to simply shuffle things (I kept the way you randomized items and destinations) ? If so I could also write something shorter and simpler, but it won't be the same random result 
Code: Select all
function addQuestItems()
local tmap = spawn("treasure_map");
tmap.scrollitem:setScrollImage("mod_assets/textures/note_pic/asia_tiger.tga")
local objects = randomOrder({spawn("globe_spherical_map"), spawn("telescope"), spawn("ancient_apparatus"), tmap})
local behin_barrels = {x=23, y=10, f=2, e=0, l=9}
local under_bush = {x= 6, y=18, f=0, e=0, l=9}
local in_water = {x=26, y=17, f=3, e=0, l=9}
local upper_left = {x= 3, y=11, f=2, e=0, l=9}
local under_table = {x=17, y=15, f=0, e=0, l=9}
objects = {
{objects[1], randomElement({sx_barrel_chest_8, sx_barrel_chest_02_9, ratling1_5, ratling1_4, ratling1_2})},
{objects[2], randomElement({behin_barrels, under_bush, in_water, upper_left, under_table, ratling3_6, ratling2_1})},
{objects[3], randomElement({behin_barrels, under_bush, in_water, upper_left, under_table, ratling3_6, ratling2_1})},
{objects[4], randomElement({behin_barrels, under_bush, in_water, upper_left, under_table, ratling3_6, ratling2_1})},
}
addItems(objects)
end
function randomOrder(tab)
local result = {}
for i = 1,#tab do table.insert(result, math.random(i), tab[i]) end
return result
end
function randomElement(tab) return tab[math.random(#tab)] end
function addItems(objects)
for i = 1,#objects do addItem(objects[i][1], objects[i][2]) end
end
function addItem(o, t)
if t.surface then
t.surface:addItem(o.item)
elseif t.monster then
t.monster:addItem(o.item)
else
o:setPosition(t.x, t.y, t.f, t.e, t.l)
end
end

Re: Ask a simple question, get a simple answer
AndakRainor, thanks a lot. Seem to work.
Funny thing is: If I have a look at your script I nearly understand nothing of what it does...
Funny thing is: If I have a look at your script I nearly understand nothing of what it does...

Re: Ask a simple question, get a simple answer
Hi guys
I hope, this could be easy. I need following object to be non-walkable like real wall and also it should display itself as a regular wall on the automap. What I need to define here ?
edit: the same goes for standrad castle_wall object
I hope, this could be easy. I need following object to be non-walkable like real wall and also it should display itself as a regular wall on the automap. What I need to define here ?
edit: the same goes for standrad castle_wall object
Code: Select all
defineObject{
name = "castle_wall_outside_01",
baseObject = "base_wall",
components = {
{
class = "Model",
model = "assets/models/env/castle_outside_wall_01.fbx",
dissolveStart = 6,
dissolveEnd = 8,
staticShadow = true,
},
{
class = "Occluder",
model = "assets/models/env/castle_wall_01_occluder.fbx",
},
},
minimalSaveState = true,
}
Re: Ask a simple question, get a simple answer
I am trying to close all doors named dungeon_secret_door_THOM_a_1 ..._2 .._3 etc.
I've tried this (and many other attempts) - nothing works.
Can anyone help, please??
I've tried this (and many other attempts) - nothing works.
Can anyone help, please??
Code: Select all
for e in party.map:allEntities() do
if e.name == "dungeon_secret_door_THOM_a_%d" then
e.door:close()
end
end
- AndakRainor
- Posts: 674
- Joined: Thu Nov 20, 2014 5:18 pm
Re: Ask a simple question, get a simple answer
Does "%d" work in this test ? If not you could use string.sub http://lua-users.org/wiki/StringLibraryTutorial
Re: Ask a simple question, get a simple answer
It doesn't seem to work. And I am looking already at the StringLibraryTutorial. I am unable to find a something that works. *sigh*
Re: Ask a simple question, get a simple answer
then you did not read the whole page!
%d is just the pattern to match a decimal number, it won't do anything special unless the string is passed to string.format or string.gmatch or string.pattern, etc
Code: Select all
for e in party.map:allEntities() do
if e.name:find("dungeon_secret_door_THOM_a_") then
e.controller:close()
end
end
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.