EXP to Level

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
KiritoSanPlays
Posts: 28
Joined: 13 Jun 2018, 16:24

EXP to Level

22 Oct 2018, 20:03

So i am in need of some help over here
I am making a program which helps me calculate price from exp to level

So i have to fill in current experience then i have to fill in a goal level then it has to find the difference between these values but the goal level has to be read out of a ini file which i already made

then it has to calculate the price depending on the experience between the current exp and goal level then it has to check what skill

so a better way to explain it is

This is the exp table which contains each level aswell as the experience to that level written in a ini format

Code: Select all

[Exp]
Level-1=0
Level-2=83
Level-3=174
Level-4=276
Level-5=388
Level-6=512
Level-7=650
Level-8=801
Level-9=969
Level-10=1154
Level-11=1384
Level-12=1584
Level-13=1833
Level-14=2107
Level-15=2411
Level-16=2746
Level-17=3115
Level-18=3523
Level-19=3973
Level-20=4470
Level-21=5018
Level-22=5624
Level-23=6291
Level-24=7028
Level-25=7842
Level-26=8740
Level-27=9730
Level-28=10824
Level-29=12031
Level-30=13363
Level-31=14833
Level-32=16456
Level-33=18247
Level-34=20224
Level-35=22406
Level-36=24815
Level-37=27473
Level-38=30408
Level-39=33648
Level-40=37224
Level-41=41171
Level-42=45529
Level-43=50339
Level-44=55649
Level-45=61512
Level-46=67983
Level-74=1096278
Level-48=83014
Level-49=91721
Level-50=101333
Level-51=111945
Level-52=123660
Level-53=136594
Level-54=150872
Level-55=166636
Level-56=184040
Level-57=203254
Level-58=224466
Level-59=247886
Level-60=273742
Level-61=302288
Level-62=333804
Level-63=368599
Level-64=407015
Level-65=449428
Level-66=496254
Level-67=547953
Level-68=605032
Level-69=668051
Level-70=737627
Level-71=814445
Level-72=899257
Level-73=992895
Level-75=1210421
Level-76=1336443
Level-77=1475581
Level-78=1629200
Level-79=1798808
Level-80=1986068
Level-81=2192818
Level-82=2421087
Level-83=2673114
Level-84=2951373
Level-85=3258594
Level-86=3597792
Level-87=3972294
Level-88=4385776
Level-89=4842295
Level-90=5346332
Level-91=5902831
Level-92=6517253
Level-93=7195629
Level-94=7944614
Level-95=8771558
Level-96=9684577
Level-97=10692629
Level-98=11805606
Level-99=13034431



and this is the code i currently have

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.



Home:
Gui, Home:Add, DropDownList, x5 y25 w125 h90 vSkill Choose1, Attack|Hitpoints|Mining|Strenght|Agility|Smithing|Defence|Herblore|Fishing|Ranged|Thieving|Cooking|Prayer|Crafting|Firemaking|Magic|Fletching|Woodcutting|Runecrafting|Slayer|Farming|Construction|Hunter
Gui, Home:Add, Text, x5 y10 w100 h15, Skill Requested:
Gui, Home:Add, Edit, x5 y75 w125 h20 vCurrentEXP, Current EXP
Gui, Home:Add, Text, x5 y60 w115 h15, Current EXP:
Gui, Home:Add, Text, x135 y80 w10 h10, ->
Gui, Home:Add, Edit, x155 y75 w44 h21 vGoal, Goal
Gui, Home:Add, Text, x155 y60 w75 h15, Goal Level:
Gui, Home:Add, Text, x5 y105 w200 h15, Price:
Gui, Home:Add, Edit, x5 y120 w230 h20 vPrice, Price
Gui, Home:Add, Text, x5 y145 w225 h15, Custommer Name:
Gui, Home:Add, Edit, x5 y160 w230 h20 vName, Name
Gui, Home:Add, Button, x250 y165 w43 h23 gSave, Save
Gui, Home:Show, w295 h189, OSRS Skill Service
return

HomeGuiClose:
ExitApp






Save:
Gui,Home:Submit,NoHide
IniWrite,%Name%,%A_WorkingDir%/Services/%Name%-Service.ini,Service,Name
IniWrite,%Skill%,%A_WorkingDir%/Services/%Name%-Service.ini,Service,Skill
IniWrite,%CurrentEXP%,%A_WorkingDir%/Services/%Name%-Service.ini,Service,Current-EXP
IniWrite,%Goal%,%A_WorkingDir%/Services/%Name%-Service.ini,Service,Goal
IniWrite,%Price%,%A_WorkingDir%/Services/%Name%-Service.ini,Service,Total-Price
return

for each skill there is a different price per 1 exp so thats the way it has to calculate the total price
Last edited by KiritoSanPlays on 22 Oct 2018, 20:45, edited 2 times in total.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: EXP to Level

22 Oct 2018, 20:05

themes are not fully operational yet and spoilers are broken, take whatever is in the spoilers out, otherwise no one can see it
KiritoSanPlays
Posts: 28
Joined: 13 Jun 2018, 16:24

Re: EXP to Level

22 Oct 2018, 20:09

swagfag wrote:
22 Oct 2018, 20:05
themes are not fully operational yet and spoilers are broken, take whatever is in the spoilers out, otherwise no one can see it
damn yeh i think they are broken due the overhaul :/ gimme a sec


Removed the spoilers :)
KiritoSanPlays
Posts: 28
Joined: 13 Jun 2018, 16:24

Re: EXP to Level

23 Oct 2018, 06:48

still didn't find what i need :/
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: EXP to Level

23 Oct 2018, 09:32

assuming levels.ini exists in working dir:

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

Home:
Gui, Home:Add, DropDownList, x5 y25 w125 h90 vSkill Choose1, Attack|Hitpoints|Mining|Strenght|Agility|Smithing|Defence|Herblore|Fishing|Ranged|Thieving|Cooking|Prayer|Crafting|Firemaking|Magic|Fletching|Woodcutting|Runecrafting|Slayer|Farming|Construction|Hunter
Gui, Home:Add, Text, x5 y10 w100 h15, Skill Requested:
Gui, Home:Add, Edit, x5 y75 w125 h20 vCurrentEXP, Current EXP
Gui, Home:Add, Text, x5 y60 w115 h15, Current EXP:
Gui, Home:Add, Text, x135 y80 w10 h10, ->
Gui, Home:Add, Edit, x155 y75 w44 h21 vGoal, Goal
Gui, Home:Add, Text, x155 y60 w75 h15, Goal Level:
Gui, Home:Add, Text, x5 y105 w200 h15, Price:
Gui, Home:Add, Edit, x5 y120 w230 h20 vPrice, Price
Gui, Home:Add, Text, x5 y145 w225 h15, Custommer Name:
Gui, Home:Add, Edit, x5 y160 w230 h20 vName, Name
Gui, Home:Add, Button, x250 y165 w43 h23 gSave, Save
Gui, Home:Show, w295 h189, OSRS Skill Service

LevelsExp := LevelsExpFromINI()
return

HomeGuiClose:
	ExitApp
return

Save:
Gui,Home:Submit,NoHide
; IniWrite,%Name%,%A_WorkingDir%/Services/%Name%-Service.ini,Service,Name
; IniWrite,%Skill%,%A_WorkingDir%/Services/%Name%-Service.ini,Service,Skill
; IniWrite,%CurrentEXP%,%A_WorkingDir%/Services/%Name%-Service.ini,Service,Current-EXP
; IniWrite,%Goal%,%A_WorkingDir%/Services/%Name%-Service.ini,Service,Goal
; IniWrite,%Price%,%A_WorkingDir%/Services/%Name%-Service.ini,Service,Total-Price

ExpAtGoal := LevelsExp[Goal]
ExpUntilGoal := ExpAtGoal - CurrentEXP
mock_PricePerExp := 5
Price := ExpUntilGoal * mock_PricePerExp

