H4 Utility – problem with adding scripts

Maps and the art of mapmaking.

Moderator: Moderators

Wirox
Leprechaun
Leprechaun
Posts: 9
Joined: 18 Aug 2019

H4 Utility – problem with adding scripts

Postby Wirox » Aug 18 2019, 16:59

Hello.
I've downloaded H4 Utility (version 3.4, to be precise) to generate a C file based on my map's scripts, edit it, and then import the edited scripts. Unfortunately I cannot seem to get the importing part to work.

The command I'm using is

Code: Select all

h4util.exe -a path-to-map path-to-the-C-file
but it only generates the dump file and doesn't even touch the map (last modified date is left intact).

This is what the command prompt displays:

Code: Select all

File Name: "Player vs AI.h4c"
Version : 22
Single Map
Uncompressing ... done
Maps Found  : 1
Processing
 Map 0 ... done
Processing Script ... done
Dumping ... done

Could anyone tell me what I am doing wrong?
Last edited by Wirox on Aug 18 2019, 18:55, edited 1 time in total.

Wirox
Leprechaun
Leprechaun
Posts: 9
Joined: 18 Aug 2019

Re: H4 Utility – problem with adding scripts

Postby Wirox » Aug 18 2019, 19:08

I've found a workaround – adding the -w parameter is enough to make it work.
So the full command is

Code: Select all

h4util.exe -a -w path-to-map path-to-the-C-file

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 577
Joined: 21 Jul 2014

Re: H4 Utility – problem with adding scripts

Postby iLiVeInAbOx05 » Aug 20 2019, 17:47

What exactly are you trying to do with your scripts? If you're just editing, why not use the editor?

If it's due to the annoyance of dealing with nested scripts, you could give the H4MG Advanced Options Map Editor a try. You don't have to click 1000 times to get to the script you want, and you can copy / paste your scripts between maps or even save your scripts.

Wirox
Leprechaun
Leprechaun
Posts: 9
Joined: 18 Aug 2019

Re: H4 Utility – problem with adding scripts

Postby Wirox » Aug 23 2019, 17:44

Yeah, I cannot imagine working on complex scripts within the basic editor.
Since H4 Utility gives me almost everything I could expect from a script-editing tool (and I'm already familiar with it), I don't see a reason to try anything else.

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 577
Joined: 21 Jul 2014

Re: H4 Utility – problem with adding scripts

Postby iLiVeInAbOx05 » Aug 23 2019, 17:47

You must not do much with scripting then :)

Wirox
Leprechaun
Leprechaun
Posts: 9
Joined: 18 Aug 2019

Re: H4 Utility – problem with adding scripts

Postby Wirox » Aug 24 2019, 9:18

Well, then you're mistaken. Can you give me an example of a scripting task that cannot be performed efficiently with H4 Utility but can with H4MG Advanced Options Map Editor?
Last edited by Wirox on Aug 24 2019, 9:31, edited 1 time in total.

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 577
Joined: 21 Jul 2014

Re: H4 Utility – problem with adding scripts

Postby iLiVeInAbOx05 » Aug 26 2019, 16:04

Not to sound rude, but there is nothing simple / intuitive or efficient about the older H4Util, which is why we got together and came up with a new Utility which could simply and easily do the things map makers wish they could with the game's editor.

If you can copy and paste events or scripts between maps with H4Util, I was never able to get it to work. With the H4MG, all you have to do is highlight your events, hit ctrl+c or right click->copy, go to the other map, ctrl+v or right click->paste into the same event type list, and save. That's it. Your events are now copied over to another map. It takes at most 5 seconds.

You can do the same thing with scripts. Highlight the scripts, ctrl+c or right click->copy, go to your other script window and ctrl+v or right click->paste, and save. Takes even less time since you can have multiple script windows open at the same time.

You can also drag and drop scripts into other scripts. For example, let's say you put your conditional inside of the "yes" branch but you meant to create it inside of the "no" branch. No biggie, just drag the conditional from the "yes" branch and drop it onto the "no" branch.

If all you want to do is edit your scripts, then H4Util would be better for some script types, since the H4MG doesn't have a window for all script types still, so it won't open some of them.

All the features are listed in the first post of this topic. It has a lot of great options which greatly reduce the time it takes to create a map / campaign.

It's fine if you prefer to just use the old H4Util, I wasn't trying to make you try it out, just suggest it as an alternative for others. Most map makers would prefer a button click on an intuitive display over repeatedly trying to get command line options correct until you finally get it right.

Wirox
Leprechaun
Leprechaun
Posts: 9
Joined: 18 Aug 2019

Re: H4 Utility – problem with adding scripts

Postby Wirox » Aug 26 2019, 19:50

