~ Forums of Enroth ~
Would you like to react to this message? Create an account in a few clicks or log in to continue.

~ Forums of Enroth ~

The Enroth diehard fan community
 
HomeHome  Latest imagesLatest images  SearchSearch  RegisterRegister  Log inLog in  
Latest topics
» [H3SW 0.8.2] Spicy Delivery
[Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Icon_minitimeby DanilaRud015 2024-07-25, 23:37

» ...to XP run...
[Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Icon_minitimeby Darmani 2024-07-18, 21:34

» fheroes2 General Announcements
[Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Icon_minitimeby sirDranik 2024-07-15, 00:28

» Silence of the Siren (HoMM like scifi game)
[Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Icon_minitimeby Sir Albe 2024-07-13, 08:09

» Songs of Silence (HoMM like game)
[Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Icon_minitimeby Blake01 2024-07-07, 21:12

» Lego Heroes of Might & Magic
[Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Icon_minitimeby Blake01 2024-07-07, 21:00

» 5Kings1Ring
[Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Icon_minitimeby GodRage 2024-07-01, 10:33

Poll
Global announcements should be:
Everlasting, 1 for each project.
[Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Redbar110%[Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Redbar12
 0% [ 0 ]
Temporary, when there is something new to announce.
[Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Redbar11100%[Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Redbar12
 100% [ 6 ]
Holalala... No idea where the Ultimate artifact is.
[Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Redbar110%[Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Redbar12
 0% [ 0 ]
Total Votes : 6
Most Viewed Topics
H3SW: General Graphics discussion
Ragoon's Graphics For HoMM3SW
Introduce yourself
H3SW General Discussion
H3SW Map List: Work in progress
H3SW: Dwelling Development
Forum Admins Feed
The Floody Land
Enrothian Fan Art
Heroes III: The Succession Wars v0.8.2 Beta

 

 [Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"?

Go down 
3 posters
AuthorMessage
Unknown_Hero
Mage
Mage
Unknown_Hero


Messages : 780
Quality Points : 78
Registration Date : 2015-09-06

[Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Empty
PostSubject: [Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"?   [Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Icon_minitime2018-09-25, 22:26

Is there a way to make the Advanced Message Box work like the Question Box?

I tried this, the one with Question Box works, but there is no picture.

Code:
hero = GetCurrentHero();  
if HasArtifact(hero, ARTIFACT_MEDAL_OF_HONOR) == false and CountEmptyArtifactSlots(hero) >= 1 then
  result = QuestionBox("Do you wish the Medal of Honor?");
  if result then
    GrantArtifact(hero, ARTIFACT_MEDAL_OF_HONOR);
  end;
end;

With Advanced Message Box, the picture is there but it does not work.

Code:
hero = GetCurrentHero();  
if HasArtifact(hero, ARTIFACT_MEDAL_OF_HONOR) == false and CountEmptyArtifactSlots(hero) >= 1 then
  result = AdvancedMessageBox("Do you wish the Medal of Honor?", 2, -1, -1, 7, ARTIFACT_MEDAL_OF_HONOR, -1, 0, -1, 0);
  if result then
    GrantArtifact(hero, ARTIFACT_MEDAL_OF_HONOR);
  end;
end;

Any ideas?
Back to top Go down
DarkAtom
Pikeman
Pikeman
DarkAtom


Messages : 47
Quality Points : 6
Registration Date : 2018-02-27

[Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Empty
PostSubject: Re: [Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"?   [Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Icon_minitime2018-12-25, 05:29

Unknown_Hero wrote:
Is there a way to make the Advanced Message Box work like the Question Box?

I tried this, the one with Question Box works, but there is no picture.

Code:
hero = GetCurrentHero();  
if HasArtifact(hero, ARTIFACT_MEDAL_OF_HONOR) == false and CountEmptyArtifactSlots(hero) >= 1 then
  result = QuestionBox("Do you wish the Medal of Honor?");
  if result then
    GrantArtifact(hero, ARTIFACT_MEDAL_OF_HONOR);
  end;
end;

With Advanced Message Box, the picture is there but it does not work.

Code:
hero = GetCurrentHero();  
if HasArtifact(hero, ARTIFACT_MEDAL_OF_HONOR) == false and CountEmptyArtifactSlots(hero) >= 1 then
  result = AdvancedMessageBox("Do you wish the Medal of Honor?", 2, -1, -1, 7, ARTIFACT_MEDAL_OF_HONOR, -1, 0, -1, 0);
  if result then
    GrantArtifact(hero, ARTIFACT_MEDAL_OF_HONOR);
  end;
end;

Any ideas?

Looking through the code of Ironfist, I found this:
Code:
static int l_AdvancedMessageBox(lua_State *L) {
  const char* msg = luaL_checkstring(L, 1);
  int yesno = luaL_checkinteger(L, 2);
  int horizontal = luaL_checkinteger(L, 3);
  int vertical = luaL_checknumber(L, 4);
  int img1type = luaL_checknumber(L, 5);
  int img1arg = luaL_checknumber(L, 6);
  int img2type = luaL_checknumber(L, 7);
  int img2arg = luaL_checknumber(L, 8);
  int writeOr = luaL_checknumber(L, 9);
  int a10 = luaL_checknumber(L, 10);
  NormalDialog((char*)msg, (int)yesno, (int)horizontal, (int)vertical, (int)img1type, (int)img1arg, (int)img2type, (int)img2arg, (int)writeOr, (int)a10);
  return 0;
}
(You can find this in src\cpp\shared\scripting\funcs.cpp at lines 75 to 88)

This clearly means that the function always returns 0 and doesn't care about anything that is passed to it. The return value of NormalDialog(...) is neglected here.

You can also see in the file that for the QuestionBox it calls H2QuestionBox()  (which is just a wrapper function of NormalDialog()) and it stores the result by calling lua_pushboolean()). So AdvancedMessageBox doesn't return anything.
Back to top Go down
Unknown_Hero
Mage
Mage
Unknown_Hero


Messages : 780
Quality Points : 78
Registration Date : 2015-09-06

[Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Empty
PostSubject: Re: [Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"?   [Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Icon_minitime2018-12-25, 08:08

Okay, thanks for your discovery and explanation. Smile
I hope the Ironfist team will remedy this so that we can use the full potential of the Advanced Message Box.

I used your hint to display +1 for the hero's primary skills with the Advanced Message Box.

"Image subtypes (the number in the list represents the type for which the subtype applies)
...
25: 0-3 (Attack, Defense, Spell Power, Knowledge) (100-103 displays a +1 skill)"

I made a post about it in the related thread.
Back to top Go down
Darmani
Master Modder
Master Modder
Darmani


Messages : 289
Quality Points : 47
Registration Date : 2014-12-27

[Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Empty
PostSubject: Re: [Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"?   [Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Icon_minitime2018-12-31, 15:49

DarkAtom: To clarify, "return 0" in a Lua callback actually means that it returns no values, not that it returns 0. Returning 0 would be "lua_pushinteger(L, 0)" or similar.
Back to top Go down
DarkAtom
Pikeman
Pikeman
DarkAtom


Messages : 47
Quality Points : 6
Registration Date : 2018-02-27

[Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Empty
PostSubject: Re: [Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"?   [Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Icon_minitime2019-01-02, 02:27

I know that, but if the C++ function says: return 0; then you can push as many integers as you want on the lua stack, none of them will get passed. You need to push the integer and return 1, not 0, to return a value in lua.
Back to top Go down
Sponsored content





[Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Empty
PostSubject: Re: [Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"?   [Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"? Icon_minitime

Back to top Go down
 
[Ironfist ver 1.3.0] How to make "Advanced Message Box" work like "Question Box"?
Back to top 
Page 1 of 1
 Similar topics
-
» Make changes to creatures.xml file
» [Ironfist ver 1.2] Ironfist Editor - Where is my mouse?
» [Ironfist ver 1.3.0] What is the best compatibility setting for ironfist.exe?
» Great work!
» [Script System][Suggestions] StopHeroMove()

Permissions in this forum:You cannot reply to topics in this forum
~ Forums of Enroth ~ :: Modding Guild :: Heroes of Might and Magic II: Project Ironfist :: Modding and Mapmaking-
Jump to: