Page 167 of 400
Re: Ask a simple question, get a simple answer
Posted: Sun Nov 20, 2016 2:03 am
by Duncan1246
AndakRainor wrote:Duncan1246 wrote:It's probably a silly question, but I need an answer: how can I close an image drawn with context commands? (code in my last post on this thread)
You could remove the connector, or immediately return in your drawing function when some condition is met.
I try to remove the connector with
Code: Select all
if ( context.button("CLOSE", offset+10, (0.8 * height)+10, 90, 90) ) then
print("CLOSED")
party.party:removeConnector("onDrawGui", self.go.id, "newsheetS")
end
"CLOSED" is print, but image stays, and click on screen is useless. What do you means by return to the drawing function?
Re: Ask a simple question, get a simple answer
Posted: Sun Nov 20, 2016 2:12 am
by AndakRainor
I mean return from the drawing function, like that:
Code: Select all
party.party:addConnector("onDrawGui", self.go.id, "newsheet")
drawFlag = true
function newsheet(self, context)
if drawFlag then
textlist()
local width = context.width
local height = context.height
local offset = context.width * .1
context.drawImage2("mod_assets/textures/dc_octog4_panel.tga",5,5,0,0,640, 480, width, height)
context.drawRect(offset, (0.8 * height), 90, 30)
context.color(0,0,0,255)
context.drawText("CLOSE", offset+10, (0.8 * height)+20)
if ( context.button("CLOSE", offset+10, (0.8 * height)+10, 90, 90) ) then
print("CLOSED")
--party.party:removeConnector("onDrawGui", self.go.id, "newsheet")
drawFlag = false
end
context.font("large")
context.drawParagraph(bufferpage, offset, context.height*.1, width*.8)
end
end
Re-Edit: oops! I did not see that you used self.go.id in your removeConnector. This can not work, as in this function, self is the party component. You should use instead:
Code: Select all
party.party:removeConnector("onDrawGui", "myScript", "newsheet")
where "myScript" is the ID of your script entity with the newsheet function.
Re: Ask a simple question, get a simple answer
Posted: Sun Nov 20, 2016 2:23 am
by Duncan1246
AndakRainor wrote:I mean return from the drawing function, like that:
Code: Select all
party.party:addConnector("onDrawGui", self.go.id, "newsheet")
drawFlag = true
function newsheet(self, context)
if drawFlag then
textlist()
local width = context.width
local height = context.height
local offset = context.width * .1
context.drawImage2("mod_assets/textures/dc_octog4_panel.tga",5,5,0,0,640, 480, width, height)
context.drawRect(offset, (0.8 * height), 90, 30)
context.color(0,0,0,255)
context.drawText("CLOSE", offset+10, (0.8 * height)+20)
if ( context.button("CLOSE", offset+10, (0.8 * height)+10, 90, 90) ) then
print("CLOSED")
--party.party:removeConnector("onDrawGui", self.go.id, "newsheet")
drawFlag = false
end
context.font("large")
context.drawParagraph(bufferpage, offset, context.height*.1, width*.8)
end
end
Edit: if the image stays after you removed the connector, it means you added the connector twice or more, and so removing it one time was not enough.
The hook is read only once, but the flag solution works as intended, thanks a lot!
Re: Ask a simple question, get a simple answer
Posted: Sun Nov 20, 2016 2:24 am
by AndakRainor
See my previous edit, I made several mistakes in my first answer, I should sleep more xD
If you want to use this function one time only, you should use the remove connector method. If you will use it several times, the flag solution can be more convenient, just switch it when you need it.
Re: Ask a simple question, get a simple answer
Posted: Sun Nov 20, 2016 2:35 am
by Duncan1246
AndakRainor wrote:See my previous edit, I made several mistakes in my first answer, I should sleep more xD
If you want to use this function one time only, you should use the remove connector method. If you will use it several times, the flag solution can be more convenient, just switch it when you need it.
Here it's 1h33 am, thanks to you I can now have some rest, I wish the same to you.

Re: Ask a simple question, get a simple answer
Posted: Mon Nov 21, 2016 12:58 am
by bongobeat
minmay wrote:Epic items are counted when the dungeon begins to get the maximum number. If this count is incorrect because you want to spawn an additional epic item, you can just use GameMode.setMaxStatistic() to fix it.
thanks all, for your answer!
Re: Ask a simple question, get a simple answer
Posted: Mon Nov 21, 2016 1:10 pm
by bongobeat
I have searched some informations in the scripting reference about
but I did not found anything. Someone can help please? what argument should be used for counting the epic items?
Re: Ask a simple question, get a simple answer
Posted: Mon Nov 21, 2016 7:16 pm
by minmay
GameMode.setMaxStatistic(stat,max)
Let's say you want to increase the maximum number of epic items by one. Then you'd call:
Code: Select all
GameMode.setMaxStatistic("epic_items_found",GameMode.getMaxStatistic("epic_items_found")+1)
Re: Ask a simple question, get a simple answer
Posted: Mon Nov 21, 2016 9:54 pm
by Isaac
minmay wrote:GameMode.setMaxStatistic(stat,max)
Let's say you want to increase the maximum number of epic items by one. Then you'd call:
Code: Select all
GameMode.setMaxStatistic("epic_items_found",GameMode.getMaxStatistic("epic_items_found")+1)
Thank you.
Where does it say "epic_items_found" is a statistic?
(Is there a published list of all the LoG2 statistics?)
Re: Ask a simple question, get a simple answer
Posted: Mon Nov 21, 2016 10:00 pm
by minmay
polymorphs
potions_mixed
spells_cast
power_attacks
unarmed_attacks
firearm_attacks
missile_attacks
throw_attacks
melee_attacks
ladders_climbed
pit_falls
tiles_dived
tiles_moved
gold_keys_used
levels_visited
fish_caught
skulls_found
treasures_found
essences_found
power_gems_found
epic_items_found
items_found
monsters_killed
secrets_found
play_time