Maybe H4 Utility isn't the simplest or the most intuitive tool, but it surely is efficient. Once you get the scripts to export and import (which, as a side note, is the only thing you'll ever need to do via the command line) you can do anything you want with your code since everything is text-based, just like in any regular programming language – so yeah, you can easily copy parts of your code and paste it wherever you want. For anyone already familiar with C (or really any imperative language) it shouldn't be difficult to work with.

User avatar
Pol
Admin
Admin
Posts: 8964
Joined: 29 Nov 2005
Location: IN SOMNIS VERITAS
Contact:

Re: H4 Utility – problem with adding scripts

Postby Pol » Aug 26 2019, 19:59

Perhaps you would like to share a few tips?
"We made it!"
The Archives | Collection of H3&WoG files | Older albeit still useful | CH Downloads
PC Specs: A10-7850K, FM2A88X+K, 16GB-1600, SSD-MLC-G3, 1TB-HDD-G3, MAYA44, SP10 500W Be Quiet

Wirox
Leprechaun
Leprechaun
Posts: 9
Joined: 18 Aug 2019

Re: H4 Utility – problem with adding scripts

Postby Wirox » Aug 26 2019, 20:10

It's pretty difficult to come up with general tips because I imagine different people have issues with different things, but if someone has some specific questions about H4 Utility, I could try to answer them.

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 577
Joined: 21 Jul 2014

Re: H4 Utility – problem with adding scripts

Postby iLiVeInAbOx05 » Aug 26 2019, 21:21

Eh, you can argue with me as much as you want, but it's not efficient. Maybe if you're talking about as far as computational resources are concerned, since it only runs for a single task, rather than opens maps for editing, etc.

