Recommended Posts

Fidu    10

holy crap... you are my hero(ine)

Finally. And i even understand why now. Thank you oh so very very much for everything. I hope you have a great day and get some similar satisfying feelings like myself right now. I am so glad. Even though it's easy for you my head hurts ^^. But i also feel like i learned a lot. And i am just happy the mod works and is (imho) massively improved with this feature.

And for anybody who might need it here is the final and correct code (with the return near the end ;) ):

Spoiler

local function ToggleMoggleRPC(inst)
    if inst.TransformState == 1 then 
    inst.components.talker:Say("I can smell it!", 2.5,true)
    else inst.components.talker:Say("I can't smell anything!", 2.5,true)
    return
    end
    inst.player_classified.mogglevision:set(not inst.components.playervision.forcenightvision)
    print(inst.components.playervision.forcenightvision)
end

 

Little bug i noticed.

When i am in State 1 and have mogglevision active and then change states the vision stays activated no matter what i do. I understand that the keyfunction just doesn't work anymore because thats intended.

But how can i make it so mogglevision gets canceled no matter if its activated or not when the other states trigger?

I think i need something that just does the opposite of "return" in this case.

Or just a function that cancels mogglevision when he is in State 2 or State 3.

Share this post


Link to post
Share on other sites
Ultroman    340

I'm sure you'll figure it out :)

I just wanted to chime in and say that structure and indentation does wonders for readability and understanding what your code is actually doing.

local function ToggleMoggleRPC(inst)
    if inst.TransformState == 1 then 
    inst.components.talker:Say("I can smell it!", 2.5,true)
    else inst.components.talker:Say("I can't smell anything!", 2.5,true)
    return
    end
    inst.player_classified.mogglevision:set(not inst.components.playervision.forcenightvision)
    print(inst.components.playervision.forcenightvision)
end

versus

local function ToggleMoggleRPC(inst)
	if inst.TransformState == 1 then 
		inst.components.talker:Say("I can smell it!", 2.5, true)
	else
		inst.components.talker:Say("I can't smell anything!", 2.5, true)
		return
	end
	inst.player_classified.mogglevision:set(not inst.components.playervision.forcenightvision)
	print(inst.components.playervision.forcenightvision)
end

 

  • Thanks 1

Share this post


Link to post
Share on other sites
Fidu    10
Posted (edited)

Thank you Ultroman,

and you are absolutely right. I just thought i already structured it but you showed me how to improve. thanks a lot.

i am not sure if i'll figure it out myself but won't try it today either way ^^. I am busted and my brain hurts XD.

Still i want to fix it... and i hope i can ask again if i can't figure it out. but like i said, it's enough for a day.

It's still an improved version so i reuploaded it:

https://steamcommunity.com/sharedfiles/filedetails/?id=1662813017

Edited by Fidu
  • Like 1

Share this post


Link to post
Share on other sites
Ultroman    340

Yeah, code gets pretty complicated in itself. No reason to help it be even more complicated :)

Of course you can ask :) I don't consider this thread closed, and I'm sure the ever-amazing Yakumo doesn't either. I just don't have time to actually help right now. Kinda swamped the next two weeks.

  • Like 1

Share this post


Link to post
Share on other sites
Fidu    10
Posted (edited)

Ok i know what i wanna do but not exactly how.

I wanna make a variable for mogglevision. (or use one thats already there, if i can figure that out)

After that i just use this variable (like: inst.mogglevision) and simply set this to "false" under the Transformstates 2 and 3 in the quanyecha.lua.

example of idea:

inst.transformstate = 3
inst.mogglevision:enable(false)

In my mind this would make it so when state 2 or 3 triggers the mogglevision gets canceled regardless if already active.

ps: i am only recently able to even have such thoughts because of all the stuff i learned today. Yes this is a compliment 

Edited by Fidu

Share this post


Link to post
Share on other sites
Fidu    10

Sadly i got to report back that your faith in me, and myself, seemed to be misplaced :(
Even though i learned a lot and understand more and more how things work, i am still unable to translate that in an actual working format.

I tried everything i could think of and that was quite a lot...
Even reading some more about functions in general like here: http://lua-users.org/wiki/FunctionsTutorial

But still to no avail.

I tried setting different functions from the mogglevision code in modmain.lua to false in the quenyecha.lua ... error
i tried to tell states 3 and 2 to simply don't use the "nightvision_colourcubes" when triggered... error
I tried to reverse the mogglevision function from modmain in the transformstates in quanyecha... error

As it stands now i still do lack the knowledge what needs to be where and how it must be written exactly for that case to do what i want.

I think i am not on the wrong track completely, but it still is quite frustrating that i still can't fix it myself. :( 
I get a feeling i would need a lot more time on my hands for this to work out properly than i have right now.

I hope you are not as dissapointed as myself at this point and still wanna gimme the right example of how it should be done to work, because i still love this character so much and playing around with it, trying to improve things (that i am actual capable of). I surely should refrain from doing to complicated things that demand a knowledge only you guys here possess.

Share this post


Link to post
Share on other sites
Ultroman    340

We can make it work at some point. I don't have time right now, but others do. And it sounds like you just need some more time with LUA tutorials. Did you take the LUA Crash Course? That site has a lot more than the crash course, but it's a great place to start. Just start practicing a bit with simpler things. You'll get the hang of it.

  • Thanks 1

Share this post


Link to post
Share on other sites
Fidu    10
Posted (edited)

I'll take a look at it and thank you for the kind words. Regarding the support of others... i hope so.

ps: in my opinion the simplest way of fixing this little bug would be:

When state 2 or state 3 triggers the "standart" vision activates. Or the vision is reset to standart. But i just don't know the code for that (maybe) simple function.

Edited by Fidu

Share this post


Link to post
Share on other sites
Fidu    10

I inserted the following code (bold) into the character.lua. It seems to work at first: moggle vision is active, the character changes into state 2 and moggle vision is canceled but than the mogglevision function stops working completely and doesn't do anything anymore no matter what state i am in.

Spoiler

inst.AnimState:SetBuild("quanyecharumo")
        inst.TransformState = 2
        
        inst.components.playervision:ForceNightVision(false)
        inst.components.playervision:SetCustomCCTable(nil)

 

Share this post


Link to post
Share on other sites
Fidu    10

Another bug i noticed:

Even though it's a local function in the modmain.lua... in line 387

Spoiler

local function ToggleMoggleRPC(inst)
    if     inst.TransformState == 1 then 
            inst.components.talker:Say("I can smell it!", 2.5,true)
    else     inst.components.talker:Say("I can't smell anything!", 2.5,true)
    return
    end
    inst.player_classified.mogglevision:set(not inst.components.playervision.forcenightvision)
    print(inst.components.playervision.forcenightvision)
end
AddModRPCHandler("globalfun", "togglemoggle", ToggleMoggleRPC)
 

When i play with a totaly different character and press the "x" key the character says I can't smell anything. Even though Inuyasha is not even in the same world (i play solo in dst).

modmain.lua

Share this post


Link to post
Share on other sites
Fidu    10

Is there any kind soul out there who is able to fix those two things, which are actually one...?

I just can't do it. And when it's fixed the mod would be perfectly fine imho.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now