I am fairly new to UE4 development so apologies if I am missing something obvious.
I am trying to convert a system from blueprints to C++. In an attempt to convert the SpawnActor node, I found that I am unable to provide input parameters like in the image below where ‘Index’ is a custom input.
In other places, to resolve this issue, I have used BeginDeferredActorSpawnFromClass, used an initialise function to provide parameters, then call FinishSpawningActor. This has worked where I am calling a C++ class.
In this case however, the actor I want to spawn is a blueprint class which is a child based on a C++ class. I am unable to implement BeginDeferredActorSpawnFromClass for this, and therefore am not sure how to pass my parameter to this.
For extra context, in the project there can be multiple characters spawned in the world. I want to pass the index of the character in order to set the material colour of each individual character using the nodes shown below.
I am able to achieve this by spawning the BP character using:
Character = GetWorld()->SpawnActor(...)
Character->Index = Index
And then using EventTick instead of EventBeginPlay but feel this is a bad solution. I would appreciate if someone could advise how to initialise the spawned actor with the required parameter.
Thanks in advance.
I was being stupid. SpawnActorDeferred is the function which serves the purpose required.
Related
I’m new to Crystal (and never really used ruby) so apologies for the ignorance here! I've looked at the ecr docs but can't seem to find an answer there.
I’m looking at using Embedded Crystal for dynamic templates in Kemal. Can I confirm - can templates only render variables that are available in the scope of the call, or can one make method/function calls from within the template itself? I.E. is there any possibility/risk of being able to execute “malicious” crystal code from within a template (in this case malicious refers to I/O or file access etc)?
To take an example from the Kemal docs:
get "/:name" do |env|
name = env.params.url["name"]
render "src/views/hello.ecr"
end
In the view hello.ecr - is name the only item that will be available in the template, or could one call File.delete("./foo")from within the template for example?
A template is compiled into Crystal code, you can write any kind of code in there, like File.delete("./foo"), for example if you write <% File.delete("./foo") %> inside of your template.
If your worry is that name will contain code and that will somehow get executed, then don't worry, that's not going to happen. Dynamic runtime code execution in Crystal is not possible, so there's no way someone will inject malicious code into your templates.
I am using openpyxl to read an excel file that will have changing values over time. The following function will take string inputs from the excel sheets to make frames for Tkinter.
def make_new_frame(strng, frame_location, frame_name, frame_list):
if not(frame_name in frame_list):
frame_list.append(frame_name)
exec("global %s" %(frame_name)) in globals()
exec("%s = Frame(%s)"%(frame_name, frame_location))
.... etc.
The code itself is quite long but I think this is enough of a snapshot to address my problem.
Now this results in the following error while parsing:
SyntaxError: function 'make_new_frame' uses import * and bare exec, which are illegal because it is a nested function
Everything in the code I included parsed and executed just fine several times, but after I added a few more lines in later versions in this function, it keeps spitting out the above error before executing the code. The error references the third line in the function, (which, I repeat, has been cleared in the past).
I added "in globals()" as recommended in another SO post, so that solution is not working.
There is a solution online here that uses setattr, which I have no idea how to use to create a widget without eventually using exec.
I would really appreciate if someone could tell me how to bypass the error while parsing or provide an alternative means for a dynamically changing set of frame names.
Quick Note:
I am aware that setting a variable as global in python is generally warned against, but I am quite certain that it will serve useful for my code
Edit 1: I have no idea why this was downvoted. If I have done something incorrectly, please let me know what it is so I can avoid doing so in the future.
I think this is an X/Y problem. You are asking for help with solution Y instead of asking for help on problem X.
If your goal is to create an unknown number of Frame objects based on external data, you can store references to the frame in a list or dictionary without having to resort to using exec and dynamically created variable names.
exec is a perfectly fine function, but is one of those things that you should never use until you fully understand why you should never use it.
Here's how to solve your actual problem without using exec:
frames = {}
def make_new_frame(strng, frame_location, frame_name, frames):
if not(frame_name in frames):
frames[frame_name] = Frame(frame_location)
return frames[frame_name]
With that, you now have a dictionary (frames) that includes a reference for every new frame by name. If you had a frame named "foo", for example, you could configure and pack it like this:
frames["foo"].configure(background="red", ...)
frames["foo"].pack(...)
If preserving the order of the frames is important you can use an OrderedDict.
I am trying to create a custom lexer based off of JavaScript for QScintilla. I have figured out how to add keywords the the lexer. However, I can not figure out how to alter the way they look when typed in like it does when you type the word function, for example.
I need to figure out how to do this with, for example, the word "fill".
Here's the code I currently have:
QsciLexer *lexer=new QsciLexerJavaScript;
QsciAPIs *api = new QsciAPIs(lexer);
api->add("fill");
api->prepare();
ui->textEdit->setLexer(lexer);
You need to subclass the QsciLexerCustom class. Then you need to make/configure several QsciStyle objects inside that class. The actual syntax highlighting is done in the styleText() function, which you need to override.
You can find detailed explanation on this website:
https://qscintilla.com/
More specifically on this page:
https://qscintilla.com/syntax-highlighting/
I hope it helps
I'm a bit desperate here... I'm trying to access one parameter of a light in Softimage.
First, when we do this:
light.GetParameterValue(L"LightExponent")
it works!
But when we try:
light.GetParameterValue(L"soft_light.atten")
it fails completely!
I tried to find documentation, but the only code that I could find is in Python and no indication for the equivalent in C++. In python, they manage to do something like:
xsi = Application
test = xsi.GetValue("LightName.point.soft_light.atten")
But I cannot figure out what is Application, and it's not the same as XSI::Application in the API.
So, any idea how to access this value ? Also, if I could found the equivalent to Application.GetValue (in the script, you can see Application.SetValue... so I imagine that GetValue exists in some form!) in C++, that would be nice... I could simply use the name of the light and then add the information that I need to access that value like:
SomeUnknownClassForNow::GetValue(light.GetName() + ".point.soft_light.atten");
Any idea ?
With the help of a client of ours, I finally managed to find a proper solution to this.
First, there's some direct parameters, like "LightExponent". But there's other parameters associated with an object, like a light, in other categories called Shaders.
With a light, or a least a point light, there's only one Shader, called "soft_light". It's possible to access it by:
light.GetShaders()[0]
It's possible to verify its name to with GetName(). Which, in this case, would be "LightName.point.soft_light".
Finally, to access the "soft_light.atten" parameter:
light.GetShaders()[0].GetParameterValue("atten")
So, in Softimage, there's sort of Hierarchy in objects and all these a separated as shaders. For more complex object, just find the right shader and extract its parameter.
I have been staring at this documentation for 5 hours now. I simply cant connect the steps. If you guys can enlighten me of the stuff.
Here is the site:
http://msdn.microsoft.com/EN-US/library/bb983718(VS.110).aspx
So my problem are the following:
-at number 5, it asked me to "Set these parameters as follows:", it didnt even mention anything about where? Where to implement the constructor, and why are we using CMFCToolbarComboBoxButton? when it already asked me at step 4 to derive a clas called CFindComboButton. Shouldnt I be making a contstructor for that one instead?
-at number 4(sorry about the non organized numbering of problems), what I did is use the add class (not the class wizard), and then I picked MFC Class. I then enter the supposedly CFindComboButton and Base class as CMFCToolBarComboBoxButton. Did I do something wrong on this one? Do I have to do anything for the ID ID_EDIT_FIND_COMBO?
-When I register the ID_EDIT_FIND_COMBO at the String Table, I dont exactly know what I did. Did I just register an id for future implementation? or is it something else?
-So I cant do step 5, I skipped to step 6. All it ask me is to look for the CreateCombo method athe the override section of properties at CFindComboButton. Well I can only find 3 override. None of them are CreateCombo method. Well from there, you can tell that I'm lost.
I'm a noob at mfc so you might wanna take that in consideration.
Even though your question is a bit jump-led up, let me try and answer so that it works for you.
Create two class - one derived from CComboBox (call it CFindComboBox) and another from CMFCToolBarComboBoxButton (call it CFindComboBoxButton). First class will implement the Combobox that will be shown when you click the drop down button in the toolbar. This drop down button is implemented by CFindComboBoxButton. Hope this is clear.
Now define the constructor for the CFindComboBoxButton as CFindComboBoxButton(UNIT nID, int nImage, DWORD dwStyles) using three parameters as explained below:
Command ID of the button which will be ID_EDIT_FIND_COMBO (or anything you want to define it as). This will get defined in the String Table. Just add a new entry in String Table with ID_EDIT_FIND_COMBO as ID and a placeholder string. Don't omit the string value else the ID will not get defined. The string value can be anything as it wont be used anywhere.
Second parameter will just be a call to CCommandManager::GetCmdImage(ID_EDIT_FIND). This will return the default image used to show the drop down for combobox. In case you want to use your own custom image you can create one and instead pass the ID of that.
Third parameter is the styles you want to use. They are defined at http://msdn.microsoft.com/EN-US/library/7h63bxbe(v=vs.110).aspx but you can use the default value (CBS_DROPDOWNLIST) to start with.
Override the CreateCombo method of CMFCToolBarComboBoxButton and add its implementation to CFindComboBoxButton. In this method create and return a pointer to CFindComboBox (CComboBox derived class).
I hope this clears all the confusion and you should be on your way to have a custom Combobox embedded inside a toolbar.
take a look at the VisualStudioDemo Sample:
http://msdn.microsoft.com/en-us/library/bb983983%28v=vs.90%29.aspx
you can find the CFindComboButton implementation there