Copying and pasting your script text is only part of the task. You still have to deal with getting H4Util to work. So just because you can copy and paste text to effectively move a script, there's still the H4Util step. So it's back to not being that easy again :(

I guess it comes down to preference: Do you prefer editing a text file and then trying to get H4Util to work, or just copy and paste and move onto other general map making tasks.

Wirox
Leprechaun
Leprechaun
Posts: 9
Joined: 18 Aug 2019

Re: H4 Utility – problem with adding scripts

Postby Wirox » Aug 26 2019, 21:32

Once you figure out what command you need to use to export/import, you don't need to do anything more for the rest of your map-making career. You save the commands somewhere, and don't have to worry about it ever again. I know what command imports the scripts, you know what command imports the script (because I wrote about it in my first comment), so what is difficult or inefficient about it? Double-clicking a batch file?

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 577
Joined: 21 Jul 2014

Re: H4 Utility – problem with adding scripts

Postby iLiVeInAbOx05 » Aug 26 2019, 21:53

Why would I need to save all of that stuff when I already have it at the touch of a button? Also, that's only one task that can be performed, what about all the rest? Anyone else using H4Util would need to find a good write up for each task it can perform, and there aren't many write-ups out there.

It's cool man. Like I said, I'm not trying to sell you on it. I'm just making sure that any other potential map makers that come across this thread know there is a better option out there.

Even you, who are familiar with H4Util, had to come here with a question about a basic task that H4Util performs. So I'm just putting another option out there that doesn't require someone to do anything more than click a button (or copy / paste).

Wirox
Leprechaun
Leprechaun
Posts: 9
Joined: 18 Aug 2019

Re: H4 Utility – problem with adding scripts

Postby Wirox » Aug 26 2019, 23:22

You seem to misunderstand how H4 Utility works. As far as script-making goes, there are only two tasks it can perform: it can convert scripts from any h4c file to C-like code, and it can convert any C-like code to h4c scripts. That's it, there are no other tasks someone needs to know how to perform because there are none, so I don't know what you are talking about.

The user can do whatever they want with the C-like file and is only limited by what the H4 engine can perform (so you won't get arrays or local variables, for instance).
You can copy-paste parts of code, you can edit existing code, you can write new code from scratch (all events are documented, so this is not a problem), you can use another tool to generate some code (like all possible cases for some complex script) and paste it here – all of this is possible because, again, users are merely editing a text-based file – you do not use H4 Utility for the most part at all. It's only used for exporting and importing scripts which is done via two simple commands.

At the time I made the thread I wasn't familiar with H4 Utility. And, again, it's just a matter of memorizing/understanding/saving two commands. There is nothing more you need to do with this tool directly.
Last edited by Wirox on Aug 26 2019, 23:23, edited 1 time in total.

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 577
Joined: 21 Jul 2014

Re: H4 Utility – problem with adding scripts

Postby iLiVeInAbOx05 » Aug 27 2019, 16:08

I understand perfectly well what it's supposed to do and what you are supposed to do outside of the program. It just isn't at all intuitive and, like I said, even people that know how to use it still have issues with it and have to find workarounds. All I was saying in my last post is that you weren't comparing what you have to do using H4Util with the same task that I described using the H4MG.

Enjoy using H4Util. Anyone else that happens across this thread, there is a significantly better option, which I mentioned above.

Wirox
Leprechaun
Leprechaun
Posts: 9
Joined: 18 Aug 2019

Re: H4 Utility – problem with adding scripts

Postby Wirox » Aug 28 2019, 9:58

Okay, this is my last post in this topic – it's obvious you're going to advertise a clearly less efficient tool just because you've created it.

I'm saying this for the fourth time I think, but apparently you still didn't get it – anything other than exporting and importing scripts is done by simply editing a text-based file. If you know how to do something in Notepad (like how to copy-paste), you know how to do it for H4 Utility scripts.

Anything your tool can do with scripts, can be easily done with H4 Utility:

Gives quick and easy access to all map events and all objects which can contain events. Some fields on the events and objects are editable and some remain to be implemented. Most script types can be edited.
With H4 Utility, if you want to edit something in a script, you simply edit a part of the C-like file. You want a script to give 1000 gold rather than 500? You just change 500 to 1000 as you would in any text file. You want to give this gold to the blue player rather than red? You just change P_RED to P_BLUE as you would in any text file.
There's one important difference, though – with H4 Utility you can edit every possible script, nothing "remains to be implemented".

Copy / paste events between maps or objects.
Copy / paste scripts between events.
With H4 Utility you just copy-paste text, it couldn't be simpler.

Save / load events to / from file. Rather than have to open a map with the scripts you want to copy, you can create an event group, copy the scripts to the event group, and save that to file. All event groups are loaded when the H4MG is started and the events can be copied / pasted to any map.
Save / load quest huts, gates, and guards to / from file. Have a cool item shop or quest hut? You can save the scripting to file, and load it to any quest hut type.
Again, can be easily achieved with H4 Utility – you just copy-paste scripts to/from any text file you want.

Viewing scripts in an event has been overhauled. Now scripts are in a Tree View, so you can navigate to any script you want, regardless of whether it is nested inside another script (such as inside a conditional script). You can create a new script at any level, and you can even drag and drop scripts to new locations, which can be extremely useful.
You can easily navigate to any part of your code; nothing prevents you from creating a new script at any level; moving scripts is done via cut-pasting, just like in any text file.

Easily navigate to custom triggered events from a script which calls said event. For example, if I have a script which calls a Custom Event "Blah_1", then I can edit the "Trigger Custom Event" script, and there is now a button to open the custom event. This is especially helpful for getting to custom events on objects which can be spread out around a map.
This one depends on how you're editing the code, but many text editors support this, for instance Sublime Text.

AI difficulty adjustments, using scripts, based on this forum topic.
If someone insisted on using these exact scripts, they'd need to make them on their own (so this could take a bit more time, but this still isn't anything difficult).

And then there are a lot of advantages of H4 Utility:
  • For a lot of people it's simply more convenient and faster to work with text rather than do everything in a click-based UI. There is a reason why most IDEs are text-based.
  • You can use other tools and programs to quickly generate large parts of code, which would be otherwise very time-consuming. For example I needed a script to give variable amount of variable resource to variable player. Due to the limits of H4 engine it can only be done by checking for every possible case, which takes roughly 7000 lines of code. I cannot imagine doing it all manually, so I generated everything with another program and pasted it to the actual file.
  • Code comments.
  • Macros.
  • You can use any feature supported by the text editor of your choice, which includes, but is not limited to:
    - Find&replace with regular expressions;
    – Code folding;
    – Customizable theme and syntax highlighting.
  • It's possible to set up a code repository for your scripts, which is very useful for any bigger project.
  • Lots of different things I don't remember off the top of my head or perhaps didn't even think of.
Last edited by Wirox on Aug 28 2019, 10:34, edited 2 times in total.

User avatar
Pol
Admin
Admin
Posts: 8964
Joined: 29 Nov 2005
Location: IN SOMNIS VERITAS
Contact:

Re: H4 Utility – problem with adding scripts

Postby Pol » Aug 28 2019, 12:47

Peace, peace, please. I thanks for clarification to both sides. It was helpful discussion.

Both utilities are useful and are aimed for different audience. And I bet that they will coexist for much longer time.
"We made it!"
The Archives | Collection of H3&WoG files | Older albeit still useful | CH Downloads
PC Specs: A10-7850K, FM2A88X+K, 16GB-1600, SSD-MLC-G3, 1TB-HDD-G3, MAYA44, SP10 500W Be Quiet


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 3 guests