Gui problems:Scripted functions doesn't work on a custom map

Get help with installing and running the Cafu Engine here. This forum is also for general questions and discussion of all aspects regarding the Cafu Engine.
Post Reply
Sacramento
Posts:9
Joined:2013-08-30, 19:37
Gui problems:Scripted functions doesn't work on a custom map

Post by Sacramento » 2014-02-05, 02:11

Hello Carsten, i have a problem here when i was testing my own map.

I created a Gui with basics functions (spining characters, glowing buttons, those things) and it works perfectly on the live preview.

But when i am working on the map, i can only see my cursor but i can't do anything at the gui...

I have tested on another map (BPWxBeta) and it works fine... i also, tested the teleporter gui, this time on my map, and it does'nt do anything too.

¿What's the problem? ¿Do i have to configure anything on a custom map before i can use a gui?

Thank you very much if you read this Carsten.
User avatar
Carsten
Site Admin
Posts:2170
Joined:2004-08-19, 13:46
Location:Germany
Contact:

Re: Gui problems:Scripted functions doesn't work on a custom

Post by Carsten » 2014-02-05, 15:30

Hi Sacramento,
nice to hear from you!
Sacramento wrote:But when i am working on the map, i can only see my cursor but i can't do anything at the gui...
Can you please refresh me on what version of the engine you're using?

And what do you mean by "i can't do anything"?
Does the mouse cursor (not) move?
Will mouse "clicks" (not) be processed?
¿What's the problem? ¿Do i have to configure anything on a custom map before i can use a gui?
A quick shot: In the "GUI Inspector" dialog, is the property "Interactive" checked [✔] ?
Best regards,
Carsten
Sacramento
Posts:9
Joined:2013-08-30, 19:37

Re: Gui problems:Scripted functions doesn't work on a custom

Post by Sacramento » 2014-02-06, 00:12

Hi Carsten, nice to see you again :)

The version i'm using is :

Code: Select all

Cafu-bin-2013-04-27-9e48f96-win32

I mean... I can't use the functions of the gui that i writed on the lua scrip file.

The cursor is good ( i had some problems to assing a proper image, but i solved that by copy the cmat file from the original teleporter gui, if there is a better why to do it, please let me know).

The mouse clicks won't work, i click on the buttoms i made and nothing happens, the gui look like it was frozen.

When i load the map, the gui appear on the terminal and all, but it seems like the lua code isn't running on MY MAP.

When i tested this on the custom maps that cafu bring, everything is ok.

¿I was clear enough? sorry if i'm dificulty to read.
User avatar
Carsten
Site Admin
Posts:2170
Joined:2004-08-19, 13:46
Location:Germany
Contact:

Re: Gui problems:Scripted functions doesn't work on a custom

Post by Carsten » 2014-02-06, 16:25

Hi,
Sacramento wrote:¿I was clear enough? sorry if i'm dificulty to read.
Yes, thanks for providing the information!

My "problem" is that I rewrote the whole GUI and entity system (as outlined here) in the meanwhile (it's all still under development though), so I have to set myself "back in time" to understand what might be the cause for your issue.

So here's a suggestion:
  • If you've checked the " [✔] Interactive" checkbox in the GUI editor, and
  • the in-game console does not provide you with a clue about what might have gone wrong,
  • could you then please send your map and GUI files to my email address (info@cafu.de)?
I would have a closer look then on what goes wrong. It would be enough if you send me your .cmap and the main and init .cgui files, so that I can check things out. :up:
Best regards,
Carsten
Sacramento
Posts:9
Joined:2013-08-30, 19:37

Re: Gui problems:Scripted functions doesn't work on a custom

Post by Sacramento » 2014-02-11, 00:11

If you've checked the " [✔] Interactive" checkbox in the GUI editor
Yep, i did
the in-game console does not provide you with a clue about what might have gone wrong
Nope, nothing

im sending you a mail with the files, i hope you can find what is wrong.
User avatar
Carsten
Site Admin
Posts:2170
Joined:2004-08-19, 13:46
Location:Germany
Contact:

Re: Gui problems:Scripted functions doesn't work on a custom

Post by Carsten » 2014-02-11, 14:33

Sacramento wrote:im sending you a mail with the files, i hope you can find what is wrong.
Thanks! I got your email with the files, and will get back to you as soon as possible (maybe later today, but it may possibly take me 2 or 3 days). :up:
Best regards,
Carsten
User avatar
Carsten
Site Admin
Posts:2170
Joined:2004-08-19, 13:46
Location:Germany
Contact:

Re: Gui problems:Scripted functions doesn't work on a custom

Post by Carsten » 2014-02-11, 22:08

Ok, I've got it:
The problem was that in the detail model, you used the filename ending with *_init.cgui. This however loads only the static parts of your GUI, not the custom script definitions, which are in *_main.cgui (which in turn loads the parts in *_init.cgui automatically).

So in the detail model settings, if you replace "_init" with "_main", things will work.

I'm sorry for the trouble. Should we improve the documentation so that others don't step into the same issue?

Also, I've just committed change 79f5b47 to branch entity-component-system, so that this problem is clearly seen and easily defused in the future. Please see the attached screenshot for the result: it works this way both in the Cafu Engine and in the Map Editor. :up:
Attachments
test_main_cgui.jpg
Best regards,
Carsten
Sacramento
Posts:9
Joined:2013-08-30, 19:37

Re: Gui problems:Scripted functions doesn't work on a custom

Post by Sacramento » 2014-02-18, 23:31

Yes now i can finally use my customs GUI! :D

Thank you so much Carsten :)

