It works really well in a cemeteryDrakkan wrote:advanced digging, impressive. thanks a lotninjanerdbgm wrote:Hey Drakkan, I modified the dig random script a bit for use in my own mod. Here's the code I ended up going with:
By adding the target (c) to the function, the script no longer needs to be on top of the floor_trigger, and
multiple floor_triggers can point to the same function.
Code: Select all
items = {"baked_maggot","boiled_beetle","blooddrop_cap","falconskyre","mudwort","skull","potion_energy","potion_cure_poison","potion_cure_disease","potion_greater_energy","potion_greater_healing","potion_healing","potion_shield","potion_resurrection","bread","cheese","borra","mole_jerky","warg_meat"} -- Give the player a small chance to dig up more than one item, or no item at all -- itemchance = {"0","1","1","1","1","1","1","1","1","1","1","1","1","1","2","2","2","2","3"} function digRandomStuff(c) local itemamt = itemchance[math.random(1,#items)] if itemamt == "0" then hudPrint("You found nothing...") end for i=1,itemamt do local item = math.random(1,#items) item = items[item] local j = c.go:spawn(item) playSound("secret") -- You can add the code to add text to notes/letter or whatever other component necessity here -- hudPrint("You found "..getArticle(j.item:getUiName())..j.item:getUiName().."!") end -- You can add code to give xp here -- end --[[ I got really sick of seeing "You got a Energy Potion!" or "You got a Cheese!", so I decided to generate the articles. The following code finds out what item was dug up and returns the proper article, or no article at all. --]] function getArticle(name) local fletter = name:sub(1,1) -- Get the first letter of the item's UI name fletter = string.byte(fletter,1) -- Convert it to ASCII if fletter < 97 then fletter = fletter + 32 end -- Convert it to lowercase. if string.char(fletter) == "a" or string.char(fletter) == "e" or string.char(fletter) == "i" or string.char(fletter) == "o" or string.char(fletter) == "u" then return "an " elseif name:sub(1,3) == "Fal" or name:sub(1,3) == "Mud" or name:sub(1,3) == "Bre" or name:sub(1,3) == "Che" or name:sub(1,3) == "Bor" or name:sub(1,3) == "Mol" or name:sub(1,3) == "War" then return "" else return "a " end end
Few questions - All solved
-
- Posts: 28
- Joined: Tue Nov 04, 2014 6:53 pm
Re: Few questions - All solved
Re: Few questions - All solved
do i need to modify any bit of this for it to work or can i literally just paste it in a LUA and attach a trigger to itninjanerdbgm wrote:Hey Drakkan, I modified the dig random script a bit for use in my own mod. Here's the code I ended up going with:
By adding the target (c) to the function, the script no longer needs to be on top of the floor_trigger, and
multiple floor_triggers can point to the same function.
Code: Select all
items = {"baked_maggot","boiled_beetle","blooddrop_cap","falconskyre","mudwort","skull","potion_energy","potion_cure_poison","potion_cure_disease","potion_greater_energy","potion_greater_healing","potion_healing","potion_shield","potion_resurrection","bread","cheese","borra","mole_jerky","warg_meat"} -- Give the player a small chance to dig up more than one item, or no item at all -- itemchance = {"0","1","1","1","1","1","1","1","1","1","1","1","1","1","2","2","2","2","3"} function digRandomStuff(c) local itemamt = itemchance[math.random(1,#items)] if itemamt == "0" then hudPrint("You found nothing...") end for i=1,itemamt do local item = math.random(1,#items) item = items[item] local j = c.go:spawn(item) playSound("secret") -- You can add the code to add text to notes/letter or whatever other component necessity here -- hudPrint("You found "..getArticle(j.item:getUiName())..j.item:getUiName().."!") end -- You can add code to give xp here -- end --[[ I got really sick of seeing "You got a Energy Potion!" or "You got a Cheese!", so I decided to generate the articles. The following code finds out what item was dug up and returns the proper article, or no article at all. --]] function getArticle(name) local fletter = name:sub(1,1) -- Get the first letter of the item's UI name fletter = string.byte(fletter,1) -- Convert it to ASCII if fletter < 97 then fletter = fletter + 32 end -- Convert it to lowercase. if string.char(fletter) == "a" or string.char(fletter) == "e" or string.char(fletter) == "i" or string.char(fletter) == "o" or string.char(fletter) == "u" then return "an " elseif name:sub(1,3) == "Fal" or name:sub(1,3) == "Mud" or name:sub(1,3) == "Bre" or name:sub(1,3) == "Che" or name:sub(1,3) == "Bor" or name:sub(1,3) == "Mol" or name:sub(1,3) == "War" then return "" else return "a " end end
-
- Posts: 28
- Joined: Tue Nov 04, 2014 6:53 pm
Re: Few questions - All solved
If you want those same items that I used, you can just copy/paste.
If you want to use other items, you'll have to change the getArticle function to reflect it, or remove that function altogether and go with a generic hudPrint (like hudPrint("You got a thing!")).
Don't forget to make your floor_trigger set to triggeredbyDigging only, and tick disableSelf.
If you want to use other items, you'll have to change the getArticle function to reflect it, or remove that function altogether and go with a generic hudPrint (like hudPrint("You got a thing!")).
Don't forget to make your floor_trigger set to triggeredbyDigging only, and tick disableSelf.
Re: Few questions - All solved
No big matter, can give you quite exact assets ( Begining to know how all assets runs ) Just running with "get" structures and mostly the blender importer from bitcpy ^^Drakkan wrote:its kind of interesting that model is not animated, but I am ok even with that as for now, because its just background. As for water component I am missing asset, but once released I think it will be no problem just to modify as you stated. Thanks a lot, definitely will be credited as well
For the water_surface :
Code: Select all
defineObject{
name = "user_water_surface",
base_object = "water_surface",
components = {
{
class = "WaterSurface",
fogColor = vec(0.021,0.045,0.13,0),
fogDensity = 0.2,
-- There you'll have to modify by -1.4 or 1.4, as you wish
planeY = -0.4,
reflectionColor = vec(0.693,0.81,0.9,0),
refractionColor = vec(1,1,1,0),
},
{
class = "WaterSurfaceMesh",
material = "water_surface_calm",
underwaterMaterial = "water_surface_underwater",
},
},
placement = "floor",
editorIcon = 264,
}
Code: Select all
defineObject{
name = "user_Oak_test",
base_object = "forest_oak_cluster",
components = {
{
class = "Model",
model = "assets/models/env/forest_oak_cluster.fbx",
-- Give the offset that you want :D
offset = vec(0,0,0,0),
},
{
class = "Animation",
currentLevelOnly = true,
playOnInit = "sway",
loop = true,
animations = {
sway = "assets/animations/env/forest_oak_cluster_idle.fbx",
},
},
{
class = "Obstacle",
},
{
class = "ProjectileCollider",
offset = vec(0,1.5,0,0),
size = vec(2.7,3,2.7,0),
},
},
placement = "floor",
editorIcon = 168,
}
Last edited by Doridion on Sat Nov 15, 2014 12:31 am, edited 5 times in total.
Re: Few questions - All solved
hmm editor crashing when trying to place this object on the mapDoridion wrote:No big matter, can give you quite exact assets ( Begining to know how all assets runs ) Just running with "get" structures and mostly the blender importer from bitcpy ^^Drakkan wrote:its kind of interesting that model is not animated, but I am ok even with that as for now, because its just background. As for water component I am missing asset, but once released I think it will be no problem just to modify as you stated. Thanks a lot, definitely will be credited as well
For the water_surface :
For the Water_surface, i'm not absolutly sure because there's some elements i don't have acces with "get" script or the blender importer, but seems running good in the editor.Code: Select all
defineObject{ name = "user_water_surface", base_object = "water_surface", components = { { class = "WaterSurface", fogColor = vec(0.021,0.045,0.13,0), fogDensity = 0.2, -- There you'll have to modify by -1.4 or 1.4, as you wich planeY = -0.4, reflectionColor = vec(0.693,0.81,0.9,0), refractionColor = vec(1,1,1,0), }, { class = "WaterSurfaceMesh", material = "water_surface_calm", underwaterMaterial = "water_surface_undewater", -- Seems having a getWaterLevel here also, but don't have setWaterLevel, so don't add item } } editorIcon = 264, }
[string "GameObject.lua"]:0: unknown placement: nil
stack traceback:
[C]: in function 'error'
[string "GameObject.lua"]: in function 'initTransform'
[string "GameObject.lua"]: in function 'initComponents'
[string "Arch.lua"]: in function 'spawn'
[string "DungeonEditor.lua"]: in function 'addObjectTool'
[string "DungeonEditor.lua"]: in function 'mapView'
[string "DungeonEditor.lua"]: in function 'update'
[string "Grimrock.lua"]: in main chunk
Re: Few questions - All solved
Yep, what i excpected ^^ Simply add placement = "floor", just before the editorIcon and that's it
I edit the code in my previous post, to add it, then you can copy/paste it ( forget a spare to a line, also added )
I edit the code in my previous post, to add it, then you can copy/paste it ( forget a spare to a line, also added )
Re: Few questions - All solved
ok now editor not crashing down but error appearing --Doridion wrote:Yep, what i excpected ^^ Simply add placement = "floor", just before the editorIcon and that's it
I edit the code in my previous post, to add it, then you can copy/paste it ( forget a spare to a line, also added )
bad argument setMaterial (material expected, got nil)
stack traceback in function setmaterial
string watersurfacemesh.lua:in function onRender
Re: Few questions - All solved
Rah ..... ok, not habing enought time to test with my pregnant wife, but make a break and test since it's ok. Sorry for waiting ((
Edit : RAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGE !!!!!!! .... can't be stupid anymore !!! I'm a dumb stupid guy (( Sorry, really sorry drakkan (( I forgot a simple "r" in "underwater" for underwater material ..... .... ..... I correct it in the previous code and i assume that i'm really stupid ((
Now that's working well ... very sorry ((
Edit 2 : Drakkan, i find something who'll interest you I was false we i though that planeY was the water level. Here are the modifications you can have. I'm actually working on disabling the water effect if the water is UNDER party's head.
Edit : RAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGE !!!!!!! .... can't be stupid anymore !!! I'm a dumb stupid guy (( Sorry, really sorry drakkan (( I forgot a simple "r" in "underwater" for underwater material ..... .... ..... I correct it in the previous code and i assume that i'm really stupid ((
Now that's working well ... very sorry ((
Edit 2 : Drakkan, i find something who'll interest you I was false we i though that planeY was the water level. Here are the modifications you can have. I'm actually working on disabling the water effect if the water is UNDER party's head.
Code: Select all
defineObject{
name = "user_water_surface",
base_object = "water_surface",
components = {
{
class = "WaterSurface",
fogColor = vec(0.021,0.045,0.13,0),
fogDensity = 0.2,
planeY = -0.4,
reflectionColor = vec(0.693,0.81,0.9,0),
refractionColor = vec(1,1,1,0),
},
{
class = "WaterSurfaceMesh",
-- There you'll have to modify the Y offset to up/down the water level
offset = vec(0,0,0,0),
material = "water_surface_calm",
underwaterMaterial = "water_surface_underwater",
},
},
placement = "floor",
editorIcon = 264,
}
Re: Few questions - All solved
I got to your answer now, thanks man. Elevation is working perfectly, splendid ! only problem is with water material surface, which is hardly visible in dungeon :/ do you know any other surface names so I could try if some is looking better ?Doridion wrote:Rah ..... ok, not habing enought time to test with my pregnant wife, but make a break and test since it's ok. Sorry for waiting ((
Edit : RAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGE !!!!!!! .... can't be stupid anymore !!! I'm a dumb stupid guy (( Sorry, really sorry drakkan (( I forgot a simple "r" in "underwater" for underwater material ..... .... ..... I correct it in the previous code and i assume that i'm really stupid ((
Now that's working well ... very sorry ((
Edit 2 : Drakkan, i find something who'll interest you I was false we i though that planeY was the water level. Here are the modifications you can have. I'm actually working on disabling the water effect if the water is UNDER party's head.
Code: Select all
defineObject{ name = "user_water_surface", base_object = "water_surface", components = { { class = "WaterSurface", fogColor = vec(0.021,0.045,0.13,0), fogDensity = 0.2, planeY = -0.4, reflectionColor = vec(0.693,0.81,0.9,0), refractionColor = vec(1,1,1,0), }, { class = "WaterSurfaceMesh", -- There you'll have to modify the Y offset to up/down the water level offset = vec(0,0,0,0), material = "water_surface_calm", underwaterMaterial = "water_surface_underwater", }, }, placement = "floor", editorIcon = 264, }
Re: Few questions - All solved
I've tested again, and seen two things.
1 - If i'm far of the water ( height +1 for example ), reflection seems having no issue. ( you can find below my test )
2 - If i'm approaching and place in the same level or really near the water, i've got the same issue than you.
I think about the reflection/refraction must be adapted with the height offset ( Y ). Or simply more, there's an issue with shader rendering.
I'm actually working on the sort of all johnW's excellent work for the primal assets definition ( really heavy work ... more than 33k lines to sort, sort, and sort again to be correctly understandable for all modders ). I finded all the water effects and will analyse them to give you an as quick as possible answer.
Sorry for late, even i'll answer, yep, i'll answer xD
1 - If i'm far of the water ( height +1 for example ), reflection seems having no issue. ( you can find below my test )
2 - If i'm approaching and place in the same level or really near the water, i've got the same issue than you.
I think about the reflection/refraction must be adapted with the height offset ( Y ). Or simply more, there's an issue with shader rendering.
I'm actually working on the sort of all johnW's excellent work for the primal assets definition ( really heavy work ... more than 33k lines to sort, sort, and sort again to be correctly understandable for all modders ). I finded all the water effects and will analyse them to give you an as quick as possible answer.
Sorry for late, even i'll answer, yep, i'll answer xD