Regarding custom scripts

snowyowl

New Member
Reaction score
0
Hi

So I'm having some great fun toying around with the custom script feature, as I find it way too tedious to input all I want into the interface of the editor. I tend to create testtriggers within the interface and then open View Script just to get the hang of how one are to type the triggers.
I have, however, run into some difficulties.

When I test my map, the custom scripted triggers won't run, even though I find them identical to the ones created by the interface. Of course I have to put the initializations of each trigger within each custom script, but there must be something I've missed.

Code:
trigger gt_TestDisplay;
 
bool gt_TestDisplay_Func (bool testConds, bool runActions) {
 
    // Actions
    if (!runActions) {
        return true;
    }
 
    gv_randQue = RandomInt(0, 5);
 
    UIDisplayMessage(PlayerGroupAll(), c_messageAreaChat, StringExternal(gv_Questions[0][gv_randQue].lv_Question));
 
    UIDisplayMessage(PlayerGroupAll(), c_messageAreaChat, StringExternal(gv_Questions[0][gv_randQue].lv_Alternative[0]));
 
    UIDisplayMessage(PlayerGroupAll(), c_messageAreaChat, StringExternal(gv_Questions[0][gv_randQue].lv_Alternative[1]));
 
    UIDisplayMessage(PlayerGroupAll(), c_messageAreaChat, StringExternal(gv_Questions[0][gv_randQue].lv_Alternative[2]));
 
    UIDisplayMessage(PlayerGroupAll(), c_messageAreaChat, StringExternal(gv_Questions[0][gv_randQue].lv_Alternative[3]));
 
 
    returntrue;
}
 
//--------------------------------------------------------------------------------------------------
void gt_TestDisplay_Init () {
 
    gt_TestDisplay = TriggerCreate("gt_TestDisplay_Func");
 
    TriggerAddEventTimeElapsed(gt_TestDisplay, 5.0, c_timeGame);
 
}

Here is a screenshot from when I test my map, clearly showing that the trigger TestDisplay isn't running.
28c0u9h.png


Edit: I've seemed to localized the problem. In the View Script view there's a Trigger Initialization which contains all the triggers implemented through the UI, it looks like this:

Code:
//--------------------------------------------------------------------------------------------------
// Trigger Initialization
//--------------------------------------------------------------------------------------------------
void InitTriggers () {
    gt_Round1_Init();
    gt_Bepa_Init();
}

I guess I need to have a gt_TestDisplay_Init(); inside that void InitTriggers () aswell, but since that cannot be altered in the custom script, well that's when I don't know how to proceed.

So basically, my query is how to get a gt_TestDisplay_Init(); inside the InitTriggers () using script, as TestDisplay is based on a custom script.
 

Juggie

New Member
Reaction score
3
There are couple of ways to run the initialization function. The simplest one is to type the name of the initialization function into the "Initialization Function (Optional)" box that's located below the custom script edit field when you view the custom script in trigger editor. That will add the function you entered there into the map's InitCustomScript() function that's run at map's initialization stage.

There are also other ways, for example creating a trigger that runs on map's initialization and calling the custom script's initialization function from that trigger, but that's kind of crude.

You can also do edit the map's initialization manually. This can be done by going to import manager and checking the box "Show Reserved" and then exporting file named MapScript.galaxy. This will export the map's script as text file, which you can edit with any external text editing tool. You can then import it back, but this is slightly tricky. You cannot import a file that has the same name as a reserved file. You have to rename the file, for example to Map.galaxy, import it, save the map and then while having the "Show Reserved" option unchecked (in import manager) rename the file to MapScript.galaxy and save the map again. Note that if you edit anything through trigger editor and then save the map, the MapScript.galaxy file will be generated from scratch and your imported file will be overwritten, so this is not particularly efficient if you use trigger editor for writing scripts. If you want to use scripts only though, I find a way similar to the one described here http://www.thehelper.net/threads/galaxy-how-to-script-in-galaxy-easily.139895/ to be quite efficient.
 

snowyowl

New Member
Reaction score
0
Thanks, that was some really useful information Juggie! I'll try to code as much as possible outside the Galaxy Editor and use the Editor to see how certain triggers are converted to script using the View Script. Hopefully I'll have better luck with this, as I weren't able to copy text from outside the Editor to it.
 

snowyowl

New Member
Reaction score
0
As for now, I receive a Syntax Error whenever I try to test my map. I put the Inits of my custom script in the code like this:

Code:
//--------------------------------------------------------------------------------------------------
// Custom Script Initialization
//--------------------------------------------------------------------------------------------------
void InitCustomScript () {
    gt_TestDisplay_Init();
    gt_SetQuestions_Init();
}

Note, I didn't put it in here along with the GUI generated scripts:
Code:
//--------------------------------------------------------------------------------------------------
// Trigger Initialization
//--------------------------------------------------------------------------------------------------
void InitTriggers () {
    gt_Round1_Init();
    gt_Bepa_Init();
}

I tried putting them there but it didn't solve the issue. Looking for bugs sure is tedious when you can't compile the file until you run the Test Map :/
I searched the Internet for a good Galaxy script editor, sadly the ones I found were for Windows only.
 

Juggie

New Member
Reaction score
3
I'm not quite sure what's the source of the syntax errors. Maybe if you posted the whole map script or attach it as a file.

Code:
//--------------------------------------------------------------------------------------------------
// Custom Script Initialization
//--------------------------------------------------------------------------------------------------
void InitCustomScript () {
    gt_TestDisplay_Init();
    gt_SetQuestions_Init();
}

This shouldn't give a syntax error as long as you defined functions with such names above those calls. Maybe the function definitions are missing? Or perhaps there is another source of syntax errors?

For clarification: When you create triggers through trigger editor, the editor will automatically generate initialization functions that look like: void gt_NameOfTrigger_Init(), where NameOfTrigger is replaced by a the name of the trigger, obviously. It will also put a call to these functions into the Trigger Initialization block so that they get called at the map's initialization stage. If you create a Custom Script instead of a trigger then nothing is generated for you automatically. You can put the name of a function that you use as an initializer into the "Initialization Function (Optional)" box, which will add the call to that function into the Custom Script Initialization block and the function will get called at map's initialization stage as well. There must be a function with such name, otherwise the editor will give you errors. If you create custom scripts instead of triggers then the editor won't generate any functions for you, so make sure you define them. You don't need to name them in the same way as the editor does, but make sure their names are unique and that you use the same name when trying to call those functions.

P.S. I'm sorry if I'm explaining the obvious, but I can only guess what went wrong. As I said posting the whole map script or at least all map's initialization functions (InitCustomScript(), InitTriggers(), InitGlobals() and InitMap()) and the custom scripts would be much helpful in identifying the problem.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top