Return Function (╯°□°)╯︵ ┻━┻

hopy

Active Member
Reaction score
64
Hey everyone, me again. I'm currently working on a day/night system for my map, as well as a little clock window to show players the current time.

After about half a day of messing around I think I've got everything to work, except for one error message. The error message in question is a return action in a function. It's supposed to return the current time of day as a string:
Trigger:
  • TimeOfDayToString
    • Options: Function
    • Return Type: String
    • Parameters
      • Time of Day = 00:00:00 <Time Of Day>
    • Grammar Text: Convert Time Of Day to string
    • Hint Text: Converts a time of day value to a string.
    • Custom Script Code
    • Local Variables
    • Actions
      • General - Return lp_timeOfDay

The error message I get is on the "General - Return lp_timeOfDay" part, and I have no clue why. Also couldn't find anything about this on the interwebs. The message happens when the editor is trying to compile the map (saving/testing), and gives me the following message:
"Script failed to compile: Error parsing return, possibly missing semicolon at the end of the return: ';' (See Trigger Editor for more details)"
Now, by this message I assumed the solution would be "add a ';' " and tada, it's fixed. However this turned out not to be the case, so I was hoping you guys knew what to do.

Odds are that it's something really simple and stupid again, and that I'll look like an idiot again, but this little error is preventing me from testing the entire thing. Thanks for any help in advance, and hope to get a reply soon. :)
 

Dave312

Censored for your safe viewing
Reaction score
269
When you are trying to return a string, you can't just type in the name of your variable and hope it will be converted for you. It won't work which is why you're getting the error.

After having a look around, there doesn't seem to be any built in functions to convert a Time of Day type to a string (or even an integer/real). However I did notice there is a built in function called GetTimeOfDay() which will return a string but it will only return the current time of day (not convert if from a parameter). This function is hidden too so you will have to type it in as custom script. I'm unsure as to whether this will work for you though as it will depend on how you have set up your system (does it use the built in time of day stuff or are you emulating it?)
 

hopy

Active Member
Reaction score
64
When you are trying to return a string, you can't just type in the name of your variable and hope it will be converted for you. It won't work which is why you're getting the error.
I actually had no idea how to do this in SC2, so I got myself a tutorial to help out on this. The actual system is pretty simple:
Is supposed to return me the time of day as a string:
Trigger:
  • TimeOfDayToString
    • Options: Function
    • Return Type: String
    • Parameters
    • Time of Day = 00:00:00 <Time Of Day>
    • Grammar Text: Convert Time Of Day to string
    • Hint Text: Converts a time of day value to a string.
    • Custom Script Code
    • Local Variables
    • Actions
    • General - Return getTimeOfDaySeconds(lp_timeofday)

Creates the dialog label and all (calls upon the function):
Trigger:
  • ------- The time of day clock. >CLOCK<
    • Dialog - Create a Modal dialog of size (270, 150) at (0, 0) relative to Top Left of screen
    • Dialog - Show (Last created dialog) for (All players)
    • Dialog - Create a label for dialog (Last created dialog) with the dimensions (200, 50) anchored to Center with an offset of (50, 50) with the text ("Time of day: " + (Text((Convert Time Of Day to string)))) color set to White text writeout set to False with a writeout duration of 2.0
    • Dialog - Show (Last created dialog item) for (All players)
    • Variable - Set ClockDisplay = (Last created dialog item)

Updates the dialog window label (calls upon the function):
Trigger:
  • Clock update
    • Events
    • Timer - Every 1.0 seconds of Game Time
    • Local Variables
    • Conditions
    • Actions
    • Dialog - Set ClockDisplay text to (Text((Convert Time Of Day to string))) for (All players)

Error I'm getting:
Code:
Script failed to compile: Error parsing return, possibly missing semicolon at the end of the return: ';' (See Trigger Editor for more details)
string gf_TimeOfDayToString (string lp_timeofDay) {
// Implementation
return getTimeOfDaySeconds(lp_timeofday);
}

Alright, what exaclty would you suggest? :D

((EDIT -- little small thing: is it possible to tint/darken the screen for a while via triggers? cant find an option))
 

Dave312

Censored for your safe viewing
Reaction score
269
Replace your current time of day function with this:
Trigger:
  • TimeOfDayAsString
    • Options: Function, Native
    • Return Type: Boolean
    • Parameters
    • Grammar Text: TimeOfDayAsString()
    • Hint Text: (None)
    • Custom Script Code

Once you check the Native option, the Local Variables and Actions section will disappear from the function. Finally you need to select the name of your function (select the first line) and uncheck Based On Name. Then set the Script Identifier to GetTimeOfDay (this must match exactly or else it won't work).

The main thing to be aware of with this function is that you can't add a parameter to it. The function will only ever return the current time of day.


You can use a fade filter to darken a screen by applying a black mask. The trigger action is called Fade In/Out.
 

hopy

Active Member
Reaction score
64
First of all: very sorry for the late reply. I've been quite buisy the past two weeks, and didn't have much time for serious work on my map.

Replace your current time of day function with this:
Trigger:
  • TimeOfDayAsString
    • Options: Function, Native
    • Return Type: Boolean
    • Parameters
    • Grammar Text: TimeOfDayAsString()
    • Hint Text: (None)
    • Custom Script Code

Alright, I followed what you did in your post, I currently have the following:
The main function, to ask up the time of day:
Trigger:
  • TimeOfDayAsString
    • Options: Function, Native
    • Return Type: Boolean
    • Parameters
    • Grammar Text: TimeOfDayAsString()
    • Hint Text: (None)
    • Custom Script Code


The (currently only) part that asks up the function:
Trigger:
  • Dialog - Create a Modal dialog of size (250, 100) at (7, 35) relative to Top Left of screen
    • Dialog - Show (Last created dialog) for (All players)
    • Dialog - Create a label for dialog (Last created dialog) with the dimensions (190, 75) anchored to Center with an offset of (0, 0) with the text (Text((GetTimeOfDay() chat string))) color set to White text writeout set to False with a writeout duration of 0.0
    • Variable - Set ClockDisplay = (Last created dialog item)


The error window I get on saving:
Code:
Script failed to compile: Invalid parameter list (See Trigger Editor for more details)
For this it selects the following part in the Script Compile Errors:
Code:
    libNtve_gf_CreateDialogItemLabel(DialogLastCreated(), 190, 75, c_anchorCenter, 0, 0, StringToText(EventChatMessage(GetTimeOfDay())), Color(100,100,100), false, 0.0);

I don't know exactly what's usefull or not, so I just copied everything. :D
My brain melts when trying to figure this out, and I'm currently tempted to make my own day/night system, based on custom timers and integers. xD

You can use a fade filter to darken a screen by applying a black mask. The trigger action is called Fade In/Out.
Thanks. :)
 
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

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top