How to make your own methods/scripts
First of when making your own methods you name a script_entity to whatever you want but in my case ill name it game,
So lets get started first off making a function.
Code: Select all
-- This is a simple function it does nothing.
function kill()
end
Lets add something to get the entity so we can define which entity we want to kill!
Code: Select all
function kill(entity)
end
Lets add the killing part!
Code: Select all
function kill(entity)
-- use return to return whatever your wanting to return!
return entity :destroy()
end
Now to use this sense our scrip_enttiy is named game we simpply say:
Code: Select all
game.script.kill(my_monster)
[/color]
Entities to know!
With Entities to get values and things are basically the same as the normal scripting but this time you need to do some special things.
To change anything in monsters you must say your_monster_name.monster.getHealth() or something else, for party its party.party and torches torch_name.controller basically if you place an object or something down click on it and at the bottom right of the entire editor you'll see something like a list with all these set able things so for monsters place one down and click on it. You'll see all these things but then theres a little tab called monster and it has all the stable values that is what you want to say when you want to do something to that entity so you_monster.monster.Value()
An example of some possibilities in what commands you can use.
Real Lua Scripts:
All Item Icons in numbers:
Leki wrote:Table of LoG 2 Editor Icons:
It's based on John's LoG1 table for visualisation (thanks for that). Enjoy and report bugs
New Defining an object:
Code: Select all
defineObject{
name = "animated_thingy",
components = {
{
class = "Model",
model = "assets/models/env/thingy.fbx",
},
{
class = "Animation",
animations = {
doTheTwist = "assets/animations/env/thingy_twist.fbx",
},
onAnimationEvent = function(self, event)
if event == "bang" then
self.go:playSound("boom")
self.go.obstacle:disable()
end
end,
},
{
class = "Sound",
sound = "hum_looping"
},
{
class = "Obstacle",
hitSound = "barrel_hit",
hitEffect = "hit_wood",
},
{
class = "Health",
health = 15,
immunities = { "poison" },
spawnOnDeath = "broken_thingy",
},
{
class = "Controller",
onActivate = function(self)
self.go.animation:play("doTheTwist")
self:disable()
end,
},
},
placement = "floor",
editorIcon = 120,
}
JohnWordsworth wrote:Having said that, the following will clone the "Tome of Wisdom" with a new title and description!
Code: Select all
defineObject{ name = "jw_tome_of_wisdom", baseObject = "tome_wisdom", components = { { class = "Item", uiName = "Boo Yah!", gfxIndex = 30, description = "A mysterious tome that will give you a skill point!", } }, }
Defining music
Go to mod_assets/Scripts/music.lua
Defining music:
Code: Select all
defineAmbientTrack{
name = "spooky",
filename = "mod_assets/sounds/spooky.ogg",
volume = 0.18,
}
All Know Entities scripts:
Floor_trigger
Code: Select all
floor_trigger_1.floortrigger:setTriggeredByParty(true)
floor_trigger_1.floortrigger:setTriggeredByMonster(false)
floor_trigger_1.floortrigger:setTriggeredByItem(false)
floor_trigger_1.floortrigger:setTriggeredByDigging(false)
--Disables self:
floor_trigger_1.floortrigger:setDisableSelf(true)
--Adds Connector:
floor_trigger_1.floortrigger:addConnector("onActivate", "script_entity_1", "setupgame")
Code: Select all
--Area it tps you
invisible_teleporter_1.teleporter:setTeleportTarget(1,11,15,0)
--Spin the player to a certain point(North, South, East,West,etc)
invisible_teleporter_1.teleporter:setSpin("south")
invisible_teleporter_1.teleporter:setTriggeredByParty(true)
invisible_teleporter_1.teleporter:setTriggeredByMonster(false)
invisible_teleporter_1.teleporter:setTriggeredByItem(false)
invisible_teleporter_1.teleporter:setTriggeredBySpell(false)
invisible_teleporter_1.controller:setInitialState("deactivate")
Code: Select all
timer_1.timer:setTimerInterval(15)
timer_1.timer:setDisableSelf(true)
timer_1.timer:setTriggerOnStart(true)
timer_1.timer:setCurrentLevelOnly(true)
timer_1.timer:addConnector("onActivate", "invisible_teleporter_1", "activate")
timer_1.timer:addConnector("onActivate", "invisible_teleporter_3", "activate")
timer_1.timer:addConnector("onActivate", "invisible_teleporter_2", "activate")
--Starts Timer
timer_1.timer:start()
--Stops Timer
timer_1.timer:stop()
Undefined Scripting:
Spawns and entity with the name at the location of type:
Code: Select all
spawn("entity name",level,x,y,facing,height,"your_cusotm_name")
Code: Select all
entity_name.surface:addItem(item_name.item)
Code: Select all
dungeon_alcove_1.surface:addItem(water_flask_1.item)
Code: Select all
playSound("Your_Sound.extension")
Player Scripts:
Prints text to the players hud:
Code: Select all
hudPrint("Your Text")
Code: Select all
party.party:getChampion(champion in numbers)
Code: Select all
party.party:getChampion(champion in numbers):gainExp(amount in numbers)
Code: Select all
party.party:getChampion(champion):setEnabled(boolean)
Code: Select all
party.party:getChampion(champion):getEnabled()
More to be found out
Variables:(Basic Lua)
Creates a local variable to be used
Code: Select all
myvar = false or 0 or "String/Text"
Code: Select all
mylar = false
function something()
if myvar == true then
myvar = false
else
myvar = true
end
end
Click Url to see more on how to sett variables in entities, this link goes to top of page!
viewtopic.php?f=22&t=7306
Code: Select all
entite_name.controller:setValue(Value)
Code: Select all
torch_holder_1.controller:setHasTorch(true)
BOSSES
So I've got it all worked out now!!!
1) Creating the boss battle:
All you need to do place an boss_fight entity down, name it whatever for example ill name it boss.
2) Adding a monster to the boss:
Simply make a script and have something trigger a function in it and the function could be this:
Code: Select all
function bossstart()
boss.bossfight:addMonster(monster.monster)
end
just replace monster.monster with boss.monster
3) Setting name in lua:
Code: Select all
boss_fight_entity.bossfight:setName("Boss Name")
Code: Select all
boss_fight_entity.bossfight:setAutoDeactivate(BOOL)
Code: Select all
boss_fight_entity.bossfight:setMusic("Music")
Code: Select all
boss_fight_entity.bossfight:activate()
Code: Select all
boss_fight_entity.bossfight:deactivate()
Hidden Pressure Plate
floor_trigger
How to make forests, and beaches
Forests
To make a forest shift + left click or right click with forest floor 1 to place down that tile all over the dungeon easily,
Then find the entity forest_day_sky and place it any were on the dungeon doesn't matter where, and find the forest_hightmap and place it
any were as well doesn't matter were again. and your done! To add forest walls just place down the forest_wall tile!
Beaches
To make a beach shift + left click or right click with the beach floor to place down that tile all over the dungeon easily,
Then find the entity forest_day_sky and place it any were on the dungeon doesn't matter where, and find the forest_hightmap and place it
any were as well doesn't matter were again. Then find the beach_ocean entity and place it down somewhere in the map and your pretty much done! (Warning the beach_ocean goes really far but will not cover the whole map unless you make it be at the complete left of the dungeon and make it face west!)
Beach_Oceans only go were ever there facing so if its facing south it will only be south. Another thing about oceans is they take up the entire map of south/north/east/west from the entity start point.
Example:
Lets say you made a beach_ocean at the middle of the map and it was facing south then the ocean would cover half the map on the south side.
Water
To make simple water just add water, well its not that simple what you really do is place your water tiles were you want them to be, then browse your assets for swamp_water or water_surface or water_surface_unerground and in saying that your pretty much done.
Terrain Height
To change the terrain height all you do is go to the little tab called Layerwhen your editing tiles,and change it to height map and that will only be there if you've added the forest
height map, then change the height to whatever and click on a tile then reload/start your dungeon and you'll see that tile is higher or lower.
Handling Tiles
Handling tiles can be a little confusing at times or the first time you open the editor, To use tiles correct they're actually pretty simple, simple select a tile out of your many tiles and if your using forest or beach or anything special look back up at how to make beaches and forests they'll help you a lot, but basically you select your tile and and you see you have the little choosing thing don't touch that it might be a little confusing but I don't think you'd really want to touch it anyway , what the LMB and RMB mean are Left Mouse Button and Right Mouse Button so if you left click on a tile in the tile browser you set the Left Mouse Button to that tile if you right click on a tile in the browser you set the Right Mouse Button to that tile.
Now the Floor and Ceil Floor Will mean how high or low the floor is Ceil will mean how high or low the ceiling will be. And so you simply place your tiles after setting your tile settings at the top and your done!
Portraits:
Legendary:
Non-consumable key?Ok I found out how to make it work, the file names needs to have the correct naming convention, [race]_[gender]_[01.. etc].tga
ex. human_female_01.tga
there is a subfolder in the LoG2 install directory with the portraits from LoG1, using their naming convention makes custom portraits show up in LoG2
master_key (but spoiler tag since its a major item in the end game of LoG2)
But it is also is able to open up every lock there is, so ones the party has it, finding a key will never be an issue.
Its not until AH releases the scripting reference that we can see if we can clone the master_key and change it so that it only opens locks that it has been assigned to and still remain with the party.
More Info Coming soon when more is found out!
Want to see a little dungeon I'm working on that has lots of examples?
Download: https://dl.dropboxusercontent.com/u/278 ... 20hand.zip
This dungeon has some things that currently don't work such as bosses, and damaging entities!
Video Tutorials: (By Skuggasveinn)
Skuggasveinn wrote:I've created some tutorials for the new Dungeon Editor
Please note that I'm just learning this stuff myself, and I've not seen the lua code behind the assets so I reserve the right to be complete wrong about what I'm talking about
Part 1 - http://youtu.be/vMMBC9B2qjM GUI and new features
Part 2 - http://youtu.be/eDaeqUUOuSc Elevations inside dungeons
Part 3 - http://youtu.be/6cv3P8dxCgY Coordinates and level transition
Part 4 - http://youtu.be/hVpY60Ptjdk Creating Water and Reflections
Part 5 - http://youtu.be/bLwSL8mhJOk Outdoor scenario
Part 6 - http://youtu.be/dxonfsoRYOY Bossfight
Code from part 6Playlist link https://www.youtube.com/playlist?list=P ... B7joLG52NcSpoilerShowCode: Select all
function startBrothersBossFight() boss_fight_brothers.bossfight:addMonster(skeleton_commander_1.monster) boss_fight_brothers.bossfight:addMonster(skeleton_commander_2.monster) boss_fight_brothers.bossfight:activate() end function startMedusaBossFight() boss_fight_medusa.bossfight:addMonster(medusa_1.monster) boss_fight_medusa.bossfight:activate() end
Hope that this will help someone get started.
Maybe I will add to these in the future.
Skuggasveinn.
Have anything I missed or don't know post it as a comment!