The Forums Are Now Closed!

The content will remain as a historical reference, thank you.

[TUTORIAL] how to create a new window

By on November 23, 2009 11:31:25 AM from Demigod Forums Demigod Forums

first things first: lua

for good work i suggest you get a good tool first. notepad++ or scite are good. if you visit the lua homepage you can download a development kit for lua which includes scite. that kit wont help you much with demigod since the debugger aint attachable (havent tried and certainly wont work) but the editor is good and you can learn lua from scratch.


for modding you need to know and understand hooks. hooks are basically overrides of the functions that already exist in the game.

the window:

for the start i decided to create a new window that shows up on the left side over the mini hero infopanel. i didnt want it to interact with other windows so its really just start the game, open the mini hero window and click a button to open that new window. then you can close it again. this is all copy paste work and doesnt need deep understanding of the api, so dont be scared.

extract the and go to lua/ui/game

the hud is initialized in the ingameui.lua from there you can start all your ui modding work. the mini hero window is located in screen_hero.lua

i suggest to copy another mod i.e. the rollover mana and equipment display by chirmaya. take care to place the files with the hooks in the right folders. i guess your own files you can place wherever you want (inside the mod directory of course) but i havent tried yet.

next you have to identify the right function to modify. in this case its createmini.

i added the neccessary code to create the new button and to call the function of the other file which contains the actual window below the script code that creates the already existing two buttons

look at this line:
    miniHeroAdvanced = import('/mods/test/hook/lua/ui/game/new.lua').CreateMiniAdvanced(parent)

it loads another lua file which includes the new window.

i commented both files, so if you have questions ask.

its important that you include the button.lua. you implicitely use it. if you dont include it your onclick method wont get fired and that sucks

the first line Group(parent) actually creates the "window" but you cant see it. its not really a window its rather an invisible container for stuff of all sorts. i.e. the buffs (over health and mana) are also in such a group. really every hud display you see is such a group. the difference is that earch of these groups has another background image. that makes them look different. in this case there is a top, a body and a bottom bitmap which creates the window.

now just do with that code whatever you want.

perhaps someone else can look into how to count minions and towers and how to get their hp. then its easy to put these infos into such a window.

another thing would be how to make that info clickable which means how to make that info pointing to another player. perhaps then its possible to make a mod with which you can heal by clicking on an image...

here is a link to the "mod"

before i forget it: you cant fuck up demigod itself by modding so no fear. if the ui i ruined (which happens a lot since there is no compiler who complains about typos or similar stuff) you either have to go trough the code carefully or overwrite the modded things with the originals.

i suggest enable cheats in your gameprefs go into singleplayer and restart the game by hitting ctrl+f10. then you will see the changes.

print("blubb") works! i prints out the string where the usual messages appear. that way you can see if actions or stuff is being triggered or not.

mrrappard gave me a link to a very useful tool its called wingrep. with this tool you can search for strings in the files of a directory and subdirectorys:

+4 Karma | 1 Reply
November 23, 2009 10:38:36 PM from Demigod Forums Demigod Forums

Thank you Derog. That is really great info!

Thanks again!

Stardock Forums v1.0.0.0    #108434  walnut1   Server Load Time: 00:00:00.0000047   Page Render Time:

Stardock Magazine | Register | Online Privacy Policy | Terms of Use

Copyright ?? 2012 Stardock Entertainment and Gas Powered Games. Demigod is a trademark of Gas Powered Games. All rights reserved. All other trademarks and copyrights are the properties of their respective owners. Windows, the Windows Vista Start button and Xbox 360 are trademarks of the Microsoft group of companies, and 'Games for Windows' and the Windows Vista Start button logo are used under license from Microsoft. ?? 2012 Advanced Micro Devices, Inc. All rights reserved. AMD, the AMD Arrow logo and combinations thereof are trademarks of Advanced Micro Devices, Inc.