Tool for mission scripting?

13 replies [Last post]
francot514
User offline. Last seen 2 years 2 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 45 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.

mikade
Hedgewars Developer

francot514
User offline. Last seen 2 years 2 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 45 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.

mikade
Hedgewars Developer

francot514
User offline. Last seen 2 years 2 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 21 weeks 5 days ago. Offline
Joined: 2009-07-18
Posts: 563

francot514 allegedly wrote:

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??

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

  sheepluva <- me  my code stats -> 
a Hedgewars Developer


   <- where I'm from  what I speak -> 

francot514
User offline. Last seen 2 years 2 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 19 weeks 2 days 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 21 weeks 5 days ago. Offline
Joined: 2009-07-18
Posts: 563

francot514 allegedly wrote:

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??

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 /lua

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 before the game.

  sheepluva <- me  my code stats -> 
a Hedgewars Developer


   <- where I'm from  what I speak -> 

francot514
User offline. Last seen 2 years 2 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 2 years 2 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 19 weeks 2 days 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 2 years 2 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 19 weeks 2 days 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

User login

Copyright © 2004-2024 Hedgewars Project. All rights reserved. [ contact ]