Tool for mission scripting?

13 replies [Last post]
francot514
User offline. Last seen 1 year 21 weeks ago. Offline
Joined: 2015-03-20
Posts: 163
Hi, im new and played few hedgewars, but i want to mod it, there is a tool i can use for mission scripting, or something good for modding the game??
mikade
mikade's picture
User offline. Last seen 11 weeks 1 day ago. Offline
Joined: 2010-10-22
Posts: 355
Hey, Missions and mods are written in lua. If you have the ability/interest to write scripts, there is a fairly comprehensive API available at https://code.google.com/p/hedgewars/wiki/LuaAPI I also created and used this WYSIWYG editor to make most of the missions in the game. It was designed to be used by people who aren't super knowledgeable about scripting, but I'm afraid I never got round to writing much documentation on its usage. Basically, you just play it as a gameplay mode and then place objects on maps to your liking and then hit... (precise + 4 maybe, I forget lol). That should generate a template script in your game0.log that includes all of the objects. After that, you can just use the API to edit the template and create any special events / behavior you want. Just place these in your data/scripts/multiplayer folder. https://dl.dropboxusercontent.com/u/15139166/HedgeEditor0_6.lua https://dl.dropboxusercontent.com/u/15139166/HedgeEditor0_6.hwp Good luck.
[color=white][b]mikade[/b][/color] [color=yellow][i]Hedgewars Developer[/i][/color] [IMG]/images/freeze.png[/IMG]
francot514
User offline. Last seen 1 year 21 weeks ago. Offline
Joined: 2015-03-20
Posts: 163
Dont know if WYSIWYG editor will be the best idea, i have created some kind of editor for Worms Armageddon, but outside the game, the difference is that the mission data there was easy readable.. For now ill try your script tool, but if i have some basic knowledge can be possible to program a simple tool that allow create the missions template (not all complex code)... What is the hwp file?? What data contains??
mikade
mikade's picture
User offline. Last seen 11 weeks 1 day ago. Offline
Joined: 2010-10-22
Posts: 355
Well, the WYSIWYG creates a template file, which is fairly easy to read if you have some basic coding experience. Feel free of course to write your own editor / tools if you'd like. The hwp is just a glorified zip file. I think the one I included contains some overrides for certain graphics other mods use. The target graphic is just a simple target, but the one included contains the graphics for the structures from Construction Mode. I can't remember if it works out the box anymore, but at the time I was using it in the editor to create pre-constructed forts that missions could use.
[color=white][b]mikade[/b][/color] [color=yellow][i]Hedgewars Developer[/i][/color] [IMG]/images/freeze.png[/IMG]
francot514
User offline. Last seen 1 year 21 weeks ago. Offline
Joined: 2015-03-20
Posts: 163
Ok, to clarify better, i will need to create some hwp file for allowing custom mission or that is just necessary for game modes scripting?? The mission only consist in the lua script and the preview image or anything else??
sheepluva
sheepluva's picture
User offline. Last seen 1 day 20 hours ago. Offline
Joined: 2009-07-18
Posts: 561
[quote=francot514] Ok, to clarify better, i will need to create some hwp file for allowing custom mission or that is just necessary for game modes scripting?? The mission only consist in the lua script and the preview image or anything else?? [/quote] You do not NEED to create any hwp file for a custom mission to work, but adding such file could allow extended customization. HWP-Files are an optional addition (a zip file with .hwp as extension) that can be used to replace or extend game data (custom graphics/sounds/etc). If used as side-car to a mission script the customizations it contains will only be loaded for that mission. See also https://code.google.com/p/hedgewars/wiki/HWPFormat
  [url=/user/3290][color=white][b]sheepluva[/b][/color][/url][color=#90BA5D] <- me[float=right]  [/float][float=right][url=https://www.openhub.net/accounts/80048][img]https://www.openhub.net/accounts/80048/widgets/account_tiny.gif[/img][/url][/float][float=right]my code stats -> [/float][/color] [i][color=#6080C0][size=8]a[size=4] [/size][/size][/color][color=yellow]Hedgewars Developer[/color][/i] [center][float=left]  [/float][float=left][url=https://twitter.com/sheepytweety][img]/images/twitter.png[/img][/url][/float] [url=/privatemsg/new/3290][color=#C0C0C0]click here to message me[/color][/url][/center] [color=#90BA5D][float=left]  [/float][float=left][url=https://en.wikipedia.org/wiki/Austria][img]/images/Flags/austria.png[/img][/url][/float][float=left] <- where I'm from[/float][float=right]  [/float][float=right][img]/images/Flags/united_kingdom.png[/img][/float][float=right][img]/images/Flags/germany.png[/img][/float][float=right]what I speak -> [/float][/color]
francot514
User offline. Last seen 1 year 21 weeks ago. Offline
Joined: 2015-03-20
Posts: 163
Some question about game itself, it load lua scripts before start, or i can modify it and allow to test without exit game, cannot change in game music??... Mission have restrictions like hedgehog or team limit??
nemo
nemo's picture
User offline. Last seen 21 hours 24 min ago. Offline
Joined: 2009-01-28
Posts: 1861
sheepluva added the option to interpret simple lua scripts during a game using chat, however usually people start a new game to test, yes. a small static map with no objects is faster to load for testing.
-- Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev
sheepluva
sheepluva's picture
User offline. Last seen 1 day 20 hours ago. Offline
Joined: 2009-07-18
Posts: 561
[quote=francot514] Some question about game itself, it load lua scripts before start, or i can modify it and allow to test without exit game, cannot change in game music??... Mission have restrictions like hedgehog or team limit?? [/quote] Missions have the same limits as ALL games in general. So max 8 teams, max 8 hedgehogs per team, etc. You could change the music by overriding the music for the used theme in your sidecar .hwp file (data path and name of the new music file must be identical). As nemo mentioned you can use the experimental "live lua" mode that will support some commands while in-game (local games only). It might be useful for testing single, simple commands, not for much more, since there's no real text cursor and no copy/paste (yet). You'd have a text cursor and copy/paste if you built the development version of Hedgewars or my backport-0.9.21-clone from source. You can currently toggle live lua mode by typing [b][color=cyan]/lua[/color][/b] You might be able to load scripts into engine that way too. But that might be useless if your script uses OnGameInit and/or a sidecar hwp, because those things need the script to be loaded normally - that is [i]before the game[/i].
  [url=/user/3290][color=white][b]sheepluva[/b][/color][/url][color=#90BA5D] <- me[float=right]  [/float][float=right][url=https://www.openhub.net/accounts/80048][img]https://www.openhub.net/accounts/80048/widgets/account_tiny.gif[/img][/url][/float][float=right]my code stats -> [/float][/color] [i][color=#6080C0][size=8]a[size=4] [/size][/size][/color][color=yellow]Hedgewars Developer[/color][/i] [center][float=left]  [/float][float=left][url=https://twitter.com/sheepytweety][img]/images/twitter.png[/img][/url][/float] [url=/privatemsg/new/3290][color=#C0C0C0]click here to message me[/color][/url][/center] [color=#90BA5D][float=left]  [/float][float=left][url=https://en.wikipedia.org/wiki/Austria][img]/images/Flags/austria.png[/img][/url][/float][float=left] <- where I'm from[/float][float=right]  [/float][float=right][img]/images/Flags/united_kingdom.png[/img][/float][float=right][img]/images/Flags/germany.png[/img][/float][float=right]what I speak -> [/float][/color]
francot514
User offline. Last seen 1 year 21 weeks ago. Offline
Joined: 2015-03-20
Posts: 163
Thanks for your help, ill start doing the basic test with some elements from the current api, to better understand all that all, after ill try to some live lua stuff.. the bad point for me is i can only do a tool that allow manual editing, not while in game, becuase dont know how to allow interactions between tool and game engine... Pd. Can you see my post about mobile version??
francot514
User offline. Last seen 1 year 21 weeks ago. Offline
Joined: 2015-03-20
Posts: 163
What i have learned in some days, is that the api their own events precreated by default, whats the difference between: function onGameInit() and function onGameStart(). Also what libraries is using the api?? io, system, or anything else??
nemo
nemo's picture
User offline. Last seen 21 hours 24 min ago. Offline
Joined: 2009-01-28
Posts: 1861
onGameInit is called first and is for setup of the game params. onGameStart is after map layout but before start of actual play. I believe sheepluva has been putting some IO limits in, but at present that's kinda incomplete. I'd suggest using lua functionality cautiously though. If you're using your own config files for example, that's a no-no. Also, there's the idea of synced/unsynced - don't do anything that can trigger floating point math for anything that isn't simply a visual effect. Stick to integer math and the div(a,b) command.
-- Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev
francot514
User offline. Last seen 1 year 21 weeks ago. Offline
Joined: 2015-03-20
Posts: 163
Really hardly to learn the complete api, i have tried some basic functions, based on user made missions, and i can handle it with a simple editor, but do advanced features will take so much time to accomplish...
nemo
nemo's picture
User offline. Last seen 21 hours 24 min ago. Offline
Joined: 2009-01-28
Posts: 1861
Well, maybe should start by sketching out what you want to do, and we can see if existing functions can be massaged into doing it, or new ones pressed into service?
-- Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev
Copyright © 2004-2023 Hedgewars Project. All rights reserved. [ contact ]