Ask a simple question, get a simple answer

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
ratman
Posts: 158
Joined: Fri Jan 10, 2020 1:13 am

Re: Ask a simple question, get a simple answer

Post by ratman »

7Soul wrote: Sun Nov 15, 2020 7:21 pm
ratman wrote: Sun Nov 15, 2020 5:52 pm Thanks, I guess I'll just make it so it gives a trait every time.
*what about how to make it so the skills cost more points the higher the level?
In the functions.lua of my mod, look for addSkillTemp, removeSkillTemp and clearSkillTemp. The line champion:setSkillPoints(champion:getSkillPoints() - 1) takes away one point. You can add a check for how many skill points the champion has and compare with the skill level, then make it subtract the skill level from it instead of 1
Sorry, I'm not very good at scripting- First of all, do I need to put the functions addSkillTemp, removeSkillTemp and clearSkillTemp into a file or something? and second how would I
add a check for how many skill points the champion has and compare with the skill level, then make it subtract the skill level from it instead of 1
User avatar
7Soul
Posts: 199
Joined: Sun Oct 19, 2014 1:56 am
Location: Brazil

Re: Ask a simple question, get a simple answer

Post by 7Soul »

ratman wrote: Sun Nov 15, 2020 7:50 pm Sorry, I'm not very good at scripting- First of all, do I need to put the functions addSkillTemp, removeSkillTemp and clearSkillTemp into a file or something? and second how would I
add a check for how many skill points the champion has and compare with the skill level, then make it subtract the skill level from it instead of 1
When you see that in init.lua "addSkillTemp" is being called as "functions.script.addSkillTemp" that means there's a script object in the game that's named "functions" with that function name. You also need to import the script file in init like "import "mod_assets/scripts/functions.lua""

Use https://github.com/JKos/log2doc/wiki/Ob ... s#champion methods to get skill level, and you know, "if" conditions
Join the LoG discord server: https://discord.gg/ArgAgNN :D

My Mods
User avatar
ratman
Posts: 158
Joined: Fri Jan 10, 2020 1:13 am

Re: Ask a simple question, get a simple answer

Post by ratman »

How would I modify your OnDrawSkills so that it doesn't have all the new graphics and just the old skill system except it calls addSkillTemp, removeSkillTemp and clearSkillTemp?
User avatar
7Soul
Posts: 199
Joined: Sun Oct 19, 2014 1:56 am
Location: Brazil

Re: Ask a simple question, get a simple answer

Post by 7Soul »

ratman wrote: Mon Nov 16, 2020 12:24 am How would I modify your OnDrawSkills so that it doesn't have all the new graphics and just the old skill system except it calls addSkillTemp, removeSkillTemp and clearSkillTemp?
You might be able to get away with only covering the buttons instead

Line 1854 is what covers the skills area so you can't click on the original buttons, so you should be able to make it only cover the bottom part.
https://github.com/JKos/log2doc/wiki/Ob ... icscontext for info on the "context" class
Join the LoG discord server: https://discord.gg/ArgAgNN :D

My Mods
User avatar
ratman
Posts: 158
Joined: Fri Jan 10, 2020 1:13 am

Re: Ask a simple question, get a simple answer

Post by ratman »

7Soul wrote: Mon Nov 16, 2020 1:34 am
ratman wrote: Mon Nov 16, 2020 12:24 am How would I modify your OnDrawSkills so that it doesn't have all the new graphics and just the old skill system except it calls addSkillTemp, removeSkillTemp and clearSkillTemp?
You might be able to get away with only covering the buttons instead

Line 1854 is what covers the skills area so you can't click on the original buttons, so you should be able to make it only cover the bottom part.
https://github.com/JKos/log2doc/wiki/Ob ... icscontext for info on the "context" class
Perhaps I didn't explain it well: I want the skill interface to look the same as it normally does, all I need to do in OnDrawSkills is make it call addSkillTemp, removeSkillTemp and clearSkillTemp at the appropriate time, but I do not know how to script this or when to call them. Or maybe I just don't understand at all.
User avatar
7Soul
Posts: 199
Joined: Sun Oct 19, 2014 1:56 am
Location: Brazil