MsgBox % Format("
(LTrim
	goal: {}
	exp at goal: {}
	current exp: {}
	exp until goal: {}
	price per exp: {}
	price total: {}
)", Goal, ExpAtGoal, CurrentEXP, ExpUntilGoal, mock_PricePerExp, Price)
return

ini_read(file, section, key) {
	IniRead RetVal, % file, % section, % key
	return RetVal
}

LevelsExpFromINI() {
	RetVal := []
	while ((val := ini_read("levels.ini", "Exp", "Level-" A_Index)) != "ERROR")
		RetVal.Push(val)

	return RetVal
}
also ur levels are missing an entry for 47. its been replaced by a misplaced 74, but the 47 doesnt exist
User avatar
YoucefHam
Posts: 372
Joined: 24 Aug 2015, 12:56
Location: Algeria
Contact:

Re: EXP to Level

23 Oct 2018, 18:17

Hi bro :wave: , I didn't use AHK for a while, so I wanted to train on your script.
Try it. :thumbup:

[Level.INI]

Code: Select all

[SkillPrice]
Attack=10
Hitpoints=15
Mining=20
Strenght=25
Agility=30
Smithing=35
Defence=40
Herblore=45
Fishing=50
Ranged=55
Thieving=60
Cooking=65
Prayer=70
Crafting=75
Firemaking=80
Magic=85
Fletching=90
Woodcutting=95
Runecrafting=100
Slayer=105
Farming=110
Construction=115
Hunter=120

[Exp]
Level-1=0
Level-2=83
Level-3=174
Level-4=276
Level-5=388
Level-6=512
Level-7=650
Level-8=801
Level-9=969
Level-10=1154
Level-11=1384
Level-12=1584
Level-13=1833
Level-14=2107
Level-15=2411
Level-16=2746
Level-17=3115
Level-18=3523
Level-19=3973
Level-20=4470
Level-21=5018
Level-22=5624
Level-23=6291
Level-24=7028
Level-25=7842
Level-26=8740
Level-27=9730
Level-28=10824
Level-29=12031
Level-30=13363
Level-31=14833
Level-32=16456
Level-33=18247
Level-34=20224
Level-35=22406
Level-36=24815
Level-37=27473
Level-38=30408
Level-39=33648
Level-40=37224
Level-41=41171
Level-42=45529
Level-43=50339
Level-44=55649
Level-45=61512
Level-46=67983
Level-47=77983
Level-48=83014
Level-49=91721
Level-50=101333
Level-51=111945
Level-52=123660
Level-53=136594
Level-54=150872
Level-55=166636
Level-56=184040
Level-57=203254
Level-58=224466
Level-59=247886
Level-60=273742
Level-61=302288
Level-62=333804
Level-63=368599
Level-64=407015
Level-65=449428
Level-66=496254
Level-67=547953
Level-68=605032
Level-69=668051
Level-70=737627
Level-71=814445
Level-72=899257
Level-73=992895
Level-74=1096278
Level-75=1210421
Level-76=1336443
Level-77=1475581
Level-78=1629200
Level-79=1798808
Level-80=1986068
Level-81=2192818
Level-82=2421087
Level-83=2673114
Level-84=2951373
Level-85=3258594
Level-86=3597792
Level-87=3972294
Level-88=4385776
Level-89=4842295
Level-90=5346332
Level-91=5902831
Level-92=6517253
Level-93=7195629
Level-94=7944614
Level-95=8771558
Level-96=9684577
Level-97=10692629
Level-98=11805606
Level-99=13034431
[Script.AHK]

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.



Gui, Home:Add, Text, x10 y10, Skill Requested:
Gui, Home:Add, DropDownList, y+2 w100 g_SkillPrice v_Skill Choose1, Attack|Hitpoints|Mining|Strenght|Agility|Smithing|Defence|Herblore|Fishing|Ranged|Thieving|Cooking|Prayer|Crafting|Firemaking|Magic|Fletching|Woodcutting|Runecrafting|Slayer|Farming|Construction|Hunter

Gui, Home:Add, Text, y+4, Current EXP:
Gui, Home:Add, Edit, y+2 w100 g_GetCurrentLvl
Gui, Home:Add, UpDown, v_CurrentEXP Range0-13034431, 500

Gui, Home:Submit, NoHide
_GetCurrentLvl()

Gui, Home:Add, Text, y+4 , Goal Level:
Gui, Home:Add, Edit, y+2 w100 g_GetPrice
Gui, Home:Add, UpDown, v_GoalLvl Range1-99,  % _CurrentLvl

Gui, Home:Add, Text, x+5 h21, ->

Gui, Home:Add, Text, x10 y+4, Custommer Name:
Gui, Home:Add, Edit, y+2 w178 v_Name, User

Gui, Home:Add, Button, x+4 h21 gSave, Save

Gui, Home:Add, Text, x130 y10, Price Of 1 Exp:
Gui, Home:Add, Edit, y+2 w100 ReadOnly v_PriceOfOneExp, 10

Gui, Home:Add, Text, y+4, Current Level:
Gui, Home:Add, Edit, y+2 w100 v_CurrentLvl ReadOnly,  % _CurrentLvl

Gui, Home:Add, Text, y+4, Price:
Gui, Home:Add, Edit, y+2 w100  ReadOnly v_PriceToGetNextLvl, 0

Gui, Home:Show,, OSRS Skill Service
return

HomeGuiClose:
	ExitApp
return


_SkillPrice:
	Gui, Home:Submit, NoHide
	_PriceOfOneExp := _IniReadSkill(_Skill)
	GuiControl,Home:, _PriceOfOneExp, % _PriceOfOneExp
	gosub _GetPrice
return


_GetCurrentLvl:
	Gui, Home:Submit, NoHide
	if (_CurrentLvl >= 0) and (_CurrentLvl <= 13034431)
		GuiControl,Home:, _CurrentLvl, % _GetCurrentLvl()
	gosub _GetPrice
return


_GetPrice:
	Gui, Home:Submit, NoHide
	IfLessOrEqual, _GoalLvl, % _GetCurrentLvl()
	{
		GuiControl,Home:, _PriceToGetNextLvl, 0
		return
	}
	GuiControl,Home:, _PriceToGetNextLvl, % _GetExpPrice()
return


Save:
	Gui,Home:Submit,NoHide
	IfNotExist, Services
		FileCreateDir, Services
	_iniSave("_Name")
	_iniSave("_Skill")
	_iniSave("_PriceOfOneExp")
	_iniSave("_CurrentLvl")
	_iniSave("_CurrentEXP")
	_iniSave("_GoalLvl")
	_iniSave("_ExpToGoalLvl")
	_iniSave("_PriceToGetNextLvl")
return


_iniSave(Var,Var2:="")
{
	global _Name
	IniWrite,% %Var%, Services\%_Name%-Service.ini, Service, % Var
}

_GetCurrentLvl()
{
	global _CurrentEXP,_CurrentLvl
	Loop, 99
	{
		_Lvl := A_Index
		_LvlExp := _IniReadExp(_Lvl)
		if (_LvlExp > _CurrentEXP)
		{
			_CurrentLvl := _Lvl - 1
			break
		}
	}
	return % _CurrentLvl
}

_GetExpPrice()
{
	global _CurrentEXP, _GoalLvl, _PriceOfOneExp, _ExpToGoalLvl
	_ExpToNextLvl := _LvlExp - _CurrentEXP
	_GoalLvlExp := _IniReadExp(_GoalLvl)
	_ExpToGoalLvl := _GoalLvlExp - _CurrentEXP
	_PriceToGetNextLvl := _ExpToGoalLvl * _PriceOfOneExp
	return % _PriceToGetNextLvl
}

_IniReadExp(Lvl)
{
	IniRead, var, Level.INI, Exp, Level-%Lvl%
	return % var
}

_IniReadSkill(SkillName)
{
	IniRead, var, Level.INI, SkillPrice, % SkillName
	return % var
}
:wave: There is always more than one way to solve a problem. ;)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, inseption86, jaka1, metallizer, rc76, Rohwedder and 317 guests