Should we improve the documentation so that others don't step into the same issue?
Yes please, it will be more better if we could understand more the engine dinamic by putting more detailed information about it.

i always like reading manuals and stuff to understand better what im doing, i was stuck in this problem for days :cry: .

You know, i think you should update the documentation for the current version of Cafu (some things in the teleporter tutorials does'nt fit at all :cry: ).

Again, thank you :D
User avatar
Carsten
Site Admin
Posts:2170
Joined:2004-08-19, 13:46
Location:Germany
Contact:

Re: Gui problems:Scripted functions doesn't work on a custom

Post by Carsten » 2014-02-19, 18:32

Sacramento wrote:Yes now i can finally use my customs GUI! :D

Thank you so much Carsten :)
It's good to hear that, thanks for the feedback!
Should we improve the documentation so that others don't step into the same issue?
Yes please, it will be more better if we could understand more the engine dinamic by putting more detailed information about it.
Well, I actually wrote the suggestion to update the docs before I added the extra check as displayed in the screenshot in my previous post, which kind of makes a documentation update redundant. Also please see below for another thought on docs update.
i always like reading manuals and stuff to understand better what im doing, i was stuck in this problem for days :cry: .
I too love reading good documentation... writing it is a hard job, though... :cheesy: ;-)

I'm sorry for the trouble you've had with this issue! :oops:
You know, i think you should update the documentation for the current version of Cafu (some things in the teleporter tutorials does'nt fit at all :cry: ).
Thanks for pointing that out!

Can you please tell what exactly doesn't fit? Even better, as this is a Wiki into which you can login with the same username and password as in this forum, could you please update this yourself?

Note however that there is a small issue involved: As anticipated in my news post More about Component Systems, things like these are going to change quite a bit in the future. So at this time, it is probably a good idea to fix obvious major problems in this tutorial, but any polishing and detail work should probably wait until mappers can actually assemble entities from components in the Map Editor...
Best regards,
Carsten
Sacramento
Posts:9
Joined:2013-08-30, 19:37

Re: Gui problems:Scripted functions doesn't work on a custom

Post by Sacramento » 2014-02-24, 23:31

Hi Carsten, sorry for the late reply.
Can you please tell what exactly doesn't fit? Even better, as this is a Wiki into which you can login with the same username and password as in this forum, could you please update this yourself?
here, this is a fragment code that is showing up in the
"Creating Teleporter Station" tutorial.

Code: Select all

function ButtonGo:OnMouseButtonUp()
    local origNr=OUR_NODE_NR;
    local destNr=DestNode:get("text");
 
    game.runMapCmd("teleport(" .. origNr .. ", " .. destNr .. ");");
    return true;
end
If we compare this with the example that cames with Cafu

Code: Select all

function ButtonGo:OnMouseButtonUp()
    local origNr = OUR_NODE_NR
    local destNr = DestNode:GetComponent("Text"):get("Text")

    Entity:RunMapCommand("teleport(" .. origNr .. ", " .. destNr .. ");");
    return true;
end

They are not the same, i dont know if im wrong at reading the lua language, but they are mising things like the ; or it cames with diferent sintax.

¿Im right and i must fix it? or ¿i should ignore it?
User avatar
Carsten
Site Admin
Posts:2170
Joined:2004-08-19, 13:46
Location:Germany
Contact:

Re: Gui problems:Scripted functions doesn't work on a custom

Post by Carsten » 2014-02-25, 15:36

Hi Sacramento,
Sacramento wrote:[...] If we compare this with the example that cames with Cafu

Code: Select all

function ButtonGo:OnMouseButtonUp()
    local origNr = OUR_NODE_NR
    local destNr = DestNode:GetComponent("Text"):get("Text")

    Entity:RunMapCommand("teleport(" .. origNr .. ", " .. destNr .. ");");
    return true;
end

This is the right, new and correct version.

In Lua, semicolons are largely optional, and while I used to use them in older scripts, nowadays my preferred Lua-style is to omit them wherever possible (although in the above fragment, it looks like I only changed this in lines that I actually edited, not globally in the entire script).

(The second purely stylistic change is that I now use a single space around most binary operators, e.g. a = b + 3 rather than a=b+3.)

More importantly, and this is the good news, is that the above code uses GUI components already. That in turn means that these things are already up to date, and will not need to change again when the entity component system is released.

That means, my above guess was wrong, and changes made to the related Wiki page are worthwhile. :-D

So if you don't mind, please update the Wiki page with the new code! :up:
Best regards,
Carsten
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 4 guests