Re: Ask a simple question, get a simple answer

Post by 7Soul »

Yeah I understood. Although now that I think about it, my solution wouldn't be enough
The thing is, you can't change how the system works (aka click skill to call a function), which is why my method is to replace all the buttons with my own. But the solution I gave above doesn't take into account clicking on the skills
You don't need to use my graphics, you can access the default graphics elements (boxes, buttons, etc) with GraphicsContext.drawGuiItem(item, x, y) and reference the names in here: https://github.com/JKos/log2doc/wiki/GuiItems but yeah it's still a lot of work
Join the LoG discord server: https://discord.gg/ArgAgNN :D

My Mods
User avatar
ratman
Posts: 158
Joined: Fri Jan 10, 2020 1:13 am

Re: Ask a simple question, get a simple answer

Post by ratman »

I try to use yours with one line modified, but it gives me error "attempt to index global 'GraphicsContext' (a nil value)
Line that gives error:

GraphicsContext.drawGuiItem(SkillsTab, w - (548 * f2), 287 * f2, 0, 0, 510, 292, 510*f2, 292*f2)

full party definition:

Code: Select all

defineObject{
	name = "party",
	baseObject = "party",
	components = {
		{
			class = "Timer",
			name = "timeSlowTimer",
			timerInterval = 30,
			disableSelf = true,
			enabled = false,
			onActivate = function(self)
				zim_functions.script:timeNormal()
			end,
		},
		{
			class = "Timer",
			name = "targetSpellUpTime",
			timerInterval = 10,
			disableSelf = true,
			enabled = false,
			onActivate = function(self)
				zim_target_ally.script.cancelledSpell()
			end,
		},
		{
			class = "Timer",
			name = "toxicItemTimer",
			timerInterval = 5,
			enabled = false,
			onActivate = function(self)
				if not zim_functions.script.toxicItemDamage() then self:disable() end
			end,
		},
		{
			class = "Null",
			name = "isScoped",
			enabled = false,
		},
		{

			class = "Controller",
			onActivate = function(self)
				self.go.particle:fadeIn(3)
			end,
			onDeactivate = function(self)
				self.go.particle:fadeOut(1)
			end,
			onToggle = function(self)
				if self.go.particle:isEnabled() then
					self.go.particle:fadeOut(1)
				else
					self.go.particle:fadeIn(3)
				end
			end,
		},	
		{
       class = "Particle",
		 name = "snow",
		 ParticleSystem = "sx_snow_emitter_party",
     },
		{
			class = "Particle",
			name = "rain",
			particleSystem = "sx_rain_emitter_party",
		},
		{
			class = "Sound",
			name = "rainsound",
			sound = "sx_rain_loop"
		},
		{

			class = "Sound",
			name = "flute",
			sound = "null",
		},
		{
			class = "Party",




		onDrawSkills = function(self, context, champion)
			local customSkills = true
			if customSkills then
				local w, h, r = context.width, 		context.height, 	context.width / context.height
				local f = (r < 1.3 and 0.8 or r < 1.4 and 0.9 or 1) * context.height/1080
				local f2 = (context.height/1080)
				local MX, MY = context.mouseX, context.mouseY
				-- Cover original skill window up
		GraphicsContext.drawGuiItem(SkillsTab, w - (548 * f2), 287 * f2, 0, 0, 510, 292, 510*f2, 292*f2) --line that gives error
				local dummy1, dummy2 = context.button("dummy",w - 536, 267, 510, 312)
				-- -- Variables
				local skill_x, skill_y = 0, 0
				local val1, val2, valX, valY = {}, {}, {}, {}
				-- local skill1_p = { 2,4,5 } -- athletics
				local skill1_p = { 2,4,5 } -- block
				local skill2_p = { 2,4,5 } -- light armor
				local skill3_p = { 2,4,5 } -- heavy armor
				local skill4_p = { 1,4,5 } -- accuracy
				local skill5_p = { 2,4,5 } -- critical
				local skill6_p = { 2,4,5 } -- firearms
				local skill7_p = { 2,3,4,5 } -- seafaring
				local skill8_p = { 1,2,4,5 } -- alchemy
				local skill9_p = { 3,4,5 } -- tinkering
				local skill10_p = { 1,4,5 } -- ranged weapons
				local skill11_p = { 2,4,5 } -- throwing weapons
				local skill12_p = { 3,4,5 } -- light weapons
				local skill13_p = { 3,4,5 } -- heavy weapons
				local skill14_p = { 1,2,4,5 } -- spellblade
				local skill15_p = { 2,4,5 } -- elemental
				local skill16_p = { 2,4,5 } -- poison
				local skill17_p = { 3,4,5 } -- concentration
				local skill18_p = { 1,4,5 } -- witchcraft				
				local skill_perks = { skill1_p, skill2_p, skill3_p, skill4_p, skill5_p, skill6_p, skill7_p, skill8_p, skill9_p, skill10_p, skill11_p, skill12_p, skill13_p, skill14_p, skill15_p, skill16_p, skill17_p, skill18_p }
				-- Draw skills slots
				for i=1,18 do
					skill_x = math.floor((i-1) / 9)
					skill_y = (i-1) % 9
					context.drawImage2("mod_assets/textures/gui/skill_slots.dds", w - ((369 - (skill_x * 252)) * f2), (298 + (skill_y * 31)) * f2, 1, 1, 70, 21, 70*f2, 21*f2)
					val1[i], val2[i] = context.button("skill_info"..i, w - (548 - (skill_x * 252)), 292 + (skill_y * 31), 252, 31)
					valX[i] = 369 - (skill_x * 252)
					valY[i] = 298 + (skill_y * 31)
				end
				-- Draw skills slots (hover)
				for i=1,18 do	
					if val2[i] then
						context.drawImage2("mod_assets/textures/gui/skill_slots.dds", w - ((valX[i] + 1) * f2), (valY[i] - 1) * f2, 0, 23, 72, 23, 72*f2, 23*f2)
						break
					end
				end
				-- Draw skill pegs
				for i=1,18 do
					skill_x = math.floor((i-1) / 9)
					skill_y = (i-1) % 9
					local xpositions = {0,0,0,5,10}
					local tickX = 0				
					-- Draw green pegs
					local skillLevel = champion:getSkillLevel(functions.script.skillNames[i])
					local tempLevel = skillLevel + functions.script.partySkillTemp[champion:getOrdinal()][i]
					if skillLevel < 5 then					
						if tempLevel > 0 and skillLevel < 5 then
							for j=skillLevel+1,tempLevel do
								tickX = ((j-1) * 11) + xpositions[j]
								context.drawImage2("mod_assets/textures/gui/skill_slots.dds", w - ((366 - (skill_x * 252) - tickX) * f2), (301 + (skill_y * 31)) * f2, 10, 46, 10, 15, 10*f2, 15*f2)
							end
						end	
					end
					
					-- Draw yellow pegs
					local skillLevel = champion:getSkillLevel(functions.script.skillNames[i])
					if skillLevel > 0 then
						for j=1,skillLevel do
							tickX = ((j-1) * 11) + xpositions[j]
							context.drawImage2("mod_assets/textures/gui/skill_slots.dds", w - ((366 - (skill_x * 252) - tickX) * f2), (301 + (skill_y * 31)) * f2, 0, 46, 10, 15, 10*f2, 15*f2)
						end
					end
					
					-- Draw trait pegs
					for j=1,#skill_perks[i] do
						tickX = (skill_perks[i][j] - 1) * 11 + xpositions[skill_perks[i][j]]
						local got = 0
						if skillLevel >= skill_perks[i][j] or tempLevel >= skill_perks[i][j] then
							got = 7
						end
						if skill_perks[i][j] < 4 then
							context.drawImage2("mod_assets/textures/gui/skill_slots.dds", w - ((363 - (skill_x * 252) - tickX) * f2), (306 + (skill_y * 31)) * f2, 72, got, 4, 5, 4*f2, 5*f2)
						elseif skill_perks[i][j] == 4 then
							context.drawImage2("mod_assets/textures/gui/skill_slots.dds", w - ((364 - (skill_x * 252) - tickX) * f2), (305 + (skill_y * 31)) * f2, 76, got, 6, 6, 6*f2, 6*f2)
						else
							context.drawImage2("mod_assets/textures/gui/skill_slots.dds", w - ((364 - (skill_x * 252) - tickX) * f2), (305 + (skill_y * 31)) * f2, 82, got, 6, 7, 6*f2, 7*f2)
						end
					end				
				end
				-- Draw confirm and clear buttons
				local confirm1, confirm2 = context.button("confirm", w - (270), 584, 108, 32)
				local clear1, clear2 = context.button("clear", w - (270-125), 584, 108, 32)
				for i=1,18 do
					if functions.script.partySkillTemp[champion:getOrdinal()][i] > 0 then
						context.drawGuiItem2("ButtonAccept", w - (274*f2), 583*f2, 0, 0, 108, 32, 108*f2, 32*f2)
						context.drawGuiItem2("ButtonClear", w - ((274-125)*f2), 583*f2, 0, 0, 108, 32, 108*f2, 32*f2)
						if confirm2 then
							context.drawGuiItem2("ButtonAcceptHover", w - (274*f2), 583*f2, 0, 0, 108, 32, 108*f2, 32*f2)
							if context.mouseDown(3) then
								functions.script.performSkillTemp(champion)
							end
						end
						if clear2 then
							context.drawGuiItem2("ButtonClearHover", w - ((274-125)*f2), 583*f2, 0, 0, 108, 32, 108*f2, 32*f2)
							if context.mouseDown(3) then
								functions.script.clearSkillTemp(champion)
							end
						end
						break
					end
				end
				-- Draw description overlay and icon
				for j=1,18 do
					if val2[j] then	
						-- Click skill --
						local points = champion:getSkillPoints()
						local skillLevel = champion:getSkillLevel(functions.script.skillNames[j])
						local skillLevelTemp = functions.script.partySkillTemp[champion:getOrdinal()][j]
						local totalSkills = functions.script.countAllSkills(champion)
						if context.mouseDown(3) and points > 0 and skillLevelTemp < 5 and skillLevelTemp < 5 - skillLevel then
							if skillLevelTemp + skillLevel == 3 then
								if totalSkills >= 7 then
									functions.script.addSkillTemp(champion, j)
								else
									hudPrint("Need 7 allocated skill points to get Silver tier. You got " .. totalSkills .. ".")
								end						
							elseif skillLevelTemp + skillLevel == 4 then
								if totalSkills >= 11 then
									functions.script.addSkillTemp(champion, j)
								else
									hudPrint("Need 11 allocated skill points to get Gold tier. You got " .. totalSkills .. ".")
								end	
							else
								functions.script.addSkillTemp(champion, j)
							end
						end
						-- Unclick skill --
						if context.mouseDown(5) and functions.script.partySkillTemp[champion:getOrdinal()][j] > 0 then
							functions.script.removeSkillTemp(champion, j)						
						end
						-- Draw description
						local f3 = math.min(f2 + 0.1, 1)
						context.drawImage2("mod_assets/textures/gui/skill_description/skill_" .. j .. ".dds", w - (1170 * f), MY - 230, 0, 0, 556, 500, 556*f, 500*f)
						-- Draw icon
						-- context.drawImage2("mod_assets/textures/gui/skills.dds", w - (1228*f2), MY - 110 + 16, ((j-1)%13)*75, math.floor((j-1)/13)*75, 75, 75, 75*f3, 75*f3)
						break
					end	
				end
			end
		end,


			onDrawGui = function(party, g)
					
				end,
				onRest = function(party)
					if ( findEntity("GTK") ) then
						if ( GTK.Core.GUI:isPartyLocked() ) then	
							return false;
						end
					end			
				end,
				onWakeUp = function(party)
					if ( findEntity("GTK") ) then
						if ( GTK.Core.GUI:isPartyLocked() ) then
							return false;
						end
					end
			
				end,
------------------------------ OnInit
			onInit 	= function(self) end,
			
------------------------------ Unused OnDraws
			onDrawInventory		= function(self, context, champion) end,
			onDrawStats			= function(self, context, champion) end,
--			onDrawSkills		= function(self, context, champion) end,
			onDrawTraits		= function(self, context, champion) end,
			
------------------------------ On Draw GUI
--			onDrawGui = function(self, g)
--				--	Prevent using mouse look while the entire party is frozen and apply screen effect
--				if zim_functions.script.entirePartyHasCondition("frozen") then
--					self:playScreenEffect("frozen_screen")
--					GameMode.setGameFlag("DisableMouseLook", true)
--				end
--			end,
			
------------------------------ On Draw Attack Panel
			onDrawAttackPanel = function(self, champion, g, x, y, scaleX, scaleY, translationX, translationY)
				if champion:hasCondition("frozen") and not champion:hasCondition("petrified") then
					champion:showAttackResult("Frozen", "SpellNoEnergy")
				end
			end,
			
------------------------------ On Attack
			onAttack = function(self, champion, action, slot)
				if champion:hasCondition("frozen") then
					return false
				elseif champion:hasCondition("disarmed") then
					champion:showAttackResult("Disarmed!", "HitSplashLarge")
					return false
				end
				
				local item = champion:getItem(slot)
				if item and (item.go.name == "rope" or item.go.name == "shovel") then
					for i = 1,4 do
						local c = party.party:getChampion(i)
						if c and c:hasCondition("slowdown") then
							hudPrint("Can't use that right now...")
							return false
						end
					end
				end
			end,
			
------------------------------ on Death
			onDie = function(self, champion)
				zim_functions.script.cureConditions(champion, "death", false)
			end,
			
------------------------------ on Cast Spell
			onCastSpell = function(self, champion, spell)
			
				--	Silence spell blocker
				if champion:hasCondition("silence") then
					champion:showAttackResult("Silence", "SpellFizzle")
					playSound("spell_expires")
					return false
				end
			end,
			
------------------------------ on Damage
			onDamage = function(self, champion, damage, damageType)
			
				--	Fire damage can remove frozen condition
				--				can set the champion on fire
				if damageType == "fire" then
					if champion:hasCondition("frozen") then
						if damage > math.random(20,40) then
							champion:removeCondition("frozen")
						end
					elseif not champion:hasCondition("burning") and damage > math.random(25,55) then
						champion:setCondition("burning")
					end
					
				--	Cold damage can remove the burning condition
				--				can freeze the champion
				elseif damageType == "cold" then
					if champion:hasCondition("burning") then
						if damage > math.random(15,35) then
							champion:removeCondition("burning")
						end
					elseif not champion:hasCondition("frozen") and damage > math.random(25,75) then
						champion:setCondition("frozen")
					end	
					
				--	Shock damage can disrupt the champion
				elseif damageType == "shock" then
					if not champion:hasCondition("disrupted") and damage > math.random(25,75) then
						champion:setCondition("disrupted")
					end
				
				-- Physical damage can be reduced with the Vanguard item
				--					may cause bleeding
				elseif damageType == "physical" then
					local h1,h2 = champion:getItem(ItemSlot.Weapon),champion:getItem(ItemSlot.OffHand)
					if (h1 and h1.go.name == "vanguard") or (h2 and h2.go.name == "vanguard") then
						if math.random() < 0.33 then
							local newDamage = damage - champion:getLevel() * 10
							if newDamage > 0 then
								if not champion:hasCondition("bleeding") and newDamage > math.random(champion:getHealth()*0.15,champion:getHealth()*0.75) then
									champion:setConditionValue("bleeding", 15) 
								end									-- Check for bleeding proc because the other checker is not reached. (false is returned before it)
								champion:damage(newDamage, "pure")	-- Since armor is taken into account before the hook is called, we can use pure damage
								champion:playDamageSound()			-- But make sure there are no damage reductions on pure.
							end										-- It's pure, it shouldn't be reduced anyways. It exists for a reason.
							playSound("human_knight_block")
							return false
						end
					end
					
					if not champion:hasCondition("bleeding") and damage > math.random(champion:getHealth()*0.15,champion:getHealth()*0.75) then
						champion:setConditionValue("bleeding", 15) 
					end
				end
			end,
		
------------------------------ on Move
--			onMove = function(self, direction)
--				if zim_functions.script.entirePartyHasCondition("frozen") then
--					playSound("party_move_blocked") return false
--				end
--				
--				--	Prevent the party from moving if they're scoped
--				if self.go.isScoped:isEnabled() then return false end
--				
--				for i = 1, 4 do
--					for j = 1, 32 do
--						local item = party.party:getChampion(i):getItem(j)
--						if item then
--							if item.go.triggerOnMove then item.go.triggerOnMove.performAction(self, direction) end
--							if item.go.containeritem then
--								for s = 1, item.go.containeritem:getCapacity() do
--									local conItem = item.go.containeritem:getItem(s)
--									if conItem and conItem.go.triggerOnMove then conItem.go.triggerOnMove.performAction(self, direction) end
--								end
--							end
--						end
--					end
--				end
--				
--				local mouseItem = getMouseItem()
--				if mouseItem then
--					if mouseItem.go.triggerOnMove then mouseItem.go.triggerOnMove.performAction(self, direction) end
--					if mouseItem.go.containeritem then
--						for i = 1, mouseItem.go.containeritem:getCapacity() do
--							local item = mouseItem.go.containeritem:getItem(i)
--							if item and item.go.triggerOnMove then item.go.triggerOnMove.performAction(self, direction) end
--						end
--					end
--				end
--				
--			end,
--		
------------------------------ on Turn
--			onTurn = function(self, direction)
--				if zim_functions.script.entirePartyHasCondition("frozen") then
--					playSound("party_move_blocked") return false
--				end
--				
--				--	Prevent the party from turning if they're scoped
--				if self.go.isScoped:isEnabled() then return false end
--			end,
			
------------------------------ on Rest
			onRest = function(self)
				if ( findEntity("GTK") ) then
					if ( GTK.Core.GUI:isPartyLocked() ) then
						return false
					end
				end	
				
				--	Prevent the party from resting if everyone is frozen.
--				if zim_functions.script.entirePartyHasCondition("frozen") then
--					playSound("party_move_blocked")
--					return false
--				end
				
				--	Prevent the party from resting if they're scoped
				if self.go.isScoped:isEnabled() then return false end
				
				--	Prevent the party from resting if time was slowed down by a Timeless since waking up returns time scale back to 1.
				for i = 1,4 do
					local champion = self:getChampion(i)
					if champion:hasCondition("slowdown") then return false end
				end					
			end,
			
------------------------------ on Wake Up
			onWakeUp = function(self)
				if ( findEntity("GTK") ) then
					if ( GTK.Core.GUI:isPartyLocked() ) then
						return false
					end
				end
			end,
			
------------------------------ on Recieve Condition
			onReceiveCondition = function(self, champion, condition)
				if		condition == "burning"	then
					local tile = party.map:getAutomapTile(party.x, party.y)
					if champion:hasCondition("fire_shield") or champion:hasCondition("frozen") or (tile == 2 and party:getElevation() < 0) then
						return false
					end
					
--				elseif	condition == "frozen"	then
--					if champion:hasCondition("frost_shield") or champion:getResistance("cold") > 85 then
--						return false
--					else
--						if champion:hasCondition("burning") then champion:removeCondition("burning") end
--					end
					
				elseif	condition == "poison"	then if champion:hasCondition("poison_shield") then return false end
					
				elseif	condition == "disrupted"	then
					if champion:hasCondition("shock_shield") then return false end
					
--				elseif	condition == "frost_shield" then
--					if champion:hasCondition("frozen") then champion:removeCondition("frozen") end
					
				elseif	condition == "fire_shield" then
					if champion:hasCondition("burning") then champion:removeCondition("burning") end
					
				elseif	condition == "shock_shield" then
					if champion:hasCondition("disrupted") then champion:removeCondition("disrupted") end
					
				elseif	condition == "poison_shield" then
					if champion:hasCondition("poison") then champion:removeCondition("poison") end
					
				elseif	condition == "marked" then
					local necklace = champion:getItem(8)
					if necklace and necklace.go.name == "demonbane_sigil" then
						playSound("goromorg_shield_hit")
						champion:showAttackResult("Negated!", "HitSplashLarge")
						return false
					end
				end
			end,
			
------------------------------ on Pick Up Item
			onPickUpItem = function(self, item)
				if item:hasTrait("toxic") and not self.go.toxicItemTimer:isEnabled() then
					self.go.toxicItemTimer:enable()
				end
			end,
			
------------------------------ on Click Item Slot
			onClickItemSlot = function(self, champion, container, slot, button)
				if party.party:isCarrying("rope") or party.party:isCarrying("shovel") then
					if button == 2 then
						for i = 1,4 do
							local c = party.party:getChampion(i)
							if c and c:hasCondition("slowdown") then
								local item = champion:getItem(slot)
								if item then
									if item.go.name == "rope" or item.go.name == "shovel" then
										hudPrint("Can't use that right now...")
										return false
									end
								elseif container then
									local i = container:getItem(slot)
									if i and (i.go.name == "rope" or i.go.name == "shovel") then
										hudPrint("Can't use that right now...")
										return false
									end
								end
							end
						end
					end
				end
			end,
				onDrawGui = function(party, g)
					
				end,
				onRest = function(party)
					if ( findEntity("GTK") ) then
						if ( GTK.Core.GUI:isPartyLocked() ) then
							return false;
						end
					end			
				end,
				onWakeUp = function(party)
					if ( findEntity("GTK") ) then
						if ( GTK.Core.GUI:isPartyLocked() ) then
							return false;
						end
					end
				end,
		},	
		{
       class = "Particle",
		 name = "snow2",
		 ParticleSystem = "sx_snow_emitter_party",
		},
	},
}
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Where the scripting reference pages list components and objects, they list them as what they are...which is not always (and not often) how they are named in the script. GraphicsContext is defined in that function as simply: context; and this can be seen at the very first line of the function, where the function's parameters are shown.

In this case these are not arbitrary. The engine calls this function and gives it these parameters, and in that order. To access the GraphicsContext functions and values, you must reference it as context rather than GraphicsContext. Reference it as it appears above, in the function's parameters.


*To be clear... the function parameter names themselves are up to the person writing the script, and they'll work so long as the name is used consistantly, but it is the position in the list of parameters that determines their content. In this case, the name context was used as the name of the second parameter/ or argument of the function. That argument is the GraphicsContext provided by the engine.
User avatar
ratman
Posts: 158
Joined: Fri Jan 10, 2020 1:13 am

Re: Ask a simple question, get a simple answer

Post by ratman »

now it gives error : 'bad argument #1 to 'drawGuiItem' (string expected, got nil) on the same line.
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Argument #1 is SkillsTab, which does not appear anywhere in your posted script as a variable. Anything undefined is nil. The function expects a graphics item, and there is one called SkillsTab, so... that's likely what is intended. You must enclose the word SkillsTab in quotes; making it a string data type.... as the error message states that it expected.
Post Reply