Page 85 of 400
Re: Ask a simple question, get a simple answer
Posted: Tue Aug 25, 2015 3:29 pm
by Drakkan
could I ask somebody to write script which will do following --
I have table called food_table
when I place object coin_gold (its stackable item) on the table, it destroy one coin and spawn gold_food object on the table. In case more gold_coins inserted it should return back the remaining money. And also - this process could be done only once (means only one gold_food could be bought).
Thanks for any help
Re: Ask a simple question, get a simple answer
Posted: Tue Aug 25, 2015 4:11 pm
by Isaac
AndakRainor wrote:The offset of the clickable component is the same, but not its size. I will try different sizes tonight and see if I get a better result.
Try this one.
Code: Select all
defineObject{
name = "dungeon_click_secret_door",
baseObject = "base_secret_door",
components = {
{
class = "Model",
model = "assets/models/env/dungeon_secret_door.fbx",
staticShadow = true,
},
{
class = "Door",
openVelocity = 0.5,
closeVelocity = -0.5,
secretDoor = true,
openSound = "wall_sliding",
closeSound = "wall_sliding",
lockSound = "wall_sliding_lock",
onOpen = function(self)
self.go.clickable:setOffset(vec(0,2.8,0))
end,
onClose = function(self)
self.go.clickable:setOffset(vec(0,1.5,0))
end,
},
{
class = "Clickable",
offset = vec(0, 1.5, 0),
size = vec(1.2, 0.8, 0.2),
frontFacing = true,
--debugDraw = true,
onClick = function(self, ...) if getMouseItem() and self.go.door:isOpen() then
return false
else self.go.door:toggle()
end
end,
},
},
}
Re: Ask a simple question, get a simple answer
Posted: Tue Aug 25, 2015 5:41 pm
by minmay
Drakkan wrote:could I ask somebody to write script which will do following --
I have table called food_table
when I place object coin_gold (its stackable item) on the table, it destroy one coin and spawn gold_food object on the table. In case more gold_coins inserted it should return back the remaining money. And also - this process could be done only once (means only one gold_food could be bought).
Thanks for any help
You should be able to do this yourself, but here. Connect the surface's onInsertItem action to this function.
Code: Select all
done = false
function itemInserted(surface)
if not done then
for _,i in surface:contents() do
if i.go.name == "coin_gold" then
if i:getStackSize() == 1 then
i.go:destroy()
else
i:setStackSize(i:getStackSize()-1)
end
done = true
surface:addItem(spawn("gold_food").item)
break
end
end
end
end
Re: Ask a simple question, get a simple answer
Posted: Fri Aug 28, 2015 1:21 pm
by RedNova
How can i change monster attack and defence parameters?
Re: Ask a simple question, get a simple answer
Posted: Fri Aug 28, 2015 1:42 pm
by Isaac
Do you mean control how they act during a fight?
Or do you mean alter things like damage and protection?
Re: Ask a simple question, get a simple answer
Posted: Fri Aug 28, 2015 2:54 pm
by RedNova
Isaac wrote:Do you mean control how they act during a fight?
Or do you mean alter things like damage and protection?
2.
And why map of my dungeon is blank?
Re: Ask a simple question, get a simple answer
Posted: Fri Aug 28, 2015 3:08 pm
by THOM
In the mod_assets folder you can find a file called items.lua. You can add there a definition for a weapon.
It has to look like that:
Code: Select all
defineObject{
name = "machete",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/machete.fbx",
},
{
class = "Item",
uiName = "Machete",
gfxIndex = 23,
impactSound = "impact_blade",
weight = 2.2,
traits = { "light_weapon", "sword" },
},
{
class = "MeleeAttack",
attackPower = 12,
accuracy = 0,
cooldown = 4.5,
swipe = "horizontal",
},
},
tags = { "weapon" },
}
How to change behaviour should be obvious, I think.
What do you mean by "my map is blank"?
Re: Ask a simple question, get a simple answer
Posted: Fri Aug 28, 2015 3:37 pm
by RedNova
Re: Ask a simple question, get a simple answer
Posted: Fri Aug 28, 2015 6:33 pm
by Isaac
RedNova wrote:why map of my dungeon is blank?
First, click the arrow in the circle on the automap. Is it still blank after that?
______
To change monster parameters, one usually defines the monster in monsters.lua, with the desired changes.
*However it is also possible to change those parameters during the game via script. The components to affect these parameters are the
monster and
monsterAttack.
For instance, if the monster id is my_ogre_1, then to make my_ogre_1 hit really hard, and be very evasive, include this in a script:
Code: Select all
my_ogre_1.monster:setEvasion(45)
my_ogre_1.basicAttack:setAttackPower(150)
my_ogre_1.turnAttack:setAttackPower(150)
my_ogre_1.charge:setAttackPower(150)
Re: Ask a simple question, get a simple answer
Posted: Fri Aug 28, 2015 6:54 pm
by THOM
Oh - sh***!
I havn't read carefully what you have asked, RedNova.
For sure, Isaac is right. He explained how to create a new monster / change behaviour of existing ones.
I did the same - but for Items like weappons...
