Putting the 'role' back in role-playing games since 2002.
Donate to Codex
Good Old Games
  • Welcome to rpgcodex.net, a site dedicated to discussing computer based role-playing games in a free and open fashion. We're less strict than other forums, but please refer to the rules.

    "This message is awaiting moderator approval": All new users must pass through our moderation queue before they will be able to post normally. Until your account has "passed" your posts will only be visible to yourself (and moderators) until they are approved. Give us a week to get around to approving / deleting / ignoring your mundane opinion on crap before hassling us about it. Once you have passed the moderation period (think of it as a test), you will be able to post normally, just like all the other retards.

Pathfinder: Kingmaker Modding Thread

Pink Eye

Monk
Patron
Joined
Oct 10, 2019
Messages
5,797
Location
Space Refrigerator
I'm very into cock and ball torture
pink you can do tryparse
since this is used for every textbox, bag of tricks created a SettingParse method and calls it whenever. a copy of it is in gold mod.

they way you are doing is wrong you can find many examples if you google "try catch c#"

ur code ignores errors because they are inside "try". do catch(overflowexception e) goldamount="1"
so wrong input becomes 1
I just copy pasted terra's code and it worked xD
 

Efe

Erudite
Joined
Dec 27, 2015
Messages
2,597
yes but that means you didnt learn...
Isnt that the reason you arent just copy pasting existing gold mod?
 

Efe

Erudite
Joined
Dec 27, 2015
Messages
2,597
when it works it says "hey it works"
on failed attempts it aborts operation (so no crash) and returns with "its not working"
thats why you put it inside an if else block
if (Int32.TryParse(someText, out value))
{
it worked! your integer is value. do some shit.
}
else
{
didnt work! there is no value. Do your thing (like assigning value ="1" instead)
}
//Now you are %100 sure you have a working integer value.
do your + gold

There is no else block there so it doesnt do anything if input doesnt work. Later on when you want to make it fancier you will probably add error text to show.
one last thing integer has a limit dont spam absurdly big numbers at it. it might work for your textbox but gold sum inside game might overflow this time.
 

Pink Eye

Monk
Patron
Joined
Oct 10, 2019
Messages
5,797
Location
Space Refrigerator
I'm very into cock and ball torture
Okay. Now I want to add another button. One button will allow the user to add gold. The other button will allow the user to add BP. The problem is that I can't find where I can reference BP...
HfzxYGs.png
 

Efe

Erudite
Joined
Dec 27, 2015
Messages
2,597
Game is under "Kingmaker". you added that on top with
using kingmaker
I doubt you can apprend random functions under it.
---------
2 locations i see OnPurchaseBp method
Kingmaker.UI.Kingdom.KingdomPurchaseBuildPoint.OnPurchaseBp()
Kingmaker.Kingdom.IKingdomPurchaseBp.OnPurchaseBp()
My logic tells me one of them is for updating UI and other is for whatever else.. but you have no way to know besides TESTING

//Insert definition of insanity guy from far cry 3 here

so search and try one by one.
 

Pink Eye

Monk
Patron
Joined
Oct 10, 2019
Messages
5,797
Location
Space Refrigerator
I'm very into cock and ball torture
Game is under "Kingmaker". you added that on top with
using kingmaker
I doubt you can apprend random functions under it.
---------
2 locations i see OnPurchaseBp method
Kingmaker.UI.Kingdom.KingdomPurchaseBuildPoint.OnPurchaseBp()
Kingmaker.Kingdom.IKingdomPurchaseBp.OnPurchaseBp()
My logic tells me one of them is for updating UI and other is for whatever else.. but you have no way to know besides TESTING

//Insert definition of insanity guy from far cry 3 here

so search and try one by one.

Wew...
 

Efe

Erudite
Joined
Dec 27, 2015
Messages
2,597
its okay to cheat for this part
just look at what bag of tricks did.
if you want to try you can attempt doing it better LATER

so answer in your gold gain code form is
KingdomState.Instance.BP = KingdomState.Instance.BP + finalBuildPointAmount;


when using object browser there is a little gear icon to have it show variables. click that
https://imgur.com/4tbhDZe
 

Efe

Erudite
Joined
Dec 27, 2015
Messages
2,597
make 2 buttons
they both use same textbox and same variables so you just change inside of IF statement. Literally just copy BP button and paste it under gold button.

if you put buttons between UnityEngine.GUILayout.BeginHorizontal(); and UnityEngine.GUILayout.EndHorizontal(); buttons will be side by side.

Also maybe if you put everything between these they might look better. your textbox is too high up for some reason.
UnityEngine.GUILayout.BeginVertical("box");
UnityEngine.GUILayout.EndVertical();
 
Last edited:

Efe

Erudite
Joined
Dec 27, 2015
Messages
2,597
I see you have GL = on top.which is assigning a nickname to it. so you might as well use GL instead of "UnityEngine.GUILayout"

GL.BeginHorizontal after valueamount = ....

GL.EndHorizontal after 2nd IF closes (after line 40)

put GL.BeginVertical at start of OnGUI
put GL.EndVertical at end of OnGUI
so everything in OnGUI is listed vertically while buttons are side by side on same line.
 

Efe

Erudite
Joined
Dec 27, 2015
Messages
2,597
i dont understand why you dont include usings on top in your pastebin. are you that sure they arent the problem?

try adding using UnityEngine; on top next to other usings


if you mouse over red marked parts a yellow lightbulb comes up. if you click on it it shows you "potential" fixes. its machine work so it doesnt do miracles but quite good to fix syntax or referencing errors.
it tells you to add "using UnityEngine"
 

As an Amazon Associate, rpgcodex.net earns from qualifying purchases.
Back
Top